mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat: integrate Stripe payment to invoices
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Model } from 'objection';
|
||||
import TenantModel from 'models/TenantModel';
|
||||
|
||||
export class PaymentIntegration extends Model {
|
||||
export class PaymentIntegration extends TenantModel {
|
||||
static get tableName() {
|
||||
return 'payment_integrations';
|
||||
}
|
||||
@@ -12,7 +13,7 @@ export class PaymentIntegration extends Model {
|
||||
static get jsonSchema() {
|
||||
return {
|
||||
type: 'object',
|
||||
required: ['service', 'enable'],
|
||||
required: ['name', 'service', 'enable'],
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
service: { type: 'string' },
|
||||
|
||||
@@ -414,8 +414,8 @@ export default class SaleInvoice extends mixin(TenantModel, [
|
||||
const Document = require('models/Document');
|
||||
const { MatchedBankTransaction } = require('models/MatchedBankTransaction');
|
||||
const {
|
||||
TransactionPaymentService,
|
||||
} = require('models/TransactionPaymentService');
|
||||
TransactionPaymentServiceEntry,
|
||||
} = require('models/TransactionPaymentServiceEntry');
|
||||
|
||||
return {
|
||||
/**
|
||||
@@ -577,14 +577,17 @@ export default class SaleInvoice extends mixin(TenantModel, [
|
||||
},
|
||||
|
||||
/**
|
||||
* Sale invoice may belongs to payment methods.
|
||||
* Sale invoice may belongs to payment methods entries.
|
||||
*/
|
||||
paymentMethods: {
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: TransactionPaymentService,
|
||||
modelClass: TransactionPaymentServiceEntry,
|
||||
join: {
|
||||
from: 'sales_invoices.id',
|
||||
to: 'transactions_payment_services.referenceId',
|
||||
to: 'transactions_payment_methods.referenceId',
|
||||
},
|
||||
beforeInsert: (model) => {
|
||||
model.referenceType = 'SaleInvoice';
|
||||
},
|
||||
filter: (query) => {
|
||||
query.where('reference_type', 'SaleInvoice');
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
import { Model, mixin } from 'objection';
|
||||
import TenantModel from 'models/TenantModel';
|
||||
|
||||
export class TransactionPaymentService extends TenantModel {
|
||||
export class TransactionPaymentServiceEntry extends TenantModel {
|
||||
/**
|
||||
* Table name
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'transactions_payment_services';
|
||||
return 'transactions_payment_methods';
|
||||
}
|
||||
|
||||
/**
|
||||
* Json schema of the model.
|
||||
*/
|
||||
static get jsonSchema() {
|
||||
return {
|
||||
type: 'object',
|
||||
required: ['service', 'enable'],
|
||||
required: ['paymentIntegrationId'],
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
reference_id: { type: 'integer' },
|
||||
reference_type: { type: 'string' },
|
||||
service: { type: 'string' },
|
||||
referenceId: { type: 'integer' },
|
||||
referenceType: { type: 'string' },
|
||||
paymentIntegrationId: { type: 'integer' },
|
||||
enable: { type: 'boolean' },
|
||||
options: { type: 'object' },
|
||||
},
|
||||
Reference in New Issue
Block a user