mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: compute items cost of inventory adjustments transcations.
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user