mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
fix: Graph fetch relations with sales & purchases models.
feat: Inventory tracker algorithm lots with FIFO or LIFO cost method.
This commit is contained in:
@@ -24,8 +24,29 @@ export default class PaymentReceive extends mixin(TenantModel, [CachableModel])
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const PaymentReceiveEntry = require('@/models/PaymentReceiveEntry');
|
||||
const AccountTransaction = require('@/models/AccountTransaction');
|
||||
const Customer = require('@/models/Customer');
|
||||
const Account = require('@/models/Account');
|
||||
|
||||
return {
|
||||
customer: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: this.relationBindKnex(Customer.default),
|
||||
join: {
|
||||
from: 'payment_receives.customerId',
|
||||
to: 'customers.id',
|
||||
},
|
||||
},
|
||||
|
||||
depositAccount: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: this.relationBindKnex(Account.default),
|
||||
join: {
|
||||
from: 'payment_receives.depositAccountId',
|
||||
to: 'accounts.id',
|
||||
},
|
||||
},
|
||||
|
||||
entries: {
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: this.relationBindKnex(PaymentReceiveEntry.default),
|
||||
@@ -34,6 +55,18 @@ export default class PaymentReceive extends mixin(TenantModel, [CachableModel])
|
||||
to: 'payment_receives_entries.paymentReceiveId',
|
||||
},
|
||||
},
|
||||
|
||||
transactions: {
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: this.relationBindKnex(AccountTransaction.default),
|
||||
join: {
|
||||
from: 'payment_receives.id',
|
||||
to: 'accounts_transactions.referenceId'
|
||||
},
|
||||
filter(builder) {
|
||||
builder.where('reference_type', 'PaymentReceive');
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user