Add payment number and date. IO-610

This commit is contained in:
Patrick Fic
2021-02-08 11:07:48 -08:00
parent f14b665e26
commit 1d091ac98d
35 changed files with 679 additions and 32 deletions

View File

@@ -1101,27 +1101,6 @@
<folder_node>
<name>fields</name>
<children>
<concept_node>
<name>actual</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>actual_cost</name>
<definition_loaded>false</definition_loaded>
@@ -23128,6 +23107,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>date</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>exportedat</name>
<definition_loaded>false</definition_loaded>
@@ -23191,6 +23191,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>paymentnum</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>stripeid</name>
<definition_loaded>false</definition_loaded>

View File

@@ -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({
<Link to={"/manage/jobs/" + record.job.id}>{record.job.ro_number}</Link>
),
},
{
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) => <DateFormatter>{record.date}</DateFormatter>,
},
{
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",

View File

@@ -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({
<Form.Item label={t("payments.fields.memo")} name="memo">
<Input disabled={disabled} />
</Form.Item>
<Form.Item
label={t("payments.fields.date")}
name="date"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<DatePickerFormItem disabled={disabled} />
</Form.Item>
<Form.Item
label={t("payments.fields.payer")}
name="payer"

View File

@@ -5,7 +5,7 @@ import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, useHistory, useLocation } from "react-router-dom";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import { DateTimeFormatter } from "../../utils/DateFormatter";
import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter";
import { alphaSort } from "../../utils/sorters";
import { connect } from "react-redux";
@@ -51,7 +51,13 @@ export function PaymentsListPaginated({
</Link>
),
},
{
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) => <DateFormatter>{record.date}</DateFormatter>,
},
{
title: t("payments.fields.amount"),
dataIndex: "amount",

View File

@@ -71,6 +71,8 @@ export const QUERY_PAYMENTS_FOR_EXPORT = gql`
stripeid
created_at
transactionid
paymentnum
date
}
}
`;

View File

@@ -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
}
}
}

View File

@@ -37,7 +37,7 @@ export function AllJobs({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
limit: 25,
order: [
{
[sortcolumn || "created_at"]: sortorder
[sortcolumn || "date"]: sortorder
? sortorder === "descend"
? "desc"
: "asc"

View File

@@ -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"

View File

@@ -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": ""

View File

@@ -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": ""

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."payments" DROP COLUMN "paymentnum";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."payments" ADD COLUMN "paymentnum" text NULL;
type: run_sql

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1 @@
[]

View File

@@ -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

View File

@@ -0,0 +1 @@
[]

View File

@@ -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

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."payments" DROP COLUMN "date";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."payments" ADD COLUMN "date" date NULL;
type: run_sql

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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),

View File

@@ -176,6 +176,8 @@ exports.QUERY_PAYMENTS_FOR_EXPORT = `
stripeid
type
payer
paymentnum
date
}
}
`;