From 69e7612b624cb962660cc414bfe62113c245b3ff Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Thu, 5 Nov 2020 12:16:28 +0200 Subject: [PATCH] feat: payment receive and made form. --- client/src/common/classes.js | 3 + .../src/containers/Purchases/Bill/BillForm.js | 18 +- .../Purchases/Bill/BillFormHeader.js | 6 + .../containers/Purchases/Bill/withBills.js | 11 +- .../Purchases/PaymentMades/PaymentMade.js | 1 + .../PaymentMades/PaymentMadeFooter.js | 32 ++ .../Purchases/PaymentMades/PaymentMadeForm.js | 175 +++++++--- .../PaymentMades/PaymentMadeFormHeader.js | 288 ++++++++-------- .../PaymentMades/PaymentMadeItemsTable.js | 106 +++--- .../PaymentMadeItemsTableEditor.js | 10 +- .../Purchases/PaymentMades/withPaymentMade.js | 7 +- .../containers/Sales/Invoice/InvoiceForm.js | 1 - .../Sales/Invoice/InvoiceFormHeader.js | 1 - .../containers/Sales/Invoice/withInvoices.js | 12 +- .../PaymentReceive/PaymentReceiveForm.js | 188 +++++++---- .../PaymentReceiveFormFooter.js | 32 ++ .../PaymentReceiveFormHeader.js | 308 +++++++++--------- .../PaymentReceive/PaymentReceiveFormPage.js | 13 +- .../PaymentReceiveItemsTable.js | 91 +++--- .../PaymentReceiveItemsTableEditor.js | 11 +- .../Sales/PaymentReceive/PaymentReceives.js | 103 ------ .../withPaymentReceiveDetail.js | 5 +- client/src/lang/en/index.js | 3 +- client/src/routes/dashboard.js | 4 +- client/src/store/Bills/bills.reducer.js | 8 + client/src/store/Bills/bills.selectors.js | 60 ++-- client/src/store/Bills/bills.type.js | 2 +- client/src/store/Invoice/invoices.actions.js | 1 - client/src/store/Invoice/invoices.reducer.js | 10 +- client/src/store/Invoice/invoices.selector.js | 45 +-- client/src/store/Invoice/invoices.types.js | 3 +- .../store/PaymentMades/paymentMade.actions.js | 19 +- .../PaymentMades/paymentMade.selector.js | 50 ++- .../PaymentReceive/paymentReceive.actions.js | 21 +- .../PaymentReceive/paymentReceive.selector.js | 94 ++++-- client/src/style/App.scss | 34 ++ client/src/style/pages/payment-made.scss | 14 + client/src/style/pages/payment-receive.scss | 14 + client/src/utils.js | 12 + server/src/interfaces/SaleInvoice.ts | 1 + server/src/services/Purchases/BillPayments.ts | 16 +- server/src/services/Sales/PaymentsReceives.ts | 17 +- 42 files changed, 1100 insertions(+), 750 deletions(-) create mode 100644 client/src/containers/Purchases/PaymentMades/PaymentMadeFooter.js create mode 100644 client/src/containers/Sales/PaymentReceive/PaymentReceiveFormFooter.js delete mode 100644 client/src/containers/Sales/PaymentReceive/PaymentReceives.js diff --git a/client/src/common/classes.js b/client/src/common/classes.js index f6112b1a8..ca94a067a 100644 --- a/client/src/common/classes.js +++ b/client/src/common/classes.js @@ -8,6 +8,9 @@ const CLASSES = { PAGE_FORM: 'page-form', PAGE_FORM_HEADER: 'page-form__header', PAGE_FORM_HEADER_PRIMARY: 'page-form__primary-section', + PAGE_FORM_HEADER_FIELDS: 'page-form__header-fields', + PAGE_FORM_HEADER_BIG_NUMBERS: 'page-form__big-numbers', + PAGE_FORM_FOOTER: 'page-form__footer', PAGE_FORM_FLOATING_ACTIONS: 'page-form__floating-actions', diff --git a/client/src/containers/Purchases/Bill/BillForm.js b/client/src/containers/Purchases/Bill/BillForm.js index 47c800e5a..9a05536eb 100644 --- a/client/src/containers/Purchases/Bill/BillForm.js +++ b/client/src/containers/Purchases/Bill/BillForm.js @@ -13,10 +13,12 @@ import classNames from 'classnames'; import { FormattedMessage as T, useIntl } from 'react-intl'; import { pick } from 'lodash'; import { CLASSES } from 'common/classes'; + import BillFormHeader from './BillFormHeader'; import EstimatesItemsTable from 'containers/Sales/Estimate/EntriesItemsTable'; import BillFloatingActions from './BillFloatingActions'; import BillFormFooter from './BillFormFooter'; + import withDashboardActions from 'containers/Dashboard/withDashboardActions'; import withMediaActions from 'containers/Media/withMediaActions'; import withBillActions from './withBillActions'; @@ -41,6 +43,7 @@ function BillForm({ //#withDashboard changePageTitle, + changePageSubtitle, //#withBillDetail bill, @@ -235,6 +238,7 @@ function BillForm({ setSubmitting(false); saveBillSubmit({ action: 'update', ...payload }); resetForm(); + changePageSubtitle(''); }) .catch((errors) => { handleErrors(errors, { setErrors }); @@ -302,10 +306,22 @@ function BillForm({ orderingIndex([...formik.values.entries, defaultBill]), ); }; + + const handleBillNumberChanged = useCallback((billNumber) => { + changePageSubtitle(billNumber); + }, []); + + // Clear page subtitle once unmount bill form page. + useEffect(() => () => { + changePageSubtitle(''); + }, [changePageSubtitle]); + return (
- + { + onBillNumberChanged && onBillNumberChanged(event.currentTarget.value); + }; + return (
@@ -166,6 +171,7 @@ function BillFormHeader({ intent={errors.bill_number && touched.bill_number && Intent.DANGER} minimal={true} {...getFieldProps('bill_number')} + onBlur={handleBillNumberBlur} /> diff --git a/client/src/containers/Purchases/Bill/withBills.js b/client/src/containers/Purchases/Bill/withBills.js index b3c4729f1..94bebc7e2 100644 --- a/client/src/containers/Purchases/Bill/withBills.js +++ b/client/src/containers/Purchases/Bill/withBills.js @@ -5,8 +5,7 @@ import { getBillPaginationMetaFactory, getBillTableQueryFactory, getVendorPayableBillsFactory, - getPayableBillsByPaymentMadeFactory, - getPaymentMadeFormPayableBillsFactory + getVendorPayableBillsEntriesFactory, } from 'store/Bills/bills.selectors'; export default (mapState) => { @@ -14,8 +13,7 @@ export default (mapState) => { const getBillsPaginationMeta = getBillPaginationMetaFactory(); const getBillTableQuery = getBillTableQueryFactory(); const getVendorPayableBills = getVendorPayableBillsFactory(); - const getPayableBillsByPaymentMade = getPayableBillsByPaymentMadeFactory(); - const getPaymentMadeFormPayableBills = getPaymentMadeFormPayableBillsFactory(); + const getVendorPayableBillsEntries = getVendorPayableBillsEntriesFactory(); const mapStateToProps = (state, props) => { const tableQuery = getBillTableQuery(state, props); @@ -29,9 +27,8 @@ export default (mapState) => { billsPageination: getBillsPaginationMeta(state, props, tableQuery), billsLoading: state.bills.loading, nextBillNumberChanged: state.bills.nextBillNumberChanged, - - // vendorPayableBills: getVendorPayableBills(state, props), - paymentMadePayableBills: getPaymentMadeFormPayableBills(state, props), + vendorPayableBills: getVendorPayableBills(state, props), + vendorPayableBillsEntries: getVendorPayableBillsEntries(state, props), }; return mapState ? mapState(mapped, state, props) : mapped; }; diff --git a/client/src/containers/Purchases/PaymentMades/PaymentMade.js b/client/src/containers/Purchases/PaymentMades/PaymentMade.js index 7eee9a8fb..6afad957b 100644 --- a/client/src/containers/Purchases/PaymentMades/PaymentMade.js +++ b/client/src/containers/Purchases/PaymentMades/PaymentMade.js @@ -83,6 +83,7 @@ function PaymentMade({ > ); diff --git a/client/src/containers/Purchases/PaymentMades/PaymentMadeFooter.js b/client/src/containers/Purchases/PaymentMades/PaymentMadeFooter.js new file mode 100644 index 000000000..d91bd7606 --- /dev/null +++ b/client/src/containers/Purchases/PaymentMades/PaymentMadeFooter.js @@ -0,0 +1,32 @@ +import React from 'react'; +import classNames from 'classnames'; +import { FormGroup, TextArea } from '@blueprintjs/core'; +import { FormattedMessage as T } from 'react-intl'; +import { Row, Col } from 'components'; +import { CLASSES } from 'common/classes'; + +/** + * Payment made form footer. + */ +export default function PaymentMadeFooter({ + getFieldProps +}) { + return ( +
+ + + {/* --------- Statement --------- */} + } + className={'form-group--statement'} + > +