2022-04-19 05:59:36 +00:00
|
|
|
import Doc from 'fyo/model/doc';
|
|
|
|
import { FiltersMap, FormulaMap } from 'fyo/model/types';
|
2022-04-11 09:41:49 +00:00
|
|
|
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 05:59:36 +00:00
|
|
|
return this.fyo.pesa(0);
|
2022-04-11 09:41:49 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static filters: FiltersMap = {
|
|
|
|
referenceName: () => ({
|
|
|
|
outstandingAmount: ['>', 0],
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
}
|