mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
fix: the currency code of transaction tax rate entry
This commit is contained in:
@@ -284,8 +284,12 @@ export const useComposeRowsOnRemoveTableRow = () => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the aggregate tax rates from the given item entries.
|
* Retrieves the aggregate tax rates from the given item entries.
|
||||||
|
* @param {string} currencyCode -
|
||||||
|
* @param {any} taxRates -
|
||||||
|
* @param {any} entries -
|
||||||
*/
|
*/
|
||||||
export const aggregateItemEntriesTaxRates = R.curry((taxRates, entries) => {
|
export const aggregateItemEntriesTaxRates = R.curry(
|
||||||
|
(currencyCode, taxRates, entries) => {
|
||||||
const taxRatesById = keyBy(taxRates, 'id');
|
const taxRatesById = keyBy(taxRates, 'id');
|
||||||
|
|
||||||
// Calculate the total tax amount of invoice entries.
|
// Calculate the total tax amount of invoice entries.
|
||||||
@@ -296,7 +300,7 @@ export const aggregateItemEntriesTaxRates = R.curry((taxRates, entries) => {
|
|||||||
const taxRate = taxRatesById[taxRateId];
|
const taxRate = taxRatesById[taxRateId];
|
||||||
const taxRates = groupedTaxRates[taxRateId];
|
const taxRates = groupedTaxRates[taxRateId];
|
||||||
const totalTaxAmount = sumBy(taxRates, 'tax_amount');
|
const totalTaxAmount = sumBy(taxRates, 'tax_amount');
|
||||||
const taxAmountFormatted = formattedAmount(totalTaxAmount, 'USD');
|
const taxAmountFormatted = formattedAmount(totalTaxAmount, currencyCode);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
taxRateId,
|
taxRateId,
|
||||||
@@ -306,4 +310,5 @@ export const aggregateItemEntriesTaxRates = R.curry((taxRates, entries) => {
|
|||||||
taxAmountFormatted,
|
taxAmountFormatted,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|||||||
@@ -322,8 +322,8 @@ export const useBillAggregatedTaxRates = () => {
|
|||||||
const { taxRates } = useBillFormContext();
|
const { taxRates } = useBillFormContext();
|
||||||
|
|
||||||
const aggregateTaxRates = React.useMemo(
|
const aggregateTaxRates = React.useMemo(
|
||||||
() => aggregateItemEntriesTaxRates(taxRates),
|
() => aggregateItemEntriesTaxRates(values.currency_code, taxRates),
|
||||||
[taxRates],
|
[values.currency_code, taxRates],
|
||||||
);
|
);
|
||||||
// Calculate the total tax amount of bill entries.
|
// Calculate the total tax amount of bill entries.
|
||||||
return React.useMemo(() => {
|
return React.useMemo(() => {
|
||||||
|
|||||||
@@ -333,8 +333,8 @@ export const useInvoiceAggregatedTaxRates = () => {
|
|||||||
const { taxRates } = useInvoiceFormContext();
|
const { taxRates } = useInvoiceFormContext();
|
||||||
|
|
||||||
const aggregateTaxRates = React.useMemo(
|
const aggregateTaxRates = React.useMemo(
|
||||||
() => aggregateItemEntriesTaxRates(taxRates),
|
() => aggregateItemEntriesTaxRates(values.currency_code, taxRates),
|
||||||
[taxRates],
|
[values.currency_code, taxRates],
|
||||||
);
|
);
|
||||||
// Calculate the total tax amount of invoice entries.
|
// Calculate the total tax amount of invoice entries.
|
||||||
return React.useMemo(() => {
|
return React.useMemo(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user