mirror of
https://github.com/frappe/books.git
synced 2024-11-10 15:50:56 +00:00
20ea214a4b
- add deletion - fix reversion
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { Fyo } from 'fyo';
|
|
import { Action, ListViewSettings } from 'fyo/model/types';
|
|
import { LedgerPosting } from 'models/Transactional/LedgerPosting';
|
|
import { ModelNameEnum } from 'models/types';
|
|
import { getInvoiceActions, getTransactionStatusColumn } from '../../helpers';
|
|
import { Invoice } from '../Invoice/Invoice';
|
|
import { PurchaseInvoiceItem } from '../PurchaseInvoiceItem/PurchaseInvoiceItem';
|
|
|
|
export class PurchaseInvoice extends Invoice {
|
|
items?: PurchaseInvoiceItem[];
|
|
|
|
async getPosting() {
|
|
const posting: LedgerPosting = new LedgerPosting(this, this.fyo);
|
|
|
|
await posting.credit(this.account!, this.baseGrandTotal!);
|
|
|
|
for (const item of this.items!) {
|
|
await posting.debit(item.account!, item.baseAmount!);
|
|
}
|
|
|
|
if (this.taxes) {
|
|
for (const tax of this.taxes) {
|
|
await posting.debit(tax.account!, tax.baseAmount!);
|
|
}
|
|
}
|
|
|
|
await posting.makeRoundOffEntry();
|
|
return posting;
|
|
}
|
|
|
|
static getActions(fyo: Fyo): Action[] {
|
|
return getInvoiceActions(ModelNameEnum.PurchaseInvoice, fyo);
|
|
}
|
|
|
|
static getListViewSettings(): ListViewSettings {
|
|
return {
|
|
formRoute: (name) => `/edit/PurchaseInvoice/${name}`,
|
|
columns: [
|
|
'party',
|
|
'name',
|
|
getTransactionStatusColumn(),
|
|
'date',
|
|
'grandTotal',
|
|
'outstandingAmount',
|
|
],
|
|
};
|
|
}
|
|
}
|