mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: hotbug creating sale invoice.
This commit is contained in:
@@ -112,6 +112,7 @@ export default class CurrenciesController extends BaseController {
|
|||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
currency_code: currencyDTO.currencyCode,
|
currency_code: currencyDTO.currencyCode,
|
||||||
|
message: 'The currency has been created successfully.',
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
@@ -130,7 +131,10 @@ export default class CurrenciesController extends BaseController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await this.currenciesService.deleteCurrency(tenantId, currencyCode);
|
await this.currenciesService.deleteCurrency(tenantId, currencyCode);
|
||||||
return res.status(200).send({ currency_code: currencyCode });
|
return res.status(200).send({
|
||||||
|
currency_code: currencyCode,
|
||||||
|
message: 'The currency has been deleted successfully.',
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
@@ -149,7 +153,10 @@ export default class CurrenciesController extends BaseController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const currency = await this.currenciesService.editCurrency(tenantId, currencyId, editCurrencyDTO);
|
const currency = await this.currenciesService.editCurrency(tenantId, currencyId, editCurrencyDTO);
|
||||||
return res.status(200).send({ currency_code: currency.currencyCode });
|
return res.status(200).send({
|
||||||
|
currency_code: currency.currencyCode,
|
||||||
|
message: 'The currency has been edited successfully.',
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,10 @@ export default class SaleInvoicesController extends BaseController{
|
|||||||
const storedSaleInvoice = await this.saleInvoiceService.createSaleInvoice(
|
const storedSaleInvoice = await this.saleInvoiceService.createSaleInvoice(
|
||||||
tenantId, saleInvoiceOTD,
|
tenantId, saleInvoiceOTD,
|
||||||
);
|
);
|
||||||
return res.status(200).send({ id: storedSaleInvoice.id });
|
return res.status(200).send({
|
||||||
|
id: storedSaleInvoice.id,
|
||||||
|
message: 'The sale invoice has been created successfully.',
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error)
|
next(error)
|
||||||
}
|
}
|
||||||
@@ -179,7 +182,10 @@ export default class SaleInvoicesController extends BaseController{
|
|||||||
try {
|
try {
|
||||||
// Update the given sale invoice details.
|
// Update the given sale invoice details.
|
||||||
await this.saleInvoiceService.editSaleInvoice(tenantId, saleInvoiceId, saleInvoiceOTD);
|
await this.saleInvoiceService.editSaleInvoice(tenantId, saleInvoiceId, saleInvoiceOTD);
|
||||||
return res.status(200).send({ id: saleInvoiceId });
|
return res.status(200).send({
|
||||||
|
id: saleInvoiceId,
|
||||||
|
message: 'The sale invoice has beeen edited successfully.',
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
@@ -221,7 +227,10 @@ export default class SaleInvoicesController extends BaseController{
|
|||||||
// Deletes the sale invoice with associated entries and journal transaction.
|
// Deletes the sale invoice with associated entries and journal transaction.
|
||||||
await this.saleInvoiceService.deleteSaleInvoice(tenantId, saleInvoiceId);
|
await this.saleInvoiceService.deleteSaleInvoice(tenantId, saleInvoiceId);
|
||||||
|
|
||||||
return res.status(200).send({ id: saleInvoiceId });
|
return res.status(200).send({
|
||||||
|
id: saleInvoiceId,
|
||||||
|
message: 'The sale invoice has been deleted successfully.',
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,10 +134,10 @@ export default class SaleInvoicesService extends SalesInvoicesCost {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...formatDateFields(omit(saleInvoiceDTO, ['delivered', 'entries']), [
|
...formatDateFields(
|
||||||
'invoiceDate',
|
omit(saleInvoiceDTO, ['delivered', 'entries']),
|
||||||
'dueDate',
|
['invoiceDate', 'dueDate']
|
||||||
]),
|
),
|
||||||
// Avoid rewrite the deliver date in edit mode when already published.
|
// Avoid rewrite the deliver date in edit mode when already published.
|
||||||
...(saleInvoiceDTO.delivered &&
|
...(saleInvoiceDTO.delivered &&
|
||||||
!oldSaleInvoice?.deliveredAt && {
|
!oldSaleInvoice?.deliveredAt && {
|
||||||
@@ -145,7 +145,7 @@ export default class SaleInvoicesService extends SalesInvoicesCost {
|
|||||||
}),
|
}),
|
||||||
balance,
|
balance,
|
||||||
paymentAmount: 0,
|
paymentAmount: 0,
|
||||||
entries: saleInvoiceObj.entries.map((entry) => ({
|
entries: saleInvoiceDTO.entries.map((entry) => ({
|
||||||
reference_type: 'SaleInvoice',
|
reference_type: 'SaleInvoice',
|
||||||
...omit(entry, ['amount', 'id']),
|
...omit(entry, ['amount', 'id']),
|
||||||
})),
|
})),
|
||||||
|
|||||||
Reference in New Issue
Block a user