mirror of
https://github.com/frappe/books.git
synced 2025-01-08 17:24:05 +00:00
incr: update tax summmary
This commit is contained in:
parent
cd09d31b9b
commit
6ee1365e45
@ -47,7 +47,7 @@ export class PurchaseInvoice extends Invoice {
|
|||||||
getTransactionStatusColumn(),
|
getTransactionStatusColumn(),
|
||||||
'party',
|
'party',
|
||||||
'date',
|
'date',
|
||||||
'grandTotal',
|
'baseGrandTotal',
|
||||||
'outstandingAmount',
|
'outstandingAmount',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@ -47,7 +47,7 @@ export class SalesInvoice extends Invoice {
|
|||||||
getTransactionStatusColumn(),
|
getTransactionStatusColumn(),
|
||||||
'party',
|
'party',
|
||||||
'date',
|
'date',
|
||||||
'grandTotal',
|
'baseGrandTotal',
|
||||||
'outstandingAmount',
|
'outstandingAmount',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,48 @@
|
|||||||
|
import { Fyo } from 'fyo';
|
||||||
|
import { DocValueMap } from 'fyo/core/types';
|
||||||
import { Doc } from 'fyo/model/doc';
|
import { Doc } from 'fyo/model/doc';
|
||||||
|
import { CurrenciesMap } from 'fyo/model/types';
|
||||||
|
import { DEFAULT_CURRENCY } from 'fyo/utils/consts';
|
||||||
import { Money } from 'pesa';
|
import { Money } from 'pesa';
|
||||||
|
import { FieldTypeEnum, Schema } from 'schemas/types';
|
||||||
|
import { Invoice } from '../Invoice/Invoice';
|
||||||
|
|
||||||
export class TaxSummary extends Doc {
|
export class TaxSummary extends Doc {
|
||||||
account?: string;
|
account?: string;
|
||||||
rate?: number;
|
rate?: number;
|
||||||
amount?: Money;
|
amount?: Money;
|
||||||
|
parentdoc?: Invoice;
|
||||||
|
|
||||||
|
get exchangeRate() {
|
||||||
|
return this.parentdoc?.exchangeRate ?? 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
get currency() {
|
||||||
|
return this.parentdoc?.currency ?? DEFAULT_CURRENCY;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(schema: Schema, data: DocValueMap, fyo: Fyo) {
|
||||||
|
super(schema, data, fyo);
|
||||||
|
this._setGetCurrencies();
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrencies: CurrenciesMap = {};
|
||||||
|
_getCurrency() {
|
||||||
|
if (this.exchangeRate === 1) {
|
||||||
|
return this.fyo.singles.SystemSettings?.currency ?? DEFAULT_CURRENCY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.currency;
|
||||||
|
}
|
||||||
|
_setGetCurrencies() {
|
||||||
|
const currencyFields = this.schema.fields.filter(
|
||||||
|
({ fieldtype }) => fieldtype === FieldTypeEnum.Currency
|
||||||
|
);
|
||||||
|
|
||||||
|
const getCurrency = this._getCurrency.bind(this);
|
||||||
|
|
||||||
|
for (const { fieldname } of currencyFields) {
|
||||||
|
this.getCurrencies[fieldname] ??= getCurrency;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "baseGrandTotal",
|
"fieldname": "baseGrandTotal",
|
||||||
"label": "Grand Total (Company Currency)",
|
"label": "Base Grand Total",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"readOnly": true
|
"readOnly": true
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user