2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

incr: update tax summmary

This commit is contained in:
18alantom 2022-10-03 13:48:02 +05:30
parent cd09d31b9b
commit 6ee1365e45
4 changed files with 43 additions and 3 deletions

View File

@ -47,7 +47,7 @@ export class PurchaseInvoice extends Invoice {
getTransactionStatusColumn(),
'party',
'date',
'grandTotal',
'baseGrandTotal',
'outstandingAmount',
],
};

View File

@ -47,7 +47,7 @@ export class SalesInvoice extends Invoice {
getTransactionStatusColumn(),
'party',
'date',
'grandTotal',
'baseGrandTotal',
'outstandingAmount',
],
};

View File

@ -1,8 +1,48 @@
import { Fyo } from 'fyo';
import { DocValueMap } from 'fyo/core/types';
import { Doc } from 'fyo/model/doc';
import { CurrenciesMap } from 'fyo/model/types';
import { DEFAULT_CURRENCY } from 'fyo/utils/consts';
import { Money } from 'pesa';
import { FieldTypeEnum, Schema } from 'schemas/types';
import { Invoice } from '../Invoice/Invoice';
export class TaxSummary extends Doc {
account?: string;
rate?: number;
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;
}
}
}

View File

@ -69,7 +69,7 @@
},
{
"fieldname": "baseGrandTotal",
"label": "Grand Total (Company Currency)",
"label": "Base Grand Total",
"fieldtype": "Currency",
"readOnly": true
},