mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
fix(Journals): sync posting datetime with jorunal entries.
This commit is contained in:
@@ -112,12 +112,10 @@ export default class AccountTransaction extends TenantModel {
|
||||
filterContactIds(query, contactIds) {
|
||||
query.whereIn('contact_id', contactIds);
|
||||
},
|
||||
|
||||
openingBalance(query, fromDate) {
|
||||
query.modify('filterDateRange', null, fromDate)
|
||||
query.modify('sumationCreditDebit')
|
||||
},
|
||||
|
||||
closingBalance(query, toDate) {
|
||||
query.modify('filterDateRange', null, toDate)
|
||||
query.modify('sumationCreditDebit')
|
||||
|
||||
@@ -11,8 +11,10 @@ export default (Model) => {
|
||||
const maybePromise = super.$beforeUpdate(opt, context);
|
||||
|
||||
return Promise.resolve(maybePromise).then(() => {
|
||||
if (this.timestamps[1]) {
|
||||
this[this.timestamps[1]] = moment().format('YYYY/MM/DD HH:mm:ss');
|
||||
const key = this.timestamps[1];
|
||||
|
||||
if (key && !this[key]) {
|
||||
this[key] = moment().format('YYYY/MM/DD HH:mm:ss');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -21,8 +23,10 @@ export default (Model) => {
|
||||
const maybePromise = super.$beforeInsert(context);
|
||||
|
||||
return Promise.resolve(maybePromise).then(() => {
|
||||
if (this.timestamps[0]) {
|
||||
this[this.timestamps[0]] = moment().format('YYYY/MM/DD HH:mm:ss');
|
||||
const key = this.timestamps[0];
|
||||
|
||||
if (key && !this[key]) {
|
||||
this[key] = moment().format('YYYY/MM/DD HH:mm:ss');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class InventoryCostLotTracker extends TenantModel {
|
||||
*/
|
||||
static get modifiers() {
|
||||
return {
|
||||
groupedEntriesCost(query) {
|
||||
groupedEntriesCost(query) {
|
||||
query.select(['date', 'item_id', 'transaction_id', 'transaction_type']);
|
||||
query.sum('cost as cost');
|
||||
|
||||
@@ -46,12 +46,13 @@ export default class InventoryCostLotTracker extends TenantModel {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Relationship mapping.
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const Item = require('models/Item');
|
||||
const SaleInvoice = require('models/SaleInvoice');
|
||||
const ItemEntry = require('models/ItemEntry');
|
||||
|
||||
return {
|
||||
item: {
|
||||
@@ -62,6 +63,25 @@ export default class InventoryCostLotTracker extends TenantModel {
|
||||
to: 'items.id',
|
||||
},
|
||||
},
|
||||
invoice: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: SaleInvoice.default,
|
||||
join: {
|
||||
from: 'inventory_cost_lot_tracker.transactionId',
|
||||
to: 'sales_invoices.id',
|
||||
},
|
||||
filter(query) {
|
||||
query.where('transaction_type', 'SaleInvoice');
|
||||
},
|
||||
},
|
||||
itemEntry: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: ItemEntry.default,
|
||||
join: {
|
||||
from: 'inventory_cost_lot_tracker.entryId',
|
||||
to: 'items_entries.id',
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ export default class InventoryTransaction extends TenantModel {
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const Item = require('models/Item');
|
||||
const ItemEntry = require('models/ItemEntry');
|
||||
|
||||
return {
|
||||
item: {
|
||||
@@ -52,6 +53,14 @@ export default class InventoryTransaction extends TenantModel {
|
||||
to: 'items.id',
|
||||
},
|
||||
},
|
||||
itemEntry: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: ItemEntry.default,
|
||||
join: {
|
||||
from: 'inventory_transactions.entryId',
|
||||
to: 'items_entries.id',
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user