mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
feat( S&P ): Add currency code in conversion to invoice & credit.
This commit is contained in:
@@ -74,8 +74,8 @@ function VendorCreditNoteForm({
|
|||||||
...(vendorcreditAutoIncrement && {
|
...(vendorcreditAutoIncrement && {
|
||||||
vendor_credit_number: vendorCreditNumber,
|
vendor_credit_number: vendorCreditNumber,
|
||||||
}),
|
}),
|
||||||
...newVendorCredit,
|
|
||||||
currency_code: base_currency,
|
currency_code: base_currency,
|
||||||
|
...newVendorCredit,
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
[vendorCredit, base_currency],
|
[vendorCredit, base_currency],
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ function VendorCreditNoteFormProvider({
|
|||||||
|
|
||||||
const newVendorCredit = !isEmpty(bill)
|
const newVendorCredit = !isEmpty(bill)
|
||||||
? transformToEditForm({
|
? transformToEditForm({
|
||||||
...pick(bill, ['vendor_id', 'entries']),
|
...pick(bill, ['vendor_id', 'currency_code', 'entries']),
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ function CreditNoteFormProvider({ creditNoteId, baseCurrency, ...props }) {
|
|||||||
|
|
||||||
const newCreditNote = !isEmpty(invoice)
|
const newCreditNote = !isEmpty(invoice)
|
||||||
? transformToEditForm({
|
? transformToEditForm({
|
||||||
...pick(invoice, ['customer_id', 'entries']),
|
...pick(invoice, ['customer_id', 'currency_code', 'entries']),
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ function InvoiceForm({
|
|||||||
invoice_no: invoiceNumber,
|
invoice_no: invoiceNumber,
|
||||||
}),
|
}),
|
||||||
entries: orderingLinesIndexes(defaultInvoice.entries),
|
entries: orderingLinesIndexes(defaultInvoice.entries),
|
||||||
...newInvoice,
|
|
||||||
currency_code: base_currency,
|
currency_code: base_currency,
|
||||||
|
...newInvoice,
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
[invoice, newInvoice, invoiceNumber, invoiceIncrementMode, base_currency],
|
[invoice, newInvoice, invoiceNumber, invoiceIncrementMode, base_currency],
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import styled from 'styled-components';
|
|||||||
import {
|
import {
|
||||||
useObserveInvoiceNoSettings,
|
useObserveInvoiceNoSettings,
|
||||||
customerNameFieldShouldUpdate,
|
customerNameFieldShouldUpdate,
|
||||||
|
useSetForeignCurrencyToEditForm,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import {
|
import {
|
||||||
@@ -84,6 +85,8 @@ function InvoiceFormHeaderFields({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useSetForeignCurrencyToEditForm();
|
||||||
|
|
||||||
// Syncs invoice number settings with form.
|
// Syncs invoice number settings with form.
|
||||||
useObserveInvoiceNoSettings(invoiceNumberPrefix, invoiceNextNumber);
|
useObserveInvoiceNoSettings(invoiceNumberPrefix, invoiceNextNumber);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
|||||||
|
|
||||||
const newInvoice = !isEmpty(estimate)
|
const newInvoice = !isEmpty(estimate)
|
||||||
? transformToEditForm({
|
? transformToEditForm({
|
||||||
...pick(estimate, ['customer_id', 'customer', 'entries']),
|
...pick(estimate, ['customer_id', 'currency_code', 'entries']),
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
@@ -91,10 +91,6 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
|||||||
!isEqual(selectCustomer?.currency_code, baseCurrency) &&
|
!isEqual(selectCustomer?.currency_code, baseCurrency) &&
|
||||||
!isUndefined(selectCustomer?.currency_code);
|
!isUndefined(selectCustomer?.currency_code);
|
||||||
|
|
||||||
const currencyCode = isForeignCustomer
|
|
||||||
? selectCustomer?.currency_code
|
|
||||||
: baseCurrency;
|
|
||||||
|
|
||||||
const provider = {
|
const provider = {
|
||||||
invoice,
|
invoice,
|
||||||
items,
|
items,
|
||||||
@@ -107,7 +103,6 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
|||||||
baseCurrency,
|
baseCurrency,
|
||||||
branches,
|
branches,
|
||||||
warehouses,
|
warehouses,
|
||||||
currencyCode,
|
|
||||||
|
|
||||||
isInvoiceLoading,
|
isInvoiceLoading,
|
||||||
isItemsLoading,
|
isItemsLoading,
|
||||||
|
|||||||
@@ -200,3 +200,14 @@ export const useSetPrimaryBranchToForm = () => {
|
|||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useSetForeignCurrencyToEditForm = () => {
|
||||||
|
const { values } = useFormikContext();
|
||||||
|
const { isNewMode, setSelectCustomer } = useInvoiceFormContext();
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!isNewMode) {
|
||||||
|
setSelectCustomer({ currency_code: values.currency_code });
|
||||||
|
}
|
||||||
|
}, [isNewMode, setSelectCustomer, values]);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user