From 1d091ac98d728e3c4684e44854089ac537e3c675 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Mon, 8 Feb 2021 11:07:48 -0800 Subject: [PATCH] Add payment number and date. IO-610 --- bodyshop_translations.babel | 63 ++++++++++++------- .../accounting-payments-table.component.jsx | 20 +++++- .../payment-form/payment-form.component.jsx | 14 ++++- .../payment-list-paginated.component.jsx | 19 +++++- client/src/graphql/accounting.queries.js | 2 + client/src/graphql/payments.queries.js | 6 ++ .../payments-all.container.page.jsx | 2 +- client/src/translations/en_us/common.json | 3 +- client/src/translations/es/common.json | 3 +- client/src/translations/fr/common.json | 3 +- .../down.yaml | 5 ++ .../up.yaml | 5 ++ .../down.yaml | 37 +++++++++++ .../up.yaml | 38 +++++++++++ .../down.yaml | 36 +++++++++++ .../up.yaml | 37 +++++++++++ .../down.yaml | 36 +++++++++++ .../up.yaml | 37 +++++++++++ .../down.yaml | 36 +++++++++++ .../up.yaml | 37 +++++++++++ .../1612809975689_run_sql_migration/down.yaml | 1 + .../1612809975689_run_sql_migration/up.yaml | 10 +++ .../1612810025041_run_sql_migration/down.yaml | 1 + .../1612810025041_run_sql_migration/up.yaml | 10 +++ .../down.yaml | 5 ++ .../up.yaml | 5 ++ .../down.yaml | 37 +++++++++++ .../up.yaml | 38 +++++++++++ .../down.yaml | 38 +++++++++++ .../up.yaml | 39 ++++++++++++ .../down.yaml | 37 +++++++++++ .../up.yaml | 38 +++++++++++ hasura/migrations/metadata.yaml | 6 ++ server/accounting/qbxml/qbxml-payments.js | 5 +- server/graphql-client/queries.js | 2 + 35 files changed, 679 insertions(+), 32 deletions(-) create mode 100644 hasura/migrations/1612809714719_alter_table_public_payments_add_column_paymentnum/down.yaml create mode 100644 hasura/migrations/1612809714719_alter_table_public_payments_add_column_paymentnum/up.yaml create mode 100644 hasura/migrations/1612809727981_update_permission_user_public_table_payments/down.yaml create mode 100644 hasura/migrations/1612809727981_update_permission_user_public_table_payments/up.yaml create mode 100644 hasura/migrations/1612809735669_update_permission_user_public_table_payments/down.yaml create mode 100644 hasura/migrations/1612809735669_update_permission_user_public_table_payments/up.yaml create mode 100644 hasura/migrations/1612809739863_update_permission_user_public_table_payments/down.yaml create mode 100644 hasura/migrations/1612809739863_update_permission_user_public_table_payments/up.yaml create mode 100644 hasura/migrations/1612809744309_update_permission_user_public_table_payments/down.yaml create mode 100644 hasura/migrations/1612809744309_update_permission_user_public_table_payments/up.yaml create mode 100644 hasura/migrations/1612809975689_run_sql_migration/down.yaml create mode 100644 hasura/migrations/1612809975689_run_sql_migration/up.yaml create mode 100644 hasura/migrations/1612810025041_run_sql_migration/down.yaml create mode 100644 hasura/migrations/1612810025041_run_sql_migration/up.yaml create mode 100644 hasura/migrations/1612810428150_alter_table_public_payments_add_column_date/down.yaml create mode 100644 hasura/migrations/1612810428150_alter_table_public_payments_add_column_date/up.yaml create mode 100644 hasura/migrations/1612810438043_update_permission_user_public_table_payments/down.yaml create mode 100644 hasura/migrations/1612810438043_update_permission_user_public_table_payments/up.yaml create mode 100644 hasura/migrations/1612810444714_update_permission_user_public_table_payments/down.yaml create mode 100644 hasura/migrations/1612810444714_update_permission_user_public_table_payments/up.yaml create mode 100644 hasura/migrations/1612810451283_update_permission_user_public_table_payments/down.yaml create mode 100644 hasura/migrations/1612810451283_update_permission_user_public_table_payments/up.yaml diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 78eaf286a..d64846190 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -1101,27 +1101,6 @@ fields - - actual - false - - - - - - en-US - false - - - es-MX - false - - - fr-CA - false - - - actual_cost false @@ -23128,6 +23107,27 @@ + + date + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + exportedat false @@ -23191,6 +23191,27 @@ + + paymentnum + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + stripeid false diff --git a/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx b/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx index ab5c565ee..1b32eba04 100644 --- a/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx +++ b/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx @@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import { logImEXEvent } from "../../firebase/firebase.utils"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; -import { DateTimeFormatter } from "../../utils/DateFormatter"; +import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter"; import { alphaSort } from "../../utils/sorters"; import PaymentExportButton from "../payment-export-button/payment-export-button.component"; import { PaymentsExportAllButton } from "../payments-export-all-button/payments-export-all-button.component"; @@ -37,7 +37,23 @@ export default function AccountingPayablesTableComponent({ {record.job.ro_number} ), }, - + { + title: t("payments.fields.date"), + dataIndex: "date", + key: "date", + sorter: (a, b) => alphaSort(a.date, b.date), + sortOrder: + state.sortedInfo.columnKey === "date" && state.sortedInfo.order, + render: (text, record) => {record.date}, + }, + { + title: t("payments.fields.date"), + dataIndex: "date", + key: "date", + sorter: (a, b) => alphaSort(a.date, b.date), + sortOrder: + state.sortedInfo.columnKey === "date" && state.sortedInfo.order, + }, { title: t("jobs.fields.owner"), dataIndex: "owner", diff --git a/client/src/components/payment-form/payment-form.component.jsx b/client/src/components/payment-form/payment-form.component.jsx index adf2bc18b..dea21e6fb 100644 --- a/client/src/components/payment-form/payment-form.component.jsx +++ b/client/src/components/payment-form/payment-form.component.jsx @@ -6,6 +6,7 @@ import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; import Alert from "../alert/alert.component"; +import DatePickerFormItem from "../form-date-picker/form-date-picker.component"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; import JobSearchSelect from "../job-search-select/job-search-select.component"; @@ -63,7 +64,18 @@ export function PaymentFormComponent({ - + + + ), }, - + { + title: t("payments.fields.paymentnum"), + dataIndex: "paymentnum", + key: "paymentnum", + sorter: (a, b) => alphaSort(a.paymentnum, b.paymentnum), + sortOrder: sortcolumn === "paymentnum" && sortorder, + }, { title: t("jobs.fields.owner"), dataIndex: "owner", @@ -73,6 +79,15 @@ export function PaymentsListPaginated({ ); }, }, + { + title: t("payments.fields.date"), + dataIndex: "date", + key: "date", + sorter: (a, b) => alphaSort(a.date, b.date), + sortOrder: + state.sortedInfo.columnKey === "date" && state.sortedInfo.order, + render: (text, record) => {record.date}, + }, { title: t("payments.fields.amount"), dataIndex: "amount", diff --git a/client/src/graphql/accounting.queries.js b/client/src/graphql/accounting.queries.js index f6010f583..2f55537c0 100644 --- a/client/src/graphql/accounting.queries.js +++ b/client/src/graphql/accounting.queries.js @@ -71,6 +71,8 @@ export const QUERY_PAYMENTS_FOR_EXPORT = gql` stripeid created_at transactionid + paymentnum + date } } `; diff --git a/client/src/graphql/payments.queries.js b/client/src/graphql/payments.queries.js index 5103358f1..f1b3aa32d 100644 --- a/client/src/graphql/payments.queries.js +++ b/client/src/graphql/payments.queries.js @@ -26,6 +26,8 @@ export const QUERY_ALL_PAYMENTS_PAGINATED = gql` id created_at jobid + paymentnum + date job { id ro_number @@ -63,6 +65,8 @@ export const UPDATE_PAYMENT = gql` exportedat stripeid payer + paymentnum + date } } } @@ -85,6 +89,8 @@ export const UPDATE_PAYMENTS = gql` exportedat stripeid payer + paymentnum + date } } } diff --git a/client/src/pages/payments-all/payments-all.container.page.jsx b/client/src/pages/payments-all/payments-all.container.page.jsx index 10f02e81c..df7492fe5 100644 --- a/client/src/pages/payments-all/payments-all.container.page.jsx +++ b/client/src/pages/payments-all/payments-all.container.page.jsx @@ -37,7 +37,7 @@ export function AllJobs({ bodyshop, setBreadcrumbs, setSelectedHeader }) { limit: 25, order: [ { - [sortcolumn || "created_at"]: sortorder + [sortcolumn || "date"]: sortorder ? sortorder === "descend" ? "desc" : "asc" diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 1e1e9e941..f93919eaf 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -85,7 +85,6 @@ "newline": "New Line" }, "fields": { - "actual": "Retail Price", "actual_cost": "Actual Cost", "actual_price": "Retail", "cost_center": "Cost Center", @@ -1407,9 +1406,11 @@ "fields": { "amount": "Amount", "created_at": "Created At", + "date": "Payment Date", "exportedat": "Exported At", "memo": "Memo", "payer": "Payer", + "paymentnum": "Payment Number", "stripeid": "Stripe ID", "transactionid": "Transaction ID", "type": "Type" diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index b1ab61528..8c42db601 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -85,7 +85,6 @@ "newline": "" }, "fields": { - "actual": "", "actual_cost": "", "actual_price": "", "cost_center": "", @@ -1407,9 +1406,11 @@ "fields": { "amount": "", "created_at": "", + "date": "", "exportedat": "", "memo": "", "payer": "", + "paymentnum": "", "stripeid": "", "transactionid": "", "type": "" diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 9101a6c4b..7449ae7fa 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -85,7 +85,6 @@ "newline": "" }, "fields": { - "actual": "", "actual_cost": "", "actual_price": "", "cost_center": "", @@ -1407,9 +1406,11 @@ "fields": { "amount": "", "created_at": "", + "date": "", "exportedat": "", "memo": "", "payer": "", + "paymentnum": "", "stripeid": "", "transactionid": "", "type": "" diff --git a/hasura/migrations/1612809714719_alter_table_public_payments_add_column_paymentnum/down.yaml b/hasura/migrations/1612809714719_alter_table_public_payments_add_column_paymentnum/down.yaml new file mode 100644 index 000000000..e9b20c89e --- /dev/null +++ b/hasura/migrations/1612809714719_alter_table_public_payments_add_column_paymentnum/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."payments" DROP COLUMN "paymentnum"; + type: run_sql diff --git a/hasura/migrations/1612809714719_alter_table_public_payments_add_column_paymentnum/up.yaml b/hasura/migrations/1612809714719_alter_table_public_payments_add_column_paymentnum/up.yaml new file mode 100644 index 000000000..bc705009e --- /dev/null +++ b/hasura/migrations/1612809714719_alter_table_public_payments_add_column_paymentnum/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."payments" ADD COLUMN "paymentnum" text NULL; + type: run_sql diff --git a/hasura/migrations/1612809727981_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1612809727981_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..d3263f3f0 --- /dev/null +++ b/hasura/migrations/1612809727981_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - type + - updated_at + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: payments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1612809727981_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1612809727981_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..6635ad75a --- /dev/null +++ b/hasura/migrations/1612809727981_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,38 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - paymentnum + - stripeid + - transactionid + - type + - updated_at + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: payments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1612809735669_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1612809735669_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..d048afd30 --- /dev/null +++ b/hasura/migrations/1612809735669_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,36 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_insert_permission +- args: + permission: + check: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - type + - updated_at + set: {} + role: user + table: + name: payments + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1612809735669_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1612809735669_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..b1dc6deff --- /dev/null +++ b/hasura/migrations/1612809735669_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_insert_permission +- args: + permission: + check: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - paymentnum + - stripeid + - transactionid + - type + - updated_at + set: {} + role: user + table: + name: payments + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1612809739863_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1612809739863_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..ffba0de91 --- /dev/null +++ b/hasura/migrations/1612809739863_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,36 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - type + - updated_at + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: payments + schema: public + type: create_update_permission diff --git a/hasura/migrations/1612809739863_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1612809739863_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..4b6a2bb0b --- /dev/null +++ b/hasura/migrations/1612809739863_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - paymentnum + - stripeid + - transactionid + - type + - updated_at + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: payments + schema: public + type: create_update_permission diff --git a/hasura/migrations/1612809744309_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1612809744309_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..ffba0de91 --- /dev/null +++ b/hasura/migrations/1612809744309_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,36 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - type + - updated_at + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: payments + schema: public + type: create_update_permission diff --git a/hasura/migrations/1612809744309_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1612809744309_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..4b6a2bb0b --- /dev/null +++ b/hasura/migrations/1612809744309_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - paymentnum + - stripeid + - transactionid + - type + - updated_at + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: payments + schema: public + type: create_update_permission diff --git a/hasura/migrations/1612809975689_run_sql_migration/down.yaml b/hasura/migrations/1612809975689_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1612809975689_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1612809975689_run_sql_migration/up.yaml b/hasura/migrations/1612809975689_run_sql_migration/up.yaml new file mode 100644 index 000000000..62df62d11 --- /dev/null +++ b/hasura/migrations/1612809975689_run_sql_migration/up.yaml @@ -0,0 +1,10 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE FUNCTION public.assign_payment_number ()\n\tRETURNS TRIGGER\n\tLANGUAGE + plpgsql\n\tAS $function$\nBEGIN\n\tIF (new.paymentnum IS NULL\n\t\tOR new.paymentnum + = 'pnew') THEN\n\tUPDATE\n\t\tcounters\n\tSET\n\t\tcount = count + 1\n\tFROM\n\t\tbodyshops\n\tWHERE\n\t\tbodyshops.id + = (\n\t\t\tSELECT\n\t\t\t\tshopid\n\t\t\tFROM\n\t\t\t\tjobs\n\t\t\tWHERE\n\t\t\t\tjobs.id + = new.jobid)\n\t\t\tAND countertype = 'paymentnum'\n\t\tRETURNING\n\t\t\tconcat(prefix, + count) INTO new.paymentnum;\nEND IF;\n\tRETURN NEW;\nEND;\n$function$;" + type: run_sql diff --git a/hasura/migrations/1612810025041_run_sql_migration/down.yaml b/hasura/migrations/1612810025041_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1612810025041_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1612810025041_run_sql_migration/up.yaml b/hasura/migrations/1612810025041_run_sql_migration/up.yaml new file mode 100644 index 000000000..096f1b44c --- /dev/null +++ b/hasura/migrations/1612810025041_run_sql_migration/up.yaml @@ -0,0 +1,10 @@ +- args: + cascade: true + read_only: false + sql: |- + create trigger payments_assign_paymentnum before + insert + on + public.payments + for each row execute procedure assign_payment_number(); + type: run_sql diff --git a/hasura/migrations/1612810428150_alter_table_public_payments_add_column_date/down.yaml b/hasura/migrations/1612810428150_alter_table_public_payments_add_column_date/down.yaml new file mode 100644 index 000000000..e475df732 --- /dev/null +++ b/hasura/migrations/1612810428150_alter_table_public_payments_add_column_date/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."payments" DROP COLUMN "date"; + type: run_sql diff --git a/hasura/migrations/1612810428150_alter_table_public_payments_add_column_date/up.yaml b/hasura/migrations/1612810428150_alter_table_public_payments_add_column_date/up.yaml new file mode 100644 index 000000000..21103bf27 --- /dev/null +++ b/hasura/migrations/1612810428150_alter_table_public_payments_add_column_date/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."payments" ADD COLUMN "date" date NULL; + type: run_sql diff --git a/hasura/migrations/1612810438043_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1612810438043_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..b1dc6deff --- /dev/null +++ b/hasura/migrations/1612810438043_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_insert_permission +- args: + permission: + check: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - paymentnum + - stripeid + - transactionid + - type + - updated_at + set: {} + role: user + table: + name: payments + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1612810438043_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1612810438043_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..19c9c80bf --- /dev/null +++ b/hasura/migrations/1612810438043_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,38 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_insert_permission +- args: + permission: + check: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - amount + - created_at + - date + - exportedat + - id + - jobid + - memo + - payer + - paymentnum + - stripeid + - transactionid + - type + - updated_at + set: {} + role: user + table: + name: payments + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1612810444714_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1612810444714_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..6635ad75a --- /dev/null +++ b/hasura/migrations/1612810444714_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,38 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - paymentnum + - stripeid + - transactionid + - type + - updated_at + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: payments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1612810444714_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1612810444714_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..eda8df053 --- /dev/null +++ b/hasura/migrations/1612810444714_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,39 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - amount + - created_at + - date + - exportedat + - id + - jobid + - memo + - payer + - paymentnum + - stripeid + - transactionid + - type + - updated_at + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: payments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1612810451283_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1612810451283_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..4b6a2bb0b --- /dev/null +++ b/hasura/migrations/1612810451283_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - paymentnum + - stripeid + - transactionid + - type + - updated_at + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: payments + schema: public + type: create_update_permission diff --git a/hasura/migrations/1612810451283_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1612810451283_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..6d40dd054 --- /dev/null +++ b/hasura/migrations/1612810451283_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,38 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - amount + - created_at + - date + - exportedat + - id + - jobid + - memo + - payer + - paymentnum + - stripeid + - transactionid + - type + - updated_at + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: payments + schema: public + type: create_update_permission diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index 50cb592d2..f5b8535e0 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -3488,11 +3488,13 @@ tables: columns: - amount - created_at + - date - exportedat - id - jobid - memo - payer + - paymentnum - stripeid - transactionid - type @@ -3503,11 +3505,13 @@ tables: columns: - amount - created_at + - date - exportedat - id - jobid - memo - payer + - paymentnum - stripeid - transactionid - type @@ -3529,11 +3533,13 @@ tables: columns: - amount - created_at + - date - exportedat - id - jobid - memo - payer + - paymentnum - stripeid - transactionid - type diff --git a/server/accounting/qbxml/qbxml-payments.js b/server/accounting/qbxml/qbxml-payments.js index ab1548bb2..aa3c67db7 100644 --- a/server/accounting/qbxml/qbxml-payments.js +++ b/server/accounting/qbxml/qbxml-payments.js @@ -71,8 +71,9 @@ const generatePayment = (payment) => { FullName: payment.job.bodyshop.md_responsibility_centers.ar.accountname, }, - TxnDate: moment(payment.created_at).format("YYYY-MM-DD"), //Trim String - RefNumber: payment.stripeid || payment.transactionid, + TxnDate: moment(payment.date).format("YYYY-MM-DD"), //Trim String + RefNumber: + payment.paymentnum || payment.stripeid || payment.transactionid, TotalAmount: Dinero({ amount: Math.round(payment.amount * 100), }).toFormat(DineroQbFormat), diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index 79eb13924..8ac1b9e34 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -176,6 +176,8 @@ exports.QUERY_PAYMENTS_FOR_EXPORT = ` stripeid type payer + paymentnum + date } } `;