mirror of
https://github.com/frappe/books.git
synced 2024-11-13 00:46:28 +00:00
76bf6cfda5
- update models to not use singleton export
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import { LedgerPosting } from 'accounting/ledgerPosting';
|
|
import { Frappe } from 'frappe';
|
|
import { Action, ListViewSettings } from 'frappe/model/types';
|
|
import {
|
|
getTransactionActions,
|
|
getTransactionStatusColumn,
|
|
} from '../../helpers';
|
|
import { Invoice } from '../Invoice/Invoice';
|
|
import { PurchaseInvoiceItem } from '../PurchaseInvoiceItem/PurchaseInvoiceItem';
|
|
|
|
export class PurchaseInvoice extends Invoice {
|
|
items?: PurchaseInvoiceItem[];
|
|
|
|
async getPosting() {
|
|
const entries: LedgerPosting = new LedgerPosting(
|
|
{
|
|
reference: this,
|
|
party: this.party,
|
|
},
|
|
this.frappe
|
|
);
|
|
|
|
await entries.credit(this.account!, this.baseGrandTotal!);
|
|
|
|
for (const item of this.items!) {
|
|
await entries.debit(item.account!, item.baseAmount!);
|
|
}
|
|
|
|
if (this.taxes) {
|
|
for (const tax of this.taxes) {
|
|
await entries.debit(tax.account!, tax.baseAmount!);
|
|
}
|
|
}
|
|
|
|
entries.makeRoundOffEntry();
|
|
return entries;
|
|
}
|
|
|
|
static getActions(frappe: Frappe): Action[] {
|
|
return getTransactionActions('PurchaseInvoice', frappe);
|
|
}
|
|
|
|
static getListViewSettings(frappe: Frappe): ListViewSettings {
|
|
return {
|
|
formRoute: (name) => `/edit/PurchaseInvoice/${name}`,
|
|
columns: [
|
|
'party',
|
|
'name',
|
|
getTransactionStatusColumn(frappe),
|
|
'date',
|
|
'grandTotal',
|
|
'outstandingAmount',
|
|
],
|
|
};
|
|
}
|
|
}
|