2022-04-19 05:59:36 +00:00
|
|
|
import { Fyo } from 'fyo';
|
|
|
|
import { Action, ListViewSettings } from 'fyo/model/types';
|
2022-04-28 12:37:07 +00:00
|
|
|
import { LedgerPosting } from 'models/ledgerPosting/ledgerPosting';
|
2022-05-02 15:17:14 +00:00
|
|
|
import { ModelNameEnum } from 'models/types';
|
|
|
|
import { getInvoiceActions, getTransactionStatusColumn } from '../../helpers';
|
2022-04-14 09:22:45 +00:00
|
|
|
import { Invoice } from '../Invoice/Invoice';
|
|
|
|
import { SalesInvoiceItem } from '../SalesInvoiceItem/SalesInvoiceItem';
|
|
|
|
|
|
|
|
export class SalesInvoice extends Invoice {
|
|
|
|
items?: SalesInvoiceItem[];
|
|
|
|
|
|
|
|
async getPosting() {
|
2022-04-18 11:29:20 +00:00
|
|
|
const entries: LedgerPosting = new LedgerPosting(
|
|
|
|
{
|
|
|
|
reference: this,
|
|
|
|
party: this.party,
|
|
|
|
},
|
2022-04-19 05:59:36 +00:00
|
|
|
this.fyo
|
2022-04-18 11:29:20 +00:00
|
|
|
);
|
2022-04-14 09:22:45 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-04-19 05:59:36 +00:00
|
|
|
static getActions(fyo: Fyo): Action[] {
|
2022-05-02 15:17:14 +00:00
|
|
|
return getInvoiceActions(ModelNameEnum.SalesInvoice, fyo);
|
2022-04-18 11:29:20 +00:00
|
|
|
}
|
2022-04-14 09:22:45 +00:00
|
|
|
|
2022-04-28 12:37:07 +00:00
|
|
|
static getListViewSettings(): ListViewSettings {
|
2022-04-18 11:29:20 +00:00
|
|
|
return {
|
|
|
|
formRoute: (name) => `/edit/SalesInvoice/${name}`,
|
|
|
|
columns: [
|
|
|
|
'party',
|
|
|
|
'name',
|
2022-04-28 12:37:07 +00:00
|
|
|
getTransactionStatusColumn(),
|
2022-04-18 11:29:20 +00:00
|
|
|
'date',
|
|
|
|
'grandTotal',
|
|
|
|
'outstandingAmount',
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
2022-04-14 09:22:45 +00:00
|
|
|
}
|