Date: Sun, 22 Nov 2020 15:42:18 +0200
Subject: [PATCH 7/9] Fix: Add prepend and money field group to customer &
vendors
---
.../Customers/CustomerFinancialPanel.js | 51 ++++++++++---------
.../src/containers/Customers/CustomerForm.js | 8 +++
.../Vendors/VendorFinanicalPanelTab.js | 40 ++++++++++-----
client/src/containers/Vendors/VendorForm.js | 8 +++
4 files changed, 69 insertions(+), 38 deletions(-)
diff --git a/client/src/containers/Customers/CustomerFinancialPanel.js b/client/src/containers/Customers/CustomerFinancialPanel.js
index c8a0d39c8..295479938 100644
--- a/client/src/containers/Customers/CustomerFinancialPanel.js
+++ b/client/src/containers/Customers/CustomerFinancialPanel.js
@@ -1,9 +1,15 @@
import React, { useCallback, useState } from 'react';
import classNames from 'classnames';
-import { FormGroup, Position, Classes } from '@blueprintjs/core';
+import { FormGroup, Position, Classes, ControlGroup } from '@blueprintjs/core';
import { DateInput } from '@blueprintjs/datetime';
import { FastField, ErrorMessage } from 'formik';
-import { MoneyInputGroup, CurrencySelectList, Row, Col } from 'components';
+import {
+ MoneyInputGroup,
+ InputPrependText,
+ CurrencySelectList,
+ Row,
+ Col,
+} from 'components';
import { FormattedMessage as T } from 'react-intl';
import withCurrencies from 'containers/Currencies/withCurrencies';
@@ -21,20 +27,7 @@ function CustomerFinancialPanel({
customerId,
}) {
- const [selectedItems, setSelectedItems] = useState();
- const onItemsSelect = useCallback(
- (filedName) => {
- return (filed) => {
- setSelectedItems({
- ...selectedItems,
- [filedName]: filed,
- });
- // setFieldValue(filedName, filed.currency_code);
- };
- },
- [selectedItems],
- );
return (
@@ -52,7 +45,6 @@ function CustomerFinancialPanel({
@@ -62,7 +54,12 @@ function CustomerFinancialPanel({
{/*------------ Opening balance -----------*/}
- {({ field, field: { value }, meta: { error, touched } }) => (
+ {({
+ form: { values },
+ field,
+ field: { value },
+ meta: { error, touched },
+ }) => (
}
className={classNames(
@@ -72,13 +69,15 @@ function CustomerFinancialPanel({
intent={inputIntent({ error, touched })}
inline={true}
>
-
+
+
+
+
)}
@@ -98,7 +97,9 @@ function CustomerFinancialPanel({
{
+ form.setFieldValue('currency_code', currency.currency_code);
+ }}
disabled={customerId}
/>
diff --git a/client/src/containers/Customers/CustomerForm.js b/client/src/containers/Customers/CustomerForm.js
index 8c0d5ac62..ffbddf34e 100644
--- a/client/src/containers/Customers/CustomerForm.js
+++ b/client/src/containers/Customers/CustomerForm.js
@@ -20,6 +20,7 @@ import withCustomerDetail from 'containers/Customers/withCustomerDetail';
import withCustomersActions from 'containers/Customers/withCustomersActions';
import withMediaActions from 'containers/Media/withMediaActions';
import withCustomers from 'containers/Customers//withCustomers';
+import withSettings from 'containers/Settings/withSettings';
import useMedia from 'hooks/useMedia';
import { compose, transformToForm } from 'utils';
@@ -73,6 +74,9 @@ function CustomerForm({
// #withCustomerDetail
customer,
+ // #withSettings
+ baseCurrency,
+
// #withCustomersActions
requestSubmitCustomer,
requestEditCustomer,
@@ -151,6 +155,7 @@ function CustomerForm({
const initialValues = useMemo(
() => ({
...defaultInitialValues,
+ currency_code: baseCurrency,
...transformToForm(customer, defaultInitialValues),
}),
[customer, defaultInitialValues],
@@ -271,6 +276,9 @@ export default compose(
withCustomers(({ customers }) => ({
customers,
})),
+ withSettings(({ organizationSettings }) => ({
+ baseCurrency: organizationSettings?.baseCurrency,
+ })),
withDashboardActions,
withCustomersActions,
withMediaActions,
diff --git a/client/src/containers/Vendors/VendorFinanicalPanelTab.js b/client/src/containers/Vendors/VendorFinanicalPanelTab.js
index d4b15ef79..86929939e 100644
--- a/client/src/containers/Vendors/VendorFinanicalPanelTab.js
+++ b/client/src/containers/Vendors/VendorFinanicalPanelTab.js
@@ -1,9 +1,15 @@
import React from 'react';
import classNames from 'classnames';
-import { FormGroup, Position, Classes } from '@blueprintjs/core';
+import { FormGroup, ControlGroup, Position, Classes } from '@blueprintjs/core';
import { DateInput } from '@blueprintjs/datetime';
import { FastField, ErrorMessage } from 'formik';
-import { MoneyInputGroup, CurrencySelectList, Row, Col } from 'components';
+import {
+ MoneyInputGroup,
+ InputPrependText,
+ CurrencySelectList,
+ Row,
+ Col,
+} from 'components';
import { FormattedMessage as T } from 'react-intl';
import withCurrencies from 'containers/Currencies/withCurrencies';
@@ -50,7 +56,12 @@ function VendorFinanicalPanelTab({
{/*------------ Opening balance -----------*/}
- {({ field, field: { value }, meta: { error, touched } }) => (
+ {({
+ form: { values },
+ field,
+ field: { value },
+ meta: { error, touched },
+ }) => (
}
className={classNames(
@@ -60,16 +71,19 @@ function VendorFinanicalPanelTab({
intent={inputIntent({ error, touched })}
inline={true}
>
-
+
+
+
+
)}
diff --git a/client/src/containers/Vendors/VendorForm.js b/client/src/containers/Vendors/VendorForm.js
index 923c28a89..23b760735 100644
--- a/client/src/containers/Vendors/VendorForm.js
+++ b/client/src/containers/Vendors/VendorForm.js
@@ -22,6 +22,7 @@ import VendorFloatingActions from './VendorFloatingActions';
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withVendorDetail from './withVendorDetail';
import withVendorActions from './withVendorActions';
+import withSettings from 'containers/Settings/withSettings';
import { compose, transformToForm } from 'utils';
@@ -73,6 +74,9 @@ function VendorForm({
requestSubmitVendor,
requestEditVendor,
+ // #withSettings
+ baseCurrency,
+
// #OwnProps
vendorId,
}) {
@@ -88,6 +92,7 @@ function VendorForm({
const initialValues = useMemo(
() => ({
...defaultInitialValues,
+ currency_code: baseCurrency,
...transformToForm(vendor, defaultInitialValues),
}),
[defaultInitialValues],
@@ -181,5 +186,8 @@ function VendorForm({
export default compose(
withVendorDetail(),
withDashboardActions,
+ withSettings(({ organizationSettings }) => ({
+ baseCurrency: organizationSettings?.baseCurrency,
+ })),
withVendorActions,
)(VendorForm);
From bd3c539f9e5fca4ab0588939ce4bc283dde242c4 Mon Sep 17 00:00:00 2001
From: elforjani3
Date: Sun, 22 Nov 2020 15:44:01 +0200
Subject: [PATCH 8/9] Fix: initial numeric values.
---
client/src/containers/Sales/Estimate/EstimateForm.js | 6 +++---
client/src/containers/Sales/Invoice/InvoiceForm.js | 6 +++---
.../containers/Sales/PaymentReceive/PaymentReceiveForm.js | 8 ++++----
client/src/containers/Sales/Receipt/ReceiptForm.js | 6 +++---
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/client/src/containers/Sales/Estimate/EstimateForm.js b/client/src/containers/Sales/Estimate/EstimateForm.js
index 5beaaeb8c..ba1f06a67 100644
--- a/client/src/containers/Sales/Estimate/EstimateForm.js
+++ b/client/src/containers/Sales/Estimate/EstimateForm.js
@@ -37,10 +37,10 @@ const MIN_LINES_NUMBER = 4;
const defaultEstimate = {
index: 0,
- item_id: null,
- rate: null,
+ item_id: '',
+ rate: '',
discount: 0,
- quantity: null,
+ quantity: '',
description: '',
};
diff --git a/client/src/containers/Sales/Invoice/InvoiceForm.js b/client/src/containers/Sales/Invoice/InvoiceForm.js
index dbafc74ac..9da290b8e 100644
--- a/client/src/containers/Sales/Invoice/InvoiceForm.js
+++ b/client/src/containers/Sales/Invoice/InvoiceForm.js
@@ -37,10 +37,10 @@ const MIN_LINES_NUMBER = 4;
const defaultInvoice = {
index: 0,
- item_id: null,
- rate: null,
+ item_id: '',
+ rate: '',
discount: 0,
- quantity: null,
+ quantity: '',
description: '',
};
diff --git a/client/src/containers/Sales/PaymentReceive/PaymentReceiveForm.js b/client/src/containers/Sales/PaymentReceive/PaymentReceiveForm.js
index bd9e3e71f..dcc4e21be 100644
--- a/client/src/containers/Sales/PaymentReceive/PaymentReceiveForm.js
+++ b/client/src/containers/Sales/PaymentReceive/PaymentReceiveForm.js
@@ -106,10 +106,10 @@ function PaymentReceiveForm({
// Default payment receive entry.
const defaultPaymentReceiveEntry = {
- id: null,
- payment_amount: null,
- invoice_id: null,
- due_amount: null,
+ id: '',
+ payment_amount: '',
+ invoice_id: '',
+ due_amount: '',
};
// Form initial values.
diff --git a/client/src/containers/Sales/Receipt/ReceiptForm.js b/client/src/containers/Sales/Receipt/ReceiptForm.js
index 23462955f..bf13f2b35 100644
--- a/client/src/containers/Sales/Receipt/ReceiptForm.js
+++ b/client/src/containers/Sales/Receipt/ReceiptForm.js
@@ -38,10 +38,10 @@ const MIN_LINES_NUMBER = 4;
const defaultReceipt = {
index: 0,
- item_id: null,
- rate: null,
+ item_id: '',
+ rate: '',
discount: 0,
- quantity: null,
+ quantity: '',
description: '',
};
From 70f4b656d8ee8026892039e113b830222792295d Mon Sep 17 00:00:00 2001
From: elforjani3
Date: Sun, 22 Nov 2020 17:16:06 +0200
Subject: [PATCH 9/9] Fix: Shipping Address in CustomerAddresaTabs.
---
client/src/containers/Customers/CustomerAddressTabs.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/src/containers/Customers/CustomerAddressTabs.js b/client/src/containers/Customers/CustomerAddressTabs.js
index 63f3824ed..6b2da9fce 100644
--- a/client/src/containers/Customers/CustomerAddressTabs.js
+++ b/client/src/containers/Customers/CustomerAddressTabs.js
@@ -159,7 +159,7 @@ const CustomerBillingAddress = ({}) => {
inline={true}
helperText={}
>
-
+
)}