mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-27 10:09:48 +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>
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import { Model, mixin } from 'objection';
|
|
// import TenantModel from 'models/TenantModel';
|
|
// import ModelSetting from './ModelSetting';
|
|
// import CustomViewBaseModel from './CustomViewBaseModel';
|
|
// import ModelSearchable from './ModelSearchable';
|
|
import { BaseModel } from '@/models/Model';
|
|
import { CreditNote } from '@/modules/CreditNotes/models/CreditNote';
|
|
|
|
export class RefundCreditNote extends BaseModel {
|
|
date: Date;
|
|
referenceNo: string;
|
|
amount: number;
|
|
currencyCode: string;
|
|
exchangeRate: number;
|
|
fromAccountId: number;
|
|
description: string;
|
|
creditNoteId: number;
|
|
|
|
userId?: number;
|
|
branchId?: number;
|
|
|
|
createdAt?: Date | null;
|
|
|
|
creditNote!: CreditNote;
|
|
|
|
/**
|
|
* Table name.
|
|
*/
|
|
static get tableName() {
|
|
return 'refund_credit_note_transactions';
|
|
}
|
|
|
|
/**
|
|
* Timestamps columns.
|
|
*/
|
|
get timestamps() {
|
|
return ['createdAt', 'updatedAt'];
|
|
}
|
|
|
|
/**
|
|
* Relationship mapping.
|
|
*/
|
|
static get relationMappings() {
|
|
const { Account } = require('../../Accounts/models/Account.model');
|
|
const { CreditNote } = require('../../CreditNotes/models/CreditNote');
|
|
|
|
return {
|
|
fromAccount: {
|
|
relation: Model.BelongsToOneRelation,
|
|
modelClass: Account,
|
|
join: {
|
|
from: 'refund_credit_note_transactions.fromAccountId',
|
|
to: 'accounts.id',
|
|
},
|
|
},
|
|
creditNote: {
|
|
relation: Model.BelongsToOneRelation,
|
|
modelClass: CreditNote,
|
|
join: {
|
|
from: 'refund_credit_note_transactions.creditNoteId',
|
|
to: 'credit_notes.id',
|
|
},
|
|
},
|
|
};
|
|
}
|
|
}
|