mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
fix issues in sales and purchases API module.
This commit is contained in:
@@ -145,9 +145,9 @@ export default class BillPaymentsService {
|
||||
// Change the different vendor balance between the new and old one.
|
||||
const changeDiffBalance = Vendor.changeDiffBalance(
|
||||
billPayment.vendor_id,
|
||||
oldBillPayment.vendor_id,
|
||||
billPayment.amount,
|
||||
oldBillPayment.amount
|
||||
oldBillPayment.vendorId,
|
||||
billPayment.amount * -1,
|
||||
oldBillPayment.amount * -1,
|
||||
);
|
||||
await Promise.all([
|
||||
...opers,
|
||||
|
||||
@@ -79,10 +79,11 @@ export default class BillsService {
|
||||
* - Re-write the inventory transactions.
|
||||
* - Re-write the bill journal transactions.
|
||||
*
|
||||
* @param {Integer} billId
|
||||
* @param {IBill} bill
|
||||
* @param {Integer} billId - The given bill id.
|
||||
* @param {IBill} bill - The given new bill details.
|
||||
*/
|
||||
static async editBill(billId, bill) {
|
||||
const oldBill = await Bill.tenant().query().findById(billId);
|
||||
const amount = sumBy(bill.entries, 'amount');
|
||||
|
||||
// Update the bill transaction.
|
||||
@@ -104,12 +105,20 @@ export default class BillsService {
|
||||
const patchEntriesOper = HasItemsEntries.patchItemsEntries(
|
||||
bill.entries, storedEntries, 'Bill', billId,
|
||||
);
|
||||
// Changes the diff vendor balance between old and new amount.
|
||||
const changeVendorBalanceOper = Vendor.changeDiffBalance(
|
||||
bill.vendor_id,
|
||||
oldBill.vendorId,
|
||||
amount,
|
||||
oldBill.amount,
|
||||
);
|
||||
// Record bill journal transactions.
|
||||
const recordTransactionsOper = this.recordJournalTransactions(bill, billId);
|
||||
|
||||
await Promise.all([
|
||||
patchEntriesOper,
|
||||
recordTransactionsOper,
|
||||
changeVendorBalanceOper,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -249,7 +258,7 @@ export default class BillsService {
|
||||
'Bill'
|
||||
);
|
||||
// Revert vendor balance.
|
||||
const revertVendorBalance = Vendor.changeBalance(billId, bill.amount * -1);
|
||||
const revertVendorBalance = Vendor.changeBalance(bill.vendorId, bill.amount * -1);
|
||||
|
||||
await Promise.all([
|
||||
deleteBillOper,
|
||||
|
||||
Reference in New Issue
Block a user