2022-04-24 12:18:44 +05:30
|
|
|
import { Doc } from 'fyo/model/doc';
|
2022-04-19 11:29:36 +05:30
|
|
|
import { FiltersMap, FormulaMap } from 'fyo/model/types';
|
2022-04-11 15:11:49 +05:30
|
|
|
import Money from 'pesa/dist/types/src/money';
|
|
|
|
|
|
|
|
export class PaymentFor extends Doc {
|
|
|
|
formulas: FormulaMap = {
|
|
|
|
amount: async () => {
|
|
|
|
const outstandingAmount = this.parentdoc!.getFrom(
|
|
|
|
this.referenceType as string,
|
|
|
|
this.referenceName as string,
|
|
|
|
'outstandingAmount'
|
|
|
|
) as Money;
|
|
|
|
|
|
|
|
if (outstandingAmount) {
|
|
|
|
return outstandingAmount;
|
|
|
|
}
|
|
|
|
|
2022-04-19 11:29:36 +05:30
|
|
|
return this.fyo.pesa(0);
|
2022-04-11 15:11:49 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static filters: FiltersMap = {
|
|
|
|
referenceName: () => ({
|
|
|
|
outstandingAmount: ['>', 0],
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
}
|