mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
48e9f1b668
- make address a manually named entry type - make a few more entry types searchable - fix dropdown filter undefined issue - reset settings docs if not saved - fix ux dropdown toggle on click
54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import { Doc } from 'fyo/model/doc';
|
|
import { ListViewSettings } from 'fyo/model/types';
|
|
import { ModelNameEnum } from 'models/types';
|
|
import { Money } from 'pesa';
|
|
|
|
export class AccountingLedgerEntry extends Doc {
|
|
date?: string | Date;
|
|
account?: string;
|
|
party?: string;
|
|
debit?: Money;
|
|
credit?: Money;
|
|
referenceType?: string;
|
|
referenceName?: string;
|
|
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: [
|
|
'date',
|
|
'account',
|
|
'party',
|
|
'debit',
|
|
'credit',
|
|
'referenceName',
|
|
],
|
|
};
|
|
}
|
|
}
|