36 lines
973 B
JavaScript
36 lines
973 B
JavaScript
module.exports = Self => {
|
|
Self.remoteMethod('getInvoiceDate', {
|
|
description: 'Returns default Invoice Date',
|
|
accessType: 'READ',
|
|
accepts: [
|
|
{
|
|
arg: 'companyFk',
|
|
type: 'number',
|
|
required: true
|
|
}
|
|
],
|
|
returns: {
|
|
type: ['object'],
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/getInvoiceDate`,
|
|
verb: 'GET'
|
|
}
|
|
});
|
|
|
|
Self.getInvoiceDate = async companyFk => {
|
|
const models = Self.app.models;
|
|
const [invoiceDate] = await models.InvoiceOut.rawSql(
|
|
`SELECT MAX(io.issued) issued
|
|
FROM invoiceOut io
|
|
JOIN invoiceOutSerial ios ON ios.code = io.serial
|
|
WHERE ios.type = 'global'
|
|
AND io.issued
|
|
AND io.companyFk = ?`,
|
|
[companyFk]
|
|
);
|
|
return invoiceDate;
|
|
};
|
|
};
|