feat: compute items cost of inventory adjustments transcations.

This commit is contained in:
a.bouhuolia
2021-01-10 17:41:32 +02:00
parent 097b9fdb3a
commit 8491d44118
20 changed files with 433 additions and 180 deletions

View File

@@ -17,6 +17,34 @@ export default class AccountTransaction extends TenantModel {
return ['createdAt'];
}
static get virtualAttributes() {
return ['referenceTypeFormatted'];
}
/**
* Retrieve formatted reference type.
* @return {string}
*/
get referenceTypeFormatted() {
return AccountTransaction.getReferenceTypeFormatted(this.referenceType);
}
/**
* Reference type formatted.
*/
static getReferenceTypeFormatted(referenceType) {
const mapped = {
'SaleInvoice': 'Sale invoice',
'SaleReceipt': 'Sale receipt',
'PaymentReceive': 'Payment receive',
'BillPayment': 'Payment made',
'VendorOpeningBalance': 'Vendor opening balance',
'CustomerOpeningBalance': 'Customer opening balance',
'InventoryAdjustment': 'Inventory adjustment'
};
return mapped[referenceType] || '';
}
/**
* Model modifiers.
*/

View File

@@ -16,6 +16,28 @@ export default class InventoryAdjustment extends TenantModel {
return ['created_at'];
}
/**
* Virtual attributes.
*/
static get virtualAttributes() {
return ['inventoryDirection'];
}
/**
* Retrieve formatted reference type.
*/
get inventoryDirection() {
return InventoryAdjustment.getInventoryDirection(this.type);
}
static getInventoryDirection(type) {
const directions = {
'increment': 'IN',
'decrement': 'OUT',
};
return directions[type] || '';
}
/**
* Relationship mapping.
*/