2022-04-24 06:48:44 +00:00
|
|
|
import { Doc } from 'fyo/model/doc';
|
2022-04-19 05:59:36 +00:00
|
|
|
import { ListViewSettings } from 'fyo/model/types';
|
2022-05-03 13:13:47 +00:00
|
|
|
import { ModelNameEnum } from 'models/types';
|
2022-05-23 05:30:54 +00:00
|
|
|
import { Money } from 'pesa';
|
2022-04-11 09:41:49 +00:00
|
|
|
|
|
|
|
export class AccountingLedgerEntry extends Doc {
|
2022-05-03 13:13:47 +00:00
|
|
|
date?: string | Date;
|
|
|
|
account?: string;
|
|
|
|
party?: string;
|
|
|
|
debit?: Money;
|
|
|
|
credit?: Money;
|
|
|
|
referenceType?: string;
|
|
|
|
referenceName?: string;
|
|
|
|
balance?: Money;
|
|
|
|
reverted?: boolean;
|
|
|
|
|
|
|
|
async revert() {
|
|
|
|
if (this.reverted) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.set('reverted', true);
|
|
|
|
const revertedEntry = this.fyo.doc.getNewDoc(
|
|
|
|
ModelNameEnum.AccountingLedgerEntry,
|
|
|
|
{
|
|
|
|
account: this.account,
|
|
|
|
party: this.party,
|
|
|
|
date: new Date(),
|
|
|
|
referenceType: this.referenceType,
|
|
|
|
referenceName: this.referenceName,
|
|
|
|
debit: this.credit,
|
|
|
|
credit: this.debit,
|
|
|
|
reverted: true,
|
|
|
|
reverts: this.name,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
await this.sync();
|
|
|
|
await revertedEntry.sync();
|
|
|
|
}
|
|
|
|
|
2022-04-18 11:29:20 +00:00
|
|
|
static getListViewSettings(): ListViewSettings {
|
|
|
|
return {
|
2022-05-04 08:19:40 +00:00
|
|
|
columns: [
|
|
|
|
'account',
|
|
|
|
'party',
|
|
|
|
'debit',
|
|
|
|
'credit',
|
|
|
|
'balance',
|
|
|
|
'referenceName',
|
|
|
|
'reverted',
|
|
|
|
],
|
2022-04-18 11:29:20 +00:00
|
|
|
};
|
|
|
|
}
|
2022-04-11 09:41:49 +00:00
|
|
|
}
|