22 lines
927 B
JavaScript
22 lines
927 B
JavaScript
const UserError = require('vn-loopback/util/user-error');
|
|
|
|
module.exports = Self => {
|
|
require('../methods/invoice-in/filter')(Self);
|
|
require('../methods/invoice-in/summary')(Self);
|
|
require('../methods/invoice-in/clone')(Self);
|
|
require('../methods/invoice-in/toBook')(Self);
|
|
require('../methods/invoice-in/getTotals')(Self);
|
|
require('../methods/invoice-in/invoiceInPdf')(Self);
|
|
require('../methods/invoice-in/invoiceInEmail')(Self);
|
|
require('../methods/invoice-in/getSerial')(Self);
|
|
require('../methods/invoice-in/corrective')(Self);
|
|
require('../methods/invoice-in/exchangeRateUpdate')(Self);
|
|
require('../methods/invoice-in/toUnbook')(Self);
|
|
|
|
Self.rewriteDbError(function(err) {
|
|
if (err.code === 'ER_ROW_IS_REFERENCED_2' && err.sqlMessage.includes('vehicleInvoiceIn'))
|
|
return new UserError(`This invoice has a linked vehicle.`);
|
|
return err;
|
|
});
|
|
};
|