2023-08-22 06:48:51 +00:00
|
|
|
import { Doc } from 'fyo/model/doc';
|
|
|
|
import { OpeningAmounts } from './OpeningAmounts';
|
|
|
|
import { OpeningCash } from './OpeningCash';
|
2024-12-24 16:47:40 +00:00
|
|
|
import { ListViewSettings } from 'fyo/model/types';
|
2023-08-22 06:48:51 +00:00
|
|
|
|
2024-12-24 16:47:40 +00:00
|
|
|
export class POSOpeningShift extends Doc {
|
2023-08-22 06:48:51 +00:00
|
|
|
openingAmounts?: OpeningAmounts[];
|
|
|
|
openingCash?: OpeningCash[];
|
2023-09-05 12:09:24 +00:00
|
|
|
openingDate?: Date;
|
2024-12-30 05:34:56 +00:00
|
|
|
closingShift?: string;
|
2023-08-22 06:48:51 +00:00
|
|
|
|
|
|
|
get openingCashAmount() {
|
|
|
|
if (!this.openingCash) {
|
|
|
|
return this.fyo.pesa(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
let openingAmount = this.fyo.pesa(0);
|
|
|
|
|
|
|
|
this.openingCash.map((row: OpeningCash) => {
|
|
|
|
const denomination = row.denomination ?? this.fyo.pesa(0);
|
|
|
|
const count = row.count ?? 0;
|
|
|
|
|
|
|
|
const amount = denomination.mul(count);
|
|
|
|
openingAmount = openingAmount.add(amount);
|
|
|
|
});
|
|
|
|
return openingAmount;
|
|
|
|
}
|
|
|
|
|
|
|
|
get openingTransferAmount() {
|
|
|
|
if (!this.openingAmounts) {
|
|
|
|
return this.fyo.pesa(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
const transferAmountRow = this.openingAmounts.filter(
|
|
|
|
(row) => row.paymentMethod === 'Transfer'
|
|
|
|
)[0];
|
|
|
|
|
|
|
|
return transferAmountRow.amount ?? this.fyo.pesa(0);
|
|
|
|
}
|
2024-12-24 16:47:40 +00:00
|
|
|
|
|
|
|
static getListViewSettings(): ListViewSettings {
|
|
|
|
return {
|
|
|
|
columns: ['name', 'openingDate'],
|
|
|
|
};
|
|
|
|
}
|
2023-08-22 06:48:51 +00:00
|
|
|
}
|