feat(createShipment): refs #7765 add dynamic weight by box
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
5567359d73
commit
40583020d0
|
@ -41,7 +41,7 @@
|
|||
<mrw:Alto><%= mrw.defaultHeight %></mrw:Alto>
|
||||
<mrw:Largo><%= mrw.defaultLength %></mrw:Largo>
|
||||
<mrw:Ancho><%= mrw.defaultWidth %></mrw:Ancho>
|
||||
<mrw:Peso><%= mrw.defaultWeight %></mrw:Peso>
|
||||
<mrw:Peso><%= expeditionData.defaultWeight ?? mrw.defaultWeight %></mrw:Peso>
|
||||
</mrw:BultoRequest>
|
||||
</mrw:Bultos>
|
||||
</mrw:DatosServicio>
|
||||
|
|
|
@ -36,39 +36,44 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
const query =
|
||||
`SELECT
|
||||
CASE co.code
|
||||
WHEN 'ES' THEN a.postalCode
|
||||
WHEN 'PT' THEN LEFT(a.postalCode, mc.portugalPostCodeTrim)
|
||||
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
|
||||
END postalCode,
|
||||
a.city,
|
||||
a.street,
|
||||
co.code countryCode,
|
||||
c.fi,
|
||||
c.name clientName,
|
||||
c.phone,
|
||||
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
||||
t.shipped,
|
||||
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
|
||||
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType,
|
||||
IF(mw.weekdays, 'S', 'N') weekDays,
|
||||
oa.description deliveryObservation
|
||||
FROM expedition e
|
||||
JOIN ticket t ON e.ticketFk = t.id
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN mrwService ms ON ms.agencyModeCodeFk = am.code
|
||||
LEFT JOIN mrwServiceWeekday mw ON mw.agencyModeCodeFk = am.code
|
||||
AND mw.weekDays & (1 << WEEKDAY(t.landed))
|
||||
JOIN client c ON t.clientFk = c.id
|
||||
JOIN address a ON t.addressFk = a.id
|
||||
LEFT JOIN addressObservation oa ON oa.addressFk = a.id
|
||||
AND oa.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'delivery')
|
||||
JOIN province p ON a.provinceFk = p.id
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
JOIN mrwConfig mc
|
||||
WHERE e.id = ?
|
||||
LIMIT 1`;
|
||||
`SELECT CASE co.code
|
||||
WHEN 'ES' THEN a.postalCode
|
||||
WHEN 'PT' THEN LEFT(a.postalCode, mc.portugalPostCodeTrim)
|
||||
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
|
||||
END postalCode,
|
||||
a.city,
|
||||
a.street,
|
||||
co.code countryCode,
|
||||
c.fi,
|
||||
c.name clientName,
|
||||
c.phone,
|
||||
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
||||
t.shipped,
|
||||
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
|
||||
LPAD(
|
||||
IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType),
|
||||
mc.serviceTypeWidth,
|
||||
'0'
|
||||
) serviceType,
|
||||
IF(mw.weekdays, 'S', 'N') weekDays,
|
||||
oa.description deliveryObservation,
|
||||
pa.defaultWeight
|
||||
FROM expedition e
|
||||
LEFT JOIN packaging pa ON e.packagingFk = pa.id
|
||||
JOIN ticket t ON e.ticketFk = t.id
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN mrwService ms ON ms.agencyModeCodeFk = am.code
|
||||
LEFT JOIN mrwServiceWeekday mw ON mw.agencyModeCodeFk = am.code
|
||||
AND mw.weekDays & (1 << WEEKDAY(t.landed))
|
||||
JOIN client c ON t.clientFk = c.id
|
||||
JOIN address a ON t.addressFk = a.id
|
||||
LEFT JOIN addressObservation oa ON oa.addressFk = a.id
|
||||
AND oa.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'delivery')
|
||||
JOIN province p ON a.provinceFk = p.id
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
JOIN mrwConfig mc
|
||||
WHERE e.id = ?
|
||||
LIMIT 1`;
|
||||
|
||||
const [expeditionData] = await Self.rawSql(query, [expeditionFk]);
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ module.exports = Self => {
|
|||
|
||||
Self.sendXmlDoc = async function(path, params, contentType) {
|
||||
const parser = new DOMParser();
|
||||
|
||||
const xmlTemplate = fs.readFileSync(path, 'utf-8');
|
||||
const renderedTemplate = ejs.render(xmlTemplate, params);
|
||||
const data = await axios.post(params.mrw.url, renderedTemplate, {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE vn.packaging ADD IF NOT EXISTS defaultWeight INT NULL
|
||||
COMMENT 'default weight used in mrw';
|
||||
|
||||
INSERT IGNORE INTO vn.packaging (id, defaultWeight)
|
||||
VALUES ('QB033', 3),
|
||||
('HC', 3),
|
||||
('kalan400', 4),
|
||||
('kalan577', 5),
|
||||
('guzma650', 6),
|
||||
('b-1', 7),
|
||||
('guzma1400', 9),
|
||||
('guzma1200', 9);
|
Loading…
Reference in New Issue