mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
fix: issues in inventory adjustments service.
This commit is contained in:
@@ -9,21 +9,44 @@ export default class InventoryAdjustment extends TenantModel {
|
||||
return 'inventory_adjustments';
|
||||
}
|
||||
|
||||
/**
|
||||
* Timestamps columns.
|
||||
*/
|
||||
get timestamps() {
|
||||
return ['created_at'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship mapping.
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const Account = require('models/InventoryAdjustmentEntry');
|
||||
|
||||
const InventoryAdjustmentEntry = require('models/InventoryAdjustmentEntry');
|
||||
const Account = require('models/Account');
|
||||
|
||||
return {
|
||||
/**
|
||||
* Adjustment entries.
|
||||
*/
|
||||
entries: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: Account.default,
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: InventoryAdjustmentEntry.default,
|
||||
join: {
|
||||
from: 'inventory_adjustments.id',
|
||||
to: 'inventory_adjustments_entries.adjustmentId',
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Inventory adjustment account.
|
||||
*/
|
||||
adjustmentAccount: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: Account.default,
|
||||
join: {
|
||||
from: 'inventory_adjustments.adjustmentAccountId',
|
||||
to: 'accounts.id',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import TenantModel from 'models/TenantModel';
|
||||
|
||||
export default class InventoryAdjustmentEntry extends TenantModel {
|
||||
/**
|
||||
* Table name
|
||||
* Table name.
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'inventory_adjustments_entries';
|
||||
@@ -13,17 +13,30 @@ export default class InventoryAdjustmentEntry extends TenantModel {
|
||||
* Relationship mapping.
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const Account = require('models/InventoryAdjustment');
|
||||
|
||||
const InventoryAdjustment = require('models/InventoryAdjustment');
|
||||
const Item = require('models/Item');
|
||||
|
||||
return {
|
||||
entries: {
|
||||
inventoryAdjustment: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: Account.default,
|
||||
modelClass: InventoryAdjustment.default,
|
||||
join: {
|
||||
from: 'inventory_adjustments_entries.adjustmentId',
|
||||
to: 'inventory_adjustments.id',
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Entry item.
|
||||
*/
|
||||
item: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: Item.default,
|
||||
join: {
|
||||
from: 'inventory_adjustments_entries.itemId',
|
||||
to: 'items.id',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user