mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-26 09:39:49 +00:00
Add withDateSessionMixin for proper timestamp handling and fix models to return empty timestamps array when database tables don't have created_at/updated_at columns. This prevents ORM insert/update errors. Models updated: - Branch, Role, RolePermission, ViewColumn, ViewRole - InventoryAdjustment, InventoryAdjustmentEntry, InventoryTransactionMeta - BillLandedCostEntry, CreditNote, CreditNoteAppliedInvoice, RefundCreditNote - PaymentReceived, SaleInvoice, SaleReceipt, Item, ItemEntry - RefundVendorCredit, VendorCreditAppliedBill - ItemWarehouseQuantity, Warehouse, WarehouseTransfer, WarehouseTransferEntry - Setting, TenantMetadataModel, TenantUser Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
1.3 KiB
TypeScript
61 lines
1.3 KiB
TypeScript
import { Model } from 'objection';
|
|
import { BaseModel } from '@/models/Model';
|
|
import { Item } from '@/modules/Items/models/Item';
|
|
// import TenantModel from 'models/TenantModel';
|
|
|
|
export class InventoryAdjustmentEntry extends BaseModel {
|
|
adjustmentId!: number;
|
|
index!: number;
|
|
itemId!: number;
|
|
quantity!: number;
|
|
cost!: number;
|
|
value!: number;
|
|
|
|
item!: Item;
|
|
|
|
/**
|
|
* Table name.
|
|
*/
|
|
static get tableName() {
|
|
return 'inventory_adjustments_entries';
|
|
}
|
|
|
|
/**
|
|
* Timestamps columns.
|
|
*/
|
|
get timestamps() {
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Relationship mapping.
|
|
*/
|
|
static get relationMappings() {
|
|
const { InventoryAdjustment } = require('./InventoryAdjustment');
|
|
const { Item } = require('../../Items/models/Item');
|
|
|
|
return {
|
|
inventoryAdjustment: {
|
|
relation: Model.BelongsToOneRelation,
|
|
modelClass: InventoryAdjustment,
|
|
join: {
|
|
from: 'inventory_adjustments_entries.adjustmentId',
|
|
to: 'inventory_adjustments.id',
|
|
},
|
|
},
|
|
|
|
/**
|
|
* Entry item.
|
|
*/
|
|
item: {
|
|
relation: Model.BelongsToOneRelation,
|
|
modelClass: Item,
|
|
join: {
|
|
from: 'inventory_adjustments_entries.itemId',
|
|
to: 'items.id',
|
|
},
|
|
},
|
|
};
|
|
}
|
|
}
|