mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
- feat: remove unnecessary migrations, controllers and models files.
- feat: metable store - feat: metable store with settings store. - feat: settings middleware to auto-save and load. - feat: DI db manager to master container. - feat: write some logs to sale invoices.
This commit is contained in:
@@ -27,6 +27,9 @@ export default class PaymentReceiveService {
|
||||
@Inject()
|
||||
journalService: JournalPosterService;
|
||||
|
||||
@Inject('logger')
|
||||
logger: any;
|
||||
|
||||
/**
|
||||
* Creates a new payment receive and store it to the storage
|
||||
* with associated invoices payment and journal transactions.
|
||||
@@ -43,6 +46,8 @@ export default class PaymentReceiveService {
|
||||
} = this.tenancy.models(tenantId);
|
||||
|
||||
const paymentAmount = sumBy(paymentReceive.entries, 'payment_amount');
|
||||
|
||||
this.logger.info('[payment_receive] inserting to the storage.');
|
||||
const storedPaymentReceive = await PaymentReceive.query()
|
||||
.insert({
|
||||
amount: paymentAmount,
|
||||
@@ -50,12 +55,15 @@ export default class PaymentReceiveService {
|
||||
});
|
||||
const storeOpers: Array<any> = [];
|
||||
|
||||
this.logger.info('[payment_receive] inserting associated entries to the storage.');
|
||||
paymentReceive.entries.forEach((entry: any) => {
|
||||
const oper = PaymentReceiveEntry.query()
|
||||
.insert({
|
||||
payment_receive_id: storedPaymentReceive.id,
|
||||
...entry,
|
||||
});
|
||||
|
||||
this.logger.info('[payment_receive] increment the sale invoice payment amount.');
|
||||
// Increment the invoice payment amount.
|
||||
const invoice = SaleInvoice.query()
|
||||
.where('id', entry.invoice_id)
|
||||
@@ -64,6 +72,8 @@ export default class PaymentReceiveService {
|
||||
storeOpers.push(oper);
|
||||
storeOpers.push(invoice);
|
||||
});
|
||||
|
||||
this.logger.info('[payment_receive] decrementing customer balance.');
|
||||
const customerIncrementOper = Customer.decrementBalance(
|
||||
paymentReceive.customer_id,
|
||||
paymentAmount,
|
||||
|
||||
Reference in New Issue
Block a user