mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
fix: sale invoices payment amount once invoice created, edited or deleted.
This commit is contained in:
@@ -24,7 +24,7 @@ export default class BillSubscriber {
|
||||
/**
|
||||
* Handles vendor balance increment once bill created.
|
||||
*/
|
||||
@On(events.bills.onCreated)
|
||||
@On(events.bill.onCreated)
|
||||
async handleVendorBalanceIncrement({ tenantId, billId, bill }) {
|
||||
const { vendorRepository } = this.tenancy.repositories(tenantId);
|
||||
|
||||
@@ -36,8 +36,8 @@ export default class BillSubscriber {
|
||||
/**
|
||||
* Handles writing journal entries once bill created.
|
||||
*/
|
||||
@On(events.bills.onCreated)
|
||||
@On(events.bills.onEdited)
|
||||
@On(events.bill.onCreated)
|
||||
@On(events.bill.onEdited)
|
||||
async handlerWriteJournalEntries({ tenantId, billId, bill }) {
|
||||
// Writes the journal entries for the given bill transaction.
|
||||
this.logger.info('[bill] writing bill journal entries.', { tenantId });
|
||||
@@ -47,7 +47,7 @@ export default class BillSubscriber {
|
||||
/**
|
||||
* Handles vendor balance decrement once bill deleted.
|
||||
*/
|
||||
@On(events.bills.onDeleted)
|
||||
@On(events.bill.onDeleted)
|
||||
async handleVendorBalanceDecrement({ tenantId, billId, oldBill }) {
|
||||
const { vendorRepository } = this.tenancy.repositories(tenantId);
|
||||
|
||||
@@ -59,7 +59,7 @@ export default class BillSubscriber {
|
||||
/**
|
||||
* Handles revert journal entries on bill deleted.
|
||||
*/
|
||||
@On(events.bills.onDeleted)
|
||||
@On(events.bill.onDeleted)
|
||||
async handlerDeleteJournalEntries({ tenantId, billId }) {
|
||||
// Delete associated bill journal transactions.
|
||||
this.logger.info('[bill] trying to delete journal entries.', { tenantId, billId });
|
||||
@@ -69,7 +69,7 @@ export default class BillSubscriber {
|
||||
/**
|
||||
* Handles vendor balance difference change.
|
||||
*/
|
||||
@On(events.bills.onEdited)
|
||||
@On(events.bill.onEdited)
|
||||
async handleVendorBalanceDiffChange({ tenantId, billId, oldBill, bill }) {
|
||||
const { vendorRepository } = this.tenancy.repositories(tenantId);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ export default {
|
||||
/**
|
||||
* Sales estimates service.
|
||||
*/
|
||||
saleEstimates: {
|
||||
saleEstimate: {
|
||||
onCreated: 'onSaleEstimateCreated',
|
||||
onEdited: 'onSaleEstimateEdited',
|
||||
onDeleted: 'onSaleEstimatedDeleted',
|
||||
@@ -98,7 +98,7 @@ export default {
|
||||
/**
|
||||
* Sales receipts service.
|
||||
*/
|
||||
saleReceipts: {
|
||||
saleReceipt: {
|
||||
onCreated: 'onSaleReceiptsCreated',
|
||||
onEdited: 'onSaleReceiptsEdited',
|
||||
onDeleted: 'onSaleReceiptsDeleted',
|
||||
@@ -109,17 +109,17 @@ export default {
|
||||
/**
|
||||
* Payment receipts service.
|
||||
*/
|
||||
paymentReceipts: {
|
||||
paymentReceive: {
|
||||
onCreated: 'onPaymentReceiveCreated',
|
||||
onEdited: 'onPaymentReceiveEdited',
|
||||
onDeleted: 'onPaymentReceiveDeleted',
|
||||
onPublished: 'onPaymentReceiptPublished',
|
||||
onPublished: 'onPaymentReceivePublished',
|
||||
},
|
||||
|
||||
/**
|
||||
* Bills service.
|
||||
*/
|
||||
bills: {
|
||||
bill: {
|
||||
onCreated: 'onBillCreated',
|
||||
onEdited: 'onBillEdited',
|
||||
onDeleted: 'onBillDeleted',
|
||||
@@ -130,7 +130,7 @@ export default {
|
||||
/**
|
||||
* Bill payments service.
|
||||
*/
|
||||
billPayments: {
|
||||
billPayment: {
|
||||
onCreated: 'onBillPaymentCreated',
|
||||
onEdited: 'onBillPaymentEdited',
|
||||
onDeleted: 'onBillPaymentDeleted',
|
||||
|
||||
@@ -19,7 +19,7 @@ export default class PaymentMadesSubscriber {
|
||||
/**
|
||||
* Handles bills payment amount increment once payment made created.
|
||||
*/
|
||||
@On(events.billPayments.onCreated)
|
||||
@On(events.billPayment.onCreated)
|
||||
async handleBillsIncrementPaymentAmount({ tenantId, billPayment, billPaymentId }) {
|
||||
const { Bill } = this.tenancy.models(tenantId);
|
||||
const storeOpers = [];
|
||||
@@ -43,7 +43,7 @@ export default class PaymentMadesSubscriber {
|
||||
/**
|
||||
* Handle vendor balance increment once payment made created.
|
||||
*/
|
||||
@On(events.billPayments.onCreated)
|
||||
@On(events.billPayment.onCreated)
|
||||
async handleVendorIncrement({ tenantId, billPayment, billPaymentId }) {
|
||||
const { vendorRepository } = this.tenancy.repositories(tenantId);
|
||||
|
||||
@@ -58,7 +58,7 @@ export default class PaymentMadesSubscriber {
|
||||
/**
|
||||
* Handle bill payment writing journal entries once created.
|
||||
*/
|
||||
@On(events.billPayments.onCreated)
|
||||
@On(events.billPayment.onCreated)
|
||||
async handleWriteJournalEntries({ tenantId, billPayment }) {
|
||||
// Records the journal transactions after bills payment
|
||||
// and change diff acoount balance.
|
||||
@@ -69,7 +69,7 @@ export default class PaymentMadesSubscriber {
|
||||
/**
|
||||
* Decrements the vendor balance once bill payment deleted.
|
||||
*/
|
||||
@On(events.billPayments.onDeleted)
|
||||
@On(events.billPayment.onDeleted)
|
||||
async handleVendorDecrement({ tenantId, paymentMadeId, oldPaymentMade }) {
|
||||
const { vendorRepository } = this.tenancy.repositories(tenantId);
|
||||
|
||||
@@ -82,7 +82,7 @@ export default class PaymentMadesSubscriber {
|
||||
/**
|
||||
* Reverts journal entries once bill payment deleted.
|
||||
*/
|
||||
@On(events.billPayments.onDeleted)
|
||||
@On(events.billPayment.onDeleted)
|
||||
async handleRevertJournalEntries({ tenantId, billPaymentId }) {
|
||||
await this.billPaymentsService.revertJournalEntries(
|
||||
tenantId, billPaymentId,
|
||||
@@ -93,7 +93,7 @@ export default class PaymentMadesSubscriber {
|
||||
* Change the vendor balance different between old and new once
|
||||
* bill payment edited.
|
||||
*/
|
||||
@On(events.billPayments.onEdited)
|
||||
@On(events.billPayment.onEdited)
|
||||
async handleVendorChangeDiffBalance({ tenantId, paymentMadeId, billPayment, oldBillPayment }) {
|
||||
const { vendorRepository } = this.tenancy.repositories(tenantId);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export default class PaymentReceivesSubscriber {
|
||||
/**
|
||||
* Handle customer balance decrement once payment receive created.
|
||||
*/
|
||||
@On(events.paymentReceipts.onCreated)
|
||||
@On(events.paymentReceive.onCreated)
|
||||
async handleCustomerBalanceDecrement({ tenantId, paymentReceiveId, paymentReceive }) {
|
||||
const { customerRepository } = this.tenancy.repositories(tenantId);
|
||||
|
||||
@@ -30,8 +30,8 @@ export default class PaymentReceivesSubscriber {
|
||||
/**
|
||||
* Handle sale invoice increment/decrement payment amount once created, edited or deleted.
|
||||
*/
|
||||
@On(events.paymentReceipts.onCreated)
|
||||
@On(events.paymentReceipts.onEdited)
|
||||
@On(events.paymentReceive.onCreated)
|
||||
@On(events.paymentReceive.onEdited)
|
||||
async handleInvoiceIncrementPaymentAmount({ tenantId, paymentReceiveId, paymentReceive, oldPaymentReceive }) {
|
||||
|
||||
this.logger.info('[payment_receive] trying to change sale invoice payment amount.', { tenantId });
|
||||
@@ -43,25 +43,23 @@ export default class PaymentReceivesSubscriber {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle sale invoice diff payment amount change on payment receive edited.
|
||||
* Handle
|
||||
*/
|
||||
@On(events.paymentReceipts.onEdited)
|
||||
async handleInvoiceDecrementPaymentAmount({ tenantId, paymentReceiveId, paymentReceive, oldPaymentReceive }) {
|
||||
@On(events.paymentReceive.onDeleted)
|
||||
async handleInvoiceDecrementPaymentAmount({ tenantId, paymentReceiveId, oldPaymentReceive }) {
|
||||
this.logger.info('[payment_receive] trying to decrement sale invoice payment amount.');
|
||||
|
||||
await this.paymentReceivesService.saveChangeInvoicePaymentAmount(
|
||||
tenantId,
|
||||
paymentReceive.entries.map((entry) => ({
|
||||
...entry,
|
||||
paymentAmount: entry.paymentAmount * -1,
|
||||
})),
|
||||
oldPaymentReceive.entries.map((entry) => ({ ...entry, paymentAmount: 0 })),
|
||||
oldPaymentReceive.entries,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle customer balance increment once payment receive deleted.
|
||||
*/
|
||||
@On(events.paymentReceipts.onDeleted)
|
||||
@On(events.paymentReceive.onDeleted)
|
||||
async handleCustomerBalanceIncrement({ tenantId, paymentReceiveId, oldPaymentReceive }) {
|
||||
const { customerRepository } = this.tenancy.repositories(tenantId);
|
||||
|
||||
@@ -75,7 +73,7 @@ export default class PaymentReceivesSubscriber {
|
||||
/**
|
||||
* Handles customer balance diff balance change once payment receive edited.
|
||||
*/
|
||||
@On(events.paymentReceipts.onEdited)
|
||||
@On(events.paymentReceive.onEdited)
|
||||
async handleCustomerBalanceDiffChange({ tenantId, paymentReceiveId, paymentReceive, oldPaymentReceive }) {
|
||||
const { customerRepository } = this.tenancy.repositories(tenantId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user