mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
fix: sync contacts balance with journal entries.
fix: edit invoice amount that has payment transactions.
This commit is contained in:
@@ -5,7 +5,6 @@ import { mapKeysDeep } from 'utils'
|
||||
import asyncMiddleware from 'api/middleware/asyncMiddleware';
|
||||
|
||||
export default class BaseController {
|
||||
|
||||
/**
|
||||
* Converts plain object keys to cameCase style.
|
||||
* @param {Object} data
|
||||
@@ -75,6 +74,10 @@ export default class BaseController {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Async middleware.
|
||||
* @param {function} callback
|
||||
*/
|
||||
asyncMiddleware(callback) {
|
||||
return asyncMiddleware(callback);
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ export default class ManualJournalsController extends BaseController {
|
||||
manualJournalId
|
||||
);
|
||||
return res.status(200).send({
|
||||
manual_journal: manualJournal
|
||||
manual_journal: manualJournal,
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
@@ -449,14 +449,25 @@ export default class ManualJournalsController extends BaseController {
|
||||
],
|
||||
});
|
||||
}
|
||||
if (error.errorType === 'CONTACTS_SHOULD_ASSIGN_WITH_VALID_ACCOUNT') {
|
||||
return res.boom.badRequest('', {
|
||||
errors: [
|
||||
{
|
||||
type: 'CONTACTS_SHOULD_ASSIGN_WITH_VALID_ACCOUNT',
|
||||
code: 700,
|
||||
meta: this.transfromToResponse(error.payload),
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
if (error.errorType === 'contacts_not_found') {
|
||||
return res.boom.badRequest('', {
|
||||
errors: [{ type: 'CONTACTS_NOT_FOUND', code: 700 }],
|
||||
errors: [{ type: 'CONTACTS_NOT_FOUND', code: 800 }],
|
||||
});
|
||||
}
|
||||
if (error.errorType === 'MANUAL_JOURNAL_ALREADY_PUBLISHED') {
|
||||
return res.boom.badRequest('', {
|
||||
errors: [{ type: 'MANUAL_JOURNAL_ALREADY_PUBLISHED', code: 800 }],
|
||||
errors: [{ type: 'MANUAL_JOURNAL_ALREADY_PUBLISHED', code: 900 }],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,14 @@ export default class SaleInvoicesController extends BaseController {
|
||||
check('entries.*.item_id').exists().isNumeric().toInt(),
|
||||
check('entries.*.rate').exists().isNumeric().toFloat(),
|
||||
check('entries.*.quantity').exists().isNumeric().toFloat(),
|
||||
check('entries.*.discount').optional({ nullable: true }).isNumeric().toFloat(),
|
||||
check('entries.*.description').optional({ nullable: true }).trim().escape(),
|
||||
check('entries.*.discount')
|
||||
.optional({ nullable: true })
|
||||
.isNumeric()
|
||||
.toFloat(),
|
||||
check('entries.*.description')
|
||||
.optional({ nullable: true })
|
||||
.trim()
|
||||
.escape(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -230,7 +236,11 @@ export default class SaleInvoicesController extends BaseController {
|
||||
|
||||
try {
|
||||
// Deletes the sale invoice with associated entries and journal transaction.
|
||||
await this.saleInvoiceService.deleteSaleInvoice(tenantId, saleInvoiceId, user);
|
||||
await this.saleInvoiceService.deleteSaleInvoice(
|
||||
tenantId,
|
||||
saleInvoiceId,
|
||||
user
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
id: saleInvoiceId,
|
||||
@@ -402,15 +412,23 @@ export default class SaleInvoicesController extends BaseController {
|
||||
}
|
||||
if (error.errorType === 'SALE_ESTIMATE_NOT_FOUND') {
|
||||
return res.boom.badRequest(null, {
|
||||
errors: [
|
||||
{ type: 'FROM_SALE_ESTIMATE_NOT_FOUND', code: 1200 },
|
||||
],
|
||||
errors: [{ type: 'FROM_SALE_ESTIMATE_NOT_FOUND', code: 1200 }],
|
||||
});
|
||||
}
|
||||
if (error.errorType === 'SALE_ESTIMATE_CONVERTED_TO_INVOICE') {
|
||||
return res.boom.badRequest(null, {
|
||||
errors: [
|
||||
{ type: 'SALE_ESTIMATE_IS_ALREADY_CONVERTED_TO_INVOICE', code: 1300 },
|
||||
{
|
||||
type: 'SALE_ESTIMATE_IS_ALREADY_CONVERTED_TO_INVOICE',
|
||||
code: 1300,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
if (error.errorType === 'INVOICE_AMOUNT_SMALLER_THAN_PAYMENT_AMOUNT') {
|
||||
return res.boom.badRequest(null, {
|
||||
errors: [
|
||||
{ type: 'INVOICE_AMOUNT_SMALLER_THAN_PAYMENT_AMOUNT', code: 1400 },
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ export default class LicensesController extends BaseController {
|
||||
challenge: true,
|
||||
})
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/generate',
|
||||
this.generateLicenseSchema,
|
||||
|
||||
Reference in New Issue
Block a user