2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 03:29:00 +00:00

fix: added closingAmounts in posShift

This commit is contained in:
akshayitzme 2023-08-22 18:26:21 +05:30 committed by akshayitzme
parent 9cf3ee0626
commit b9b2f3d49e
3 changed files with 30 additions and 7 deletions

View File

@ -3,10 +3,11 @@ import { FormulaMap } from 'fyo/model/types';
import { Money } from 'pesa'; import { Money } from 'pesa';
export class ClosingAmounts extends Doc { export class ClosingAmounts extends Doc {
openingAmount?: Money;
closingAmount?: Money; closingAmount?: Money;
expectedAmount?: Money;
differenceAmount?: Money; differenceAmount?: Money;
expectedAmount?: Money;
openingAmount?: Money;
paymentMethod?: string;
formulas: FormulaMap = { formulas: FormulaMap = {
differenceAmount: { differenceAmount: {

View File

@ -5,13 +5,13 @@ import { OpeningAmounts } from './OpeningAmounts';
import { OpeningCash } from './OpeningCash'; import { OpeningCash } from './OpeningCash';
export class POSShift extends Doc { export class POSShift extends Doc {
isShiftOpen?: boolean;
openingDate?: Date;
closingDate?: Date;
openingAmounts?: OpeningAmounts[];
closingAmounts?: ClosingAmounts[]; closingAmounts?: ClosingAmounts[];
openingCash?: OpeningCash[];
closingCash?: ClosingCash[]; closingCash?: ClosingCash[];
closingDate?: Date;
isShiftOpen?: boolean;
openingAmounts?: OpeningAmounts[];
openingCash?: OpeningCash[];
openingDate?: Date;
get openingCashAmount() { get openingCashAmount() {
if (!this.openingCash) { if (!this.openingCash) {
@ -30,6 +30,23 @@ export class POSShift extends Doc {
return openingAmount; return openingAmount;
} }
get closingCashAmount() {
if (!this.closingCash) {
return this.fyo.pesa(0);
}
let closingAmount = this.fyo.pesa(0);
this.closingCash.map((row: ClosingCash) => {
const denomination = row.denomination ?? this.fyo.pesa(0);
const count = row.count ?? 0;
const amount = denomination.mul(count);
closingAmount = closingAmount.add(amount);
});
return closingAmount;
}
get openingTransferAmount() { get openingTransferAmount() {
if (!this.openingAmounts) { if (!this.openingAmounts) {
return this.fyo.pesa(0); return this.fyo.pesa(0);

View File

@ -33,6 +33,11 @@
"fieldname": "openingAmounts", "fieldname": "openingAmounts",
"fieldtype": "Table", "fieldtype": "Table",
"target": "OpeningAmounts" "target": "OpeningAmounts"
},
{
"fieldname": "closingAmounts",
"fieldtype": "Table",
"target": "ClosingAmounts"
} }
] ]
} }