2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 11:29:00 +00:00
books/models/baseModels/AccountingLedgerEntry/AccountingLedgerEntry.ts

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

56 lines
1.2 KiB
TypeScript
Raw Normal View History

import { Doc } from 'fyo/model/doc';
import { ListViewSettings } from 'fyo/model/types';
import { ModelNameEnum } from 'models/types';
2022-05-23 05:30:54 +00:00
import { Money } from 'pesa';
export class AccountingLedgerEntry extends Doc {
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();
}
static getListViewSettings(): ListViewSettings {
return {
columns: [
'account',
'party',
'debit',
'credit',
'balance',
'referenceName',
'reverted',
],
};
}
}