mirror of
https://github.com/frappe/books.git
synced 2025-01-24 23:58:27 +00:00
9877bf4fd3
- allow nulls in converter else not not null'll fail
28 lines
643 B
TypeScript
28 lines
643 B
TypeScript
import { Doc } from 'fyo/model/doc';
|
|
import { FiltersMap, FormulaMap } from 'fyo/model/types';
|
|
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;
|
|
}
|
|
|
|
return this.fyo.pesa(0);
|
|
},
|
|
};
|
|
|
|
static filters: FiltersMap = {
|
|
referenceName: () => ({
|
|
outstandingAmount: ['>', 0],
|
|
}),
|
|
};
|
|
}
|