2023-08-22 06:48:51 +00:00
|
|
|
import { Doc } from 'fyo/model/doc';
|
|
|
|
import { FormulaMap } from 'fyo/model/types';
|
|
|
|
import { Money } from 'pesa';
|
|
|
|
|
|
|
|
export class ClosingAmounts extends Doc {
|
|
|
|
closingAmount?: Money;
|
|
|
|
differenceAmount?: Money;
|
2023-08-22 12:56:21 +00:00
|
|
|
expectedAmount?: Money;
|
|
|
|
openingAmount?: Money;
|
|
|
|
paymentMethod?: string;
|
2023-08-22 06:48:51 +00:00
|
|
|
|
|
|
|
formulas: FormulaMap = {
|
|
|
|
differenceAmount: {
|
|
|
|
formula: () => {
|
|
|
|
if (!this.closingAmount) {
|
|
|
|
return this.fyo.pesa(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.expectedAmount) {
|
|
|
|
return this.fyo.pesa(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.closingAmount.sub(this.expectedAmount);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|