2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00
books/models/baseModels/PaymentFor/PaymentFor.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
639 B
TypeScript
Raw Normal View History

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],
}),
};
}