2022-04-14 09:22:45 +00:00
|
|
|
import { LedgerPosting } from 'accounting/ledgerPosting';
|
2022-04-18 11:29:20 +00:00
|
|
|
import { Frappe } from 'frappe';
|
2022-04-14 09:22:45 +00:00
|
|
|
import { Action, ListViewSettings } from 'frappe/model/types';
|
|
|
|
import {
|
|
|
|
getTransactionActions,
|
|
|
|
getTransactionStatusColumn,
|
|
|
|
} from '../../helpers';
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
this.frappe
|
|
|
|
);
|
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-18 11:29:20 +00:00
|
|
|
static getActions(frappe: Frappe): Action[] {
|
|
|
|
return getTransactionActions('SalesInvoice', frappe);
|
|
|
|
}
|
2022-04-14 09:22:45 +00:00
|
|
|
|
2022-04-18 11:29:20 +00:00
|
|
|
static getListViewSettings(frappe: Frappe): ListViewSettings {
|
|
|
|
return {
|
|
|
|
formRoute: (name) => `/edit/SalesInvoice/${name}`,
|
|
|
|
columns: [
|
|
|
|
'party',
|
|
|
|
'name',
|
|
|
|
getTransactionStatusColumn(frappe),
|
|
|
|
'date',
|
|
|
|
'grandTotal',
|
|
|
|
'outstandingAmount',
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
2022-04-14 09:22:45 +00:00
|
|
|
}
|