mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat: Link transations with payment methods
This commit is contained in:
27
packages/server/src/models/PaymentIntegration.ts
Normal file
27
packages/server/src/models/PaymentIntegration.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Model } from 'objection';
|
||||
|
||||
export class PaymentIntegration extends Model {
|
||||
static get tableName() {
|
||||
return 'payment_integrations';
|
||||
}
|
||||
|
||||
static get idColumn() {
|
||||
return 'id';
|
||||
}
|
||||
|
||||
static get jsonSchema() {
|
||||
return {
|
||||
type: 'object',
|
||||
required: ['service', 'enable'],
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
service: { type: 'string' },
|
||||
enable: { type: 'boolean' },
|
||||
accountId: { type: 'string' },
|
||||
options: { type: 'object' },
|
||||
createdAt: { type: 'string', format: 'date-time' },
|
||||
updatedAt: { type: 'string', format: 'date-time' },
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -413,6 +413,9 @@ export default class SaleInvoice extends mixin(TenantModel, [
|
||||
const TaxRateTransaction = require('models/TaxRateTransaction');
|
||||
const Document = require('models/Document');
|
||||
const { MatchedBankTransaction } = require('models/MatchedBankTransaction');
|
||||
const {
|
||||
TransactionPaymentService,
|
||||
} = require('models/TransactionPaymentService');
|
||||
|
||||
return {
|
||||
/**
|
||||
@@ -509,7 +512,7 @@ export default class SaleInvoice extends mixin(TenantModel, [
|
||||
join: {
|
||||
from: 'sales_invoices.warehouseId',
|
||||
to: 'warehouses.id',
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -566,12 +569,27 @@ export default class SaleInvoice extends mixin(TenantModel, [
|
||||
modelClass: MatchedBankTransaction,
|
||||
join: {
|
||||
from: 'sales_invoices.id',
|
||||
to: "matched_bank_transactions.referenceId",
|
||||
to: 'matched_bank_transactions.referenceId',
|
||||
},
|
||||
filter(query) {
|
||||
query.where('reference_type', 'SaleInvoice');
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Sale invoice may belongs to payment methods.
|
||||
*/
|
||||
paymentMethods: {
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: TransactionPaymentService,
|
||||
join: {
|
||||
from: 'sales_invoices.id',
|
||||
to: 'transactions_payment_services.referenceId',
|
||||
},
|
||||
filter: (query) => {
|
||||
query.where('reference_type', 'SaleInvoice');
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
33
packages/server/src/models/TransactionPaymentService.ts
Normal file
33
packages/server/src/models/TransactionPaymentService.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Model, mixin } from 'objection';
|
||||
import TenantModel from 'models/TenantModel';
|
||||
|
||||
export class TransactionPaymentService extends TenantModel {
|
||||
/**
|
||||
* Table name
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'transactions_payment_services';
|
||||
}
|
||||
|
||||
static get jsonSchema() {
|
||||
return {
|
||||
type: 'object',
|
||||
required: ['service', 'enable'],
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
reference_id: { type: 'integer' },
|
||||
reference_type: { type: 'string' },
|
||||
service: { type: 'string' },
|
||||
enable: { type: 'boolean' },
|
||||
options: { type: 'object' },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship mapping.
|
||||
*/
|
||||
static get relationMappings() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user