closure
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
660842ca31
commit
d7ab95fcc8
|
@ -0,0 +1,80 @@
|
|||
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('closeAll', {
|
||||
description: 'Makes the closure process from all warehouses',
|
||||
accessType: 'WRITE',
|
||||
accepts: [],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/close-all`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.closeAll = async ctx => {
|
||||
const toDate = new Date();
|
||||
toDate.setDate(toDate.getDate() - 1);
|
||||
|
||||
const todayMinDate = new Date();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
|
||||
const todayMaxDate = new Date();
|
||||
maxDate.setHours(23, 59, 59, 59);
|
||||
|
||||
// Prevent closure for current day
|
||||
if (toDate >= todayMinDate && toDate <= todayMaxDate)
|
||||
throw new UserError('You cannot close tickets for today');
|
||||
|
||||
const tickets = await Self.rawSql(`
|
||||
SELECT
|
||||
t.id,
|
||||
t.clientFk,
|
||||
t.companyFk,
|
||||
c.name clientName,
|
||||
c.email recipient,
|
||||
c.salesPersonFk,
|
||||
c.isToBeMailed,
|
||||
c.hasToInvoice,
|
||||
co.hasDailyInvoice,
|
||||
eu.email salesPersonEmail
|
||||
FROM ticket t
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN warehouse wh ON wh.id = t.warehouseFk AND wh.hasComission
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.id = ts.alertLevel
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN province p ON p.id = c.provinceFk
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
||||
WHERE al.code = 'PACKED'
|
||||
AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY)
|
||||
AND util.dayEnd(?)
|
||||
AND t.refFk IS NULL
|
||||
GROUP BY t.id`, [toDate, toDate]);
|
||||
|
||||
console.log(tickets);
|
||||
|
||||
// await closure.start(tickets, response.locals);
|
||||
|
||||
// await db.rawSql(`
|
||||
// UPDATE ticket t
|
||||
// JOIN ticketState ts ON t.id = ts.ticketFk
|
||||
// JOIN alertLevel al ON al.id = ts.alertLevel
|
||||
// JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
// JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
// JOIN zone z ON z.id = t.zoneFk
|
||||
// SET t.routeFk = NULL
|
||||
// WHERE DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY)
|
||||
// AND util.dayEnd(?)
|
||||
// AND al.code NOT IN('DELIVERED','PACKED')
|
||||
// AND t.routeFk
|
||||
// AND z.name LIKE '%MADRID%'`, [toDate, toDate]);
|
||||
|
||||
return true;
|
||||
};
|
||||
};
|
|
@ -1,2 +0,0 @@
|
|||
// Import global directives
|
||||
require('./pin');
|
|
@ -1,9 +0,0 @@
|
|||
// DIRECTIVES NOT WORKING
|
||||
const Vue = require('vue');
|
||||
Vue.directive('pin', {
|
||||
bind: function(el, binding, vnode) {
|
||||
el.style.position = 'fixed';
|
||||
el.style.top = binding.value + 'px';
|
||||
el.style.backgroundColor = 'red';
|
||||
}
|
||||
});
|
|
@ -13,7 +13,6 @@ module.exports = {
|
|||
require('./core/smtp').init();
|
||||
require('./core/mixins');
|
||||
require('./core/filters');
|
||||
require('./core/directives');
|
||||
|
||||
const componentsDir = fs.readdirSync(componentsPath);
|
||||
componentsDir.forEach(componentName => {
|
||||
|
|
Loading…
Reference in New Issue