mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
Merge branch 'currencyCode'
This commit is contained in:
@@ -34,6 +34,7 @@ function EstimateForm({
|
||||
estimateNextNumber,
|
||||
estimateNumberPrefix,
|
||||
estimateIncrementMode,
|
||||
baseCurrency,
|
||||
}) {
|
||||
const { formatMessage } = useIntl();
|
||||
const history = useHistory();
|
||||
@@ -57,10 +58,11 @@ function EstimateForm({
|
||||
? { ...transformToEditForm(estimate) }
|
||||
: {
|
||||
...defaultEstimate,
|
||||
...(estimateIncrementMode) && ({
|
||||
...(estimateIncrementMode && {
|
||||
estimate_number: estimateNumber,
|
||||
}),
|
||||
entries: orderingLinesIndexes(defaultEstimate.entries),
|
||||
currency_code: baseCurrency,
|
||||
}),
|
||||
}),
|
||||
[estimate, estimateNumber, estimateIncrementMode],
|
||||
@@ -101,7 +103,7 @@ function EstimateForm({
|
||||
}
|
||||
const form = {
|
||||
...omit(values, ['estimate_number_manually', 'estimate_number']),
|
||||
...(values.estimate_number_manually) && ({
|
||||
...(values.estimate_number_manually && {
|
||||
estimate_number: values.estimate_number,
|
||||
}),
|
||||
delivered: submitPayload.deliver,
|
||||
@@ -175,9 +177,10 @@ function EstimateForm({
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withSettings(({ estimatesSettings }) => ({
|
||||
withSettings(({ estimatesSettings, organizationSettings }) => ({
|
||||
estimateNextNumber: estimatesSettings?.nextNumber,
|
||||
estimateNumberPrefix: estimatesSettings?.numberPrefix,
|
||||
estimateIncrementMode: estimatesSettings?.autoIncrement,
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
)(EstimateForm);
|
||||
|
||||
@@ -14,15 +14,20 @@ export default function EstimateFormItemsEntriesField() {
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
||||
<FastField name={'entries'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field: { value },
|
||||
meta: { error, touched },
|
||||
}) => (
|
||||
<ItemsEntriesTable
|
||||
entries={value}
|
||||
onUpdateData={(entries) => {
|
||||
form.setFieldValue('entries', entries);
|
||||
setFieldValue('entries', entries);
|
||||
}}
|
||||
items={items}
|
||||
errors={error}
|
||||
linesNumber={4}
|
||||
currencyCode={values.currency_code}
|
||||
/>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
@@ -34,6 +34,7 @@ function InvoiceForm({
|
||||
invoiceNextNumber,
|
||||
invoiceNumberPrefix,
|
||||
invoiceIncrementMode,
|
||||
baseCurrency,
|
||||
}) {
|
||||
const { formatMessage } = useIntl();
|
||||
const history = useHistory();
|
||||
@@ -61,11 +62,12 @@ function InvoiceForm({
|
||||
? transformToEditForm(invoice)
|
||||
: {
|
||||
...defaultInvoice,
|
||||
...(invoiceIncrementMode) && ({
|
||||
...(invoiceIncrementMode && {
|
||||
invoice_no: invoiceNumber,
|
||||
}),
|
||||
entries: orderingLinesIndexes(defaultInvoice.entries),
|
||||
...newInvoice,
|
||||
currency_code: baseCurrency,
|
||||
}),
|
||||
}),
|
||||
[invoice, newInvoice, invoiceNumber, invoiceIncrementMode],
|
||||
@@ -91,7 +93,7 @@ function InvoiceForm({
|
||||
}
|
||||
const form = {
|
||||
...omit(values, ['invoice_no', 'invoice_no_manually']),
|
||||
...(values.invoice_no_manually) && ({
|
||||
...(values.invoice_no_manually && {
|
||||
invoice_no: values.invoice_no,
|
||||
}),
|
||||
delivered: submitPayload.deliver,
|
||||
@@ -169,9 +171,10 @@ function InvoiceForm({
|
||||
export default compose(
|
||||
withDashboardActions,
|
||||
withMediaActions,
|
||||
withSettings(({ invoiceSettings }) => ({
|
||||
withSettings(({ invoiceSettings, organizationSettings }) => ({
|
||||
invoiceNextNumber: invoiceSettings?.nextNumber,
|
||||
invoiceNumberPrefix: invoiceSettings?.numberPrefix,
|
||||
invoiceIncrementMode: invoiceSettings?.incrementMode,
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
)(InvoiceForm);
|
||||
|
||||
@@ -14,15 +14,20 @@ export default function InvoiceItemsEntriesEditorField() {
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
||||
<FastField name={'entries'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field: { value },
|
||||
meta: { error, touched },
|
||||
}) => (
|
||||
<ItemsEntriesTable
|
||||
entries={value}
|
||||
onUpdateData={(entries) => {
|
||||
form.setFieldValue('entries', entries);
|
||||
setFieldValue('entries', entries);
|
||||
}}
|
||||
items={items}
|
||||
errors={error}
|
||||
linesNumber={4}
|
||||
currencyCode={values.currency_code}
|
||||
/>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
@@ -37,6 +37,7 @@ function PaymentReceiveForm({
|
||||
paymentReceiveNextNumber,
|
||||
paymentReceiveNumberPrefix,
|
||||
paymentReceiveAutoIncrement,
|
||||
baseCurrency,
|
||||
}) {
|
||||
const history = useHistory();
|
||||
const { formatMessage } = useIntl();
|
||||
@@ -68,6 +69,7 @@ function PaymentReceiveForm({
|
||||
payment_receive_no: nextPaymentNumber,
|
||||
deposit_account_id: defaultTo(preferredDepositAccount, ''),
|
||||
}),
|
||||
currency_code: baseCurrency,
|
||||
}),
|
||||
}),
|
||||
[
|
||||
@@ -199,11 +201,12 @@ function PaymentReceiveForm({
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withSettings(({ paymentReceiveSettings }) => ({
|
||||
withSettings(({ paymentReceiveSettings, organizationSettings }) => ({
|
||||
paymentReceiveSettings,
|
||||
paymentReceiveNextNumber: paymentReceiveSettings?.nextNumber,
|
||||
paymentReceiveNumberPrefix: paymentReceiveSettings?.numberPrefix,
|
||||
paymentReceiveAutoIncrement: paymentReceiveSettings?.autoIncrement,
|
||||
preferredDepositAccount: paymentReceiveSettings?.depositAccount,
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
)(PaymentReceiveForm);
|
||||
|
||||
@@ -11,12 +11,13 @@ export default function PaymentReceiveFormBody() {
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
||||
<FastField name={'entries'}>
|
||||
{({ form, field: { value } }) => (
|
||||
{({ form: { values, setFieldValue }, field: { value } }) => (
|
||||
<PaymentReceiveItemsTable
|
||||
entries={value}
|
||||
onUpdateData={(newEntries) => {
|
||||
form.setFieldValue('entries', newEntries);
|
||||
setFieldValue('entries', newEntries);
|
||||
}}
|
||||
currencyCode={values.currency_code}
|
||||
/>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
@@ -15,6 +15,7 @@ import { compose, updateTableRow } from 'utils';
|
||||
export default function PaymentReceiveItemsTable({
|
||||
entries,
|
||||
onUpdateData,
|
||||
currencyCode
|
||||
}) {
|
||||
// Payment receive form context.
|
||||
const {
|
||||
@@ -52,6 +53,7 @@ export default function PaymentReceiveItemsTable({
|
||||
payload={{
|
||||
errors: [],
|
||||
updateData: handleUpdateData,
|
||||
currencyCode
|
||||
}}
|
||||
noResults={noResultsMessage}
|
||||
footer={true}
|
||||
|
||||
@@ -9,14 +9,14 @@ import { safeSumBy, formattedAmount } from 'utils';
|
||||
* Invoice date cell.
|
||||
*/
|
||||
function InvoiceDateCell({ value }) {
|
||||
return <span>{ moment(value).format('YYYY MMM DD') }</span>
|
||||
return <span>{moment(value).format('YYYY MMM DD')}</span>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index table cell.
|
||||
*/
|
||||
function IndexCell({ row: { index } }) {
|
||||
return (<span>{index + 1}</span>);
|
||||
return <span>{index + 1}</span>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,33 +29,32 @@ function InvNumberCellAccessor(row) {
|
||||
/**
|
||||
* Balance footer cell.
|
||||
*/
|
||||
function BalanceFooterCell({ rows }) {
|
||||
function BalanceFooterCell({ payload: { currencyCode }, rows }) {
|
||||
const total = safeSumBy(rows, 'original.amount');
|
||||
return <span>{ formattedAmount(total, 'USD') }</span>;
|
||||
return <span>{formattedAmount(total, currencyCode)}</span>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Due amount footer cell.
|
||||
*/
|
||||
function DueAmountFooterCell({ rows }) {
|
||||
function DueAmountFooterCell({ payload: { currencyCode }, rows }) {
|
||||
const totalDueAmount = safeSumBy(rows, 'original.due_amount');
|
||||
return <span>{ formattedAmount(totalDueAmount, 'USD') }</span>;
|
||||
return <span>{formattedAmount(totalDueAmount, currencyCode)}</span>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment amount footer cell.
|
||||
*/
|
||||
function PaymentAmountFooterCell({ rows }) {
|
||||
function PaymentAmountFooterCell({ payload: { currencyCode }, rows }) {
|
||||
const totalPaymentAmount = safeSumBy(rows, 'original.payment_amount');
|
||||
return <span>{ formattedAmount(totalPaymentAmount, 'USD') }</span>;
|
||||
return <span>{formattedAmount(totalPaymentAmount, currencyCode)}</span>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mobey table cell.
|
||||
*/
|
||||
function MoneyTableCell({ value }) {
|
||||
return <Money amount={value} currency={"USD"} />
|
||||
function MoneyTableCell({ row: { original }, value }) {
|
||||
return <Money amount={value} currency={original.currency_code} />;
|
||||
}
|
||||
|
||||
function DateFooterCell() {
|
||||
@@ -77,7 +76,7 @@ export const usePaymentReceiveEntriesColumns = () => {
|
||||
width: 40,
|
||||
disableResizing: true,
|
||||
disableSortBy: true,
|
||||
className: 'index'
|
||||
className: 'index',
|
||||
},
|
||||
{
|
||||
Header: formatMessage({ id: 'Date' }),
|
||||
@@ -88,7 +87,7 @@ export const usePaymentReceiveEntriesColumns = () => {
|
||||
disableSortBy: true,
|
||||
disableResizing: true,
|
||||
width: 250,
|
||||
className: 'date'
|
||||
className: 'date',
|
||||
},
|
||||
{
|
||||
Header: formatMessage({ id: 'invocie_number' }),
|
||||
@@ -125,5 +124,5 @@ export const usePaymentReceiveEntriesColumns = () => {
|
||||
},
|
||||
],
|
||||
[formatMessage],
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -50,6 +50,7 @@ export const transformInvoicesNewPageEntries = (invoices) => [
|
||||
due_amount: invoice.due_amount,
|
||||
date: invoice.invoice_date,
|
||||
amount: invoice.balance,
|
||||
currency_code:invoice.currency_code,
|
||||
payment_amount: '',
|
||||
invoice_no: invoice.invoice_no,
|
||||
total_payment_amount: invoice.payment_amount,
|
||||
|
||||
@@ -37,6 +37,7 @@ function ReceiptForm({
|
||||
receiptNumberPrefix,
|
||||
receiptAutoIncrement,
|
||||
preferredDepositAccount,
|
||||
baseCurrency,
|
||||
}) {
|
||||
const { formatMessage } = useIntl();
|
||||
const history = useHistory();
|
||||
@@ -67,6 +68,7 @@ function ReceiptForm({
|
||||
}),
|
||||
deposit_account_id: parseInt(preferredDepositAccount),
|
||||
entries: orderingLinesIndexes(defaultReceipt.entries),
|
||||
currency_code: baseCurrency,
|
||||
}),
|
||||
}),
|
||||
[receipt, preferredDepositAccount, nextReceiptNumber, receiptAutoIncrement],
|
||||
@@ -105,8 +107,9 @@ function ReceiptForm({
|
||||
}
|
||||
const form = {
|
||||
...omit(values, ['receipt_number_manually', 'receipt_number']),
|
||||
...(values.receipt_number_manually) && ({
|
||||
...(values.receipt_number_manually && {
|
||||
receipt_number: values.receipt_number,
|
||||
currency_code: baseCurrency,
|
||||
}),
|
||||
closed: submitPayload.status,
|
||||
entries: entries.map((entry) => ({ ...omit(entry, ['total']) })),
|
||||
@@ -182,10 +185,11 @@ function ReceiptForm({
|
||||
|
||||
export default compose(
|
||||
withDashboardActions,
|
||||
withSettings(({ receiptSettings }) => ({
|
||||
withSettings(({ receiptSettings, organizationSettings }) => ({
|
||||
receiptNextNumber: receiptSettings?.nextNumber,
|
||||
receiptNumberPrefix: receiptSettings?.numberPrefix,
|
||||
receiptAutoIncrement: receiptSettings?.autoIncrement,
|
||||
preferredDepositAccount: receiptSettings?.preferredDepositAccount,
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
)(ReceiptForm);
|
||||
|
||||
@@ -11,15 +11,20 @@ export default function ReceiptItemsEntriesEditor({ defaultReceipt }) {
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
||||
<FastField name={'entries'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field: { value },
|
||||
meta: { error, touched },
|
||||
}) => (
|
||||
<ItemsEntriesTable
|
||||
entries={value}
|
||||
onUpdateData={(entries) => {
|
||||
form.setFieldValue('entries', entries);
|
||||
setFieldValue('entries', entries);
|
||||
}}
|
||||
items={items}
|
||||
errors={error}
|
||||
linesNumber={4}
|
||||
currencyCode={values.currency_code}
|
||||
/>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
Reference in New Issue
Block a user