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

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

53 lines
1.4 KiB
TypeScript
Raw Normal View History

import { Fyo } from 'fyo';
import { Action, ListViewSettings } from 'fyo/model/types';
import { LedgerPosting } from 'models/ledgerPosting/ledgerPosting';
import { ModelNameEnum } from 'models/types';
import { getInvoiceActions, getTransactionStatusColumn } from '../../helpers';
import { Invoice } from '../Invoice/Invoice';
import { SalesInvoiceItem } from '../SalesInvoiceItem/SalesInvoiceItem';
export class SalesInvoice extends Invoice {
items?: SalesInvoiceItem[];
async getPosting() {
const entries: LedgerPosting = new LedgerPosting(
{
reference: this,
party: this.party,
},
this.fyo
);
await entries.debit(this.account!, this.baseGrandTotal!);
for (const item of this.items!) {
await entries.credit(item.account!, item.baseAmount!);
}
if (this.taxes) {
for (const tax of this.taxes!) {
await entries.credit(tax.account!, tax.baseAmount!);
}
}
entries.makeRoundOffEntry();
return entries;
}
static getActions(fyo: Fyo): Action[] {
return getInvoiceActions(ModelNameEnum.SalesInvoice, fyo);
}
static getListViewSettings(): ListViewSettings {
return {
formRoute: (name) => `/edit/SalesInvoice/${name}`,
columns: [
'party',
'name',
getTransactionStatusColumn(),
'date',
'grandTotal',
'outstandingAmount',
],
};
}
}