WIP: feat(createShipment): refs #7765 add dynamic weight by box #2764

Draft
pablone wants to merge 1 commits from 7765-packingDefaultWeight into dev
4 changed files with 52 additions and 35 deletions

View File

@ -41,7 +41,7 @@
<mrw:Alto><%= mrw.defaultHeight %></mrw:Alto> <mrw:Alto><%= mrw.defaultHeight %></mrw:Alto>
<mrw:Largo><%= mrw.defaultLength %></mrw:Largo> <mrw:Largo><%= mrw.defaultLength %></mrw:Largo>
<mrw:Ancho><%= mrw.defaultWidth %></mrw:Ancho> <mrw:Ancho><%= mrw.defaultWidth %></mrw:Ancho>
<mrw:Peso><%= mrw.defaultWeight %></mrw:Peso> <mrw:Peso><%= expeditionData.defaultWeight ?? mrw.defaultWeight %></mrw:Peso>
</mrw:BultoRequest> </mrw:BultoRequest>
</mrw:Bultos> </mrw:Bultos>
</mrw:DatosServicio> </mrw:DatosServicio>

View File

@ -36,8 +36,7 @@ module.exports = Self => {
} }
const query = const query =
`SELECT `SELECT CASE co.code
CASE co.code
WHEN 'ES' THEN a.postalCode WHEN 'ES' THEN a.postalCode
WHEN 'PT' THEN LEFT(a.postalCode, mc.portugalPostCodeTrim) WHEN 'PT' THEN LEFT(a.postalCode, mc.portugalPostCodeTrim)
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00') WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
@ -51,10 +50,16 @@ module.exports = Self => {
DATE_FORMAT(t.shipped, '%d/%m/%Y') created, DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
t.shipped, t.shipped,
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType, LPAD(
IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType),
mc.serviceTypeWidth,
'0'
) serviceType,
IF(mw.weekdays, 'S', 'N') weekDays, IF(mw.weekdays, 'S', 'N') weekDays,
oa.description deliveryObservation oa.description deliveryObservation,
pa.defaultWeight
FROM expedition e FROM expedition e
LEFT JOIN packaging pa ON e.packagingFk = pa.id
JOIN ticket t ON e.ticketFk = t.id JOIN ticket t ON e.ticketFk = t.id
JOIN agencyMode am ON am.id = t.agencyModeFk JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN mrwService ms ON ms.agencyModeCodeFk = am.code JOIN mrwService ms ON ms.agencyModeCodeFk = am.code

View File

@ -21,7 +21,6 @@ module.exports = Self => {
Self.sendXmlDoc = async function(path, params, contentType) { Self.sendXmlDoc = async function(path, params, contentType) {
const parser = new DOMParser(); const parser = new DOMParser();
const xmlTemplate = fs.readFileSync(path, 'utf-8'); const xmlTemplate = fs.readFileSync(path, 'utf-8');
const renderedTemplate = ejs.render(xmlTemplate, params); const renderedTemplate = ejs.render(xmlTemplate, params);
const data = await axios.post(params.mrw.url, renderedTemplate, { const data = await axios.post(params.mrw.url, renderedTemplate, {

View File

@ -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);