7525-devToTest #2542
|
@ -39,8 +39,6 @@ module.exports = Self => {
|
||||||
const xmlString = response.data;
|
const xmlString = response.data;
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||||
const [resultElement] = xmlDoc.getElementsByTagName('Mensaje');
|
return xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
||||||
|
|
||||||
return resultElement.textContent;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,7 +42,8 @@ module.exports = Self => {
|
||||||
throw new UserError(`Some mrwConfig parameters are not set`);
|
throw new UserError(`Some mrwConfig parameters are not set`);
|
||||||
|
|
||||||
const query =
|
const query =
|
||||||
`SELECT CASE co.code
|
`SELECT
|
||||||
|
CASE co.code
|
||||||
WHEN 'ES' THEN a.postalCode
|
WHEN 'ES' THEN a.postalCode
|
||||||
WHEN 'PT' THEN LEFT(a.postalCode, 4)
|
WHEN 'PT' THEN LEFT(a.postalCode, 4)
|
||||||
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
|
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
|
||||||
|
@ -89,14 +90,9 @@ module.exports = Self => {
|
||||||
const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml');
|
const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml');
|
||||||
const file = getTextByTag(getLabelResponse, 'EtiquetaFile');
|
const file = getTextByTag(getLabelResponse, 'EtiquetaFile');
|
||||||
|
|
||||||
try {
|
|
||||||
await models.Expedition.updateAll({id: expeditionFk}, {externalId: shipmentId}, myOptions);
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
} catch (error) {
|
|
||||||
if (tx) await tx.rollback();
|
return {shipmentId, file};
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function getTextByTag(xmlDoc, tag) {
|
function getTextByTag(xmlDoc, tag) {
|
||||||
|
|
|
@ -81,9 +81,9 @@ describe('MRWConfig createShipment()', () => {
|
||||||
|
|
||||||
spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop()));
|
spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop()));
|
||||||
|
|
||||||
const base64Binary = await models.MrwConfig.createShipment(expedition1.id, options);
|
const {file} = await models.MrwConfig.createShipment(expedition1.id, options);
|
||||||
|
|
||||||
expect(base64Binary).toEqual(mockBase64Binary);
|
expect(file).toEqual(mockBase64Binary);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if mrwConfig has no data', async() => {
|
it('should fail if mrwConfig has no data', async() => {
|
||||||
|
|
|
@ -35,7 +35,7 @@ BEGIN
|
||||||
itemFk,
|
itemFk,
|
||||||
longName,
|
longName,
|
||||||
supplier,
|
supplier,
|
||||||
entryFk,
|
CONCAT('E',entryFk) entryFk,
|
||||||
landed,
|
landed,
|
||||||
`in`,
|
`in`,
|
||||||
`out`,
|
`out`,
|
||||||
|
@ -49,16 +49,98 @@ BEGIN
|
||||||
itemFk,
|
itemFk,
|
||||||
longName,
|
longName,
|
||||||
supplier,
|
supplier,
|
||||||
'previous',
|
'E previous',
|
||||||
vFromDated,
|
vFromDated,
|
||||||
SUM(`in`),
|
SUM(`in`),
|
||||||
SUM(`out`),
|
SUM(`out`),
|
||||||
NULL,
|
NULL,
|
||||||
buyingValue
|
AVG(buyingValue)
|
||||||
FROM supplierPackaging
|
FROM supplierPackaging
|
||||||
WHERE supplierFk = vSupplierFk
|
WHERE supplierFk = vSupplierFk
|
||||||
AND landed < vFromDated
|
AND landed < vFromDated
|
||||||
GROUP BY itemFk
|
GROUP BY itemFk
|
||||||
|
UNION ALL
|
||||||
|
SELECT vSupplierFk,
|
||||||
|
s.itemFk,
|
||||||
|
i.longName,
|
||||||
|
c.name,
|
||||||
|
CONCAT('T',s.ticketFk),
|
||||||
|
DATE(t.shipped),
|
||||||
|
-LEAST(s.quantity,0) `in`,
|
||||||
|
GREATEST(s.quantity,0) `out`,
|
||||||
|
t.warehouseFk,
|
||||||
|
s.price * (100 - s.discount) / 100
|
||||||
|
FROM sale s
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN packaging p ON p.itemFk = i.id
|
||||||
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
|
JOIN client c ON c.id = t.clientFk
|
||||||
|
JOIN supplier su ON su.nif = c.fi
|
||||||
|
WHERE su.id = vSupplierFk
|
||||||
|
AND t.shipped >= vFromDated
|
||||||
|
AND p.isPackageReturnable
|
||||||
|
UNION ALL
|
||||||
|
SELECT vSupplierFk,
|
||||||
|
s.itemFk,
|
||||||
|
i.longName,
|
||||||
|
c.name,
|
||||||
|
'T previous',
|
||||||
|
vFromDated,
|
||||||
|
SUM(-LEAST(s.quantity,0)) `in`,
|
||||||
|
SUM(GREATEST(s.quantity,0)) `out`,
|
||||||
|
NULL,
|
||||||
|
AVG(s.price * (100 - s.discount) / 100)
|
||||||
|
FROM sale s
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN packaging p ON p.itemFk = i.id
|
||||||
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
|
JOIN client c ON c.id = t.clientFk
|
||||||
|
JOIN supplier su ON su.nif = c.fi
|
||||||
|
WHERE su.id = vSupplierFk
|
||||||
|
AND t.shipped < vFromDated
|
||||||
|
AND p.isPackageReturnable
|
||||||
|
GROUP BY s.itemFk
|
||||||
|
UNION ALL
|
||||||
|
SELECT vSupplierFk,
|
||||||
|
p.itemFk,
|
||||||
|
i.longName,
|
||||||
|
c.name,
|
||||||
|
CONCAT('TP',tp.ticketFk),
|
||||||
|
DATE(t.shipped),
|
||||||
|
-LEAST(tp.quantity,0) `in`,
|
||||||
|
GREATEST(tp.quantity,0) `out`,
|
||||||
|
t.warehouseFk,
|
||||||
|
0
|
||||||
|
FROM ticketPackaging tp
|
||||||
|
JOIN packaging p ON p.id = tp.packagingFk
|
||||||
|
JOIN item i ON i.id = p.itemFk
|
||||||
|
JOIN ticket t ON t.id = tp.ticketFk
|
||||||
|
JOIN client c ON c.id = t.clientFk
|
||||||
|
JOIN supplier su ON su.nif = c.fi
|
||||||
|
WHERE su.id = vSupplierFk
|
||||||
|
AND t.shipped >= vFromDated
|
||||||
|
AND p.isPackageReturnable
|
||||||
|
UNION ALL
|
||||||
|
SELECT vSupplierFk,
|
||||||
|
p.itemFk,
|
||||||
|
i.longName,
|
||||||
|
c.name,
|
||||||
|
'TP previous',
|
||||||
|
vFromDated,
|
||||||
|
SUM(-LEAST(tp.quantity,0)) `in`,
|
||||||
|
SUM(GREATEST(tp.quantity,0)) `out`,
|
||||||
|
NULL,
|
||||||
|
0
|
||||||
|
FROM ticketPackaging tp
|
||||||
|
JOIN packaging p ON p.id = tp.packagingFk
|
||||||
|
JOIN item i ON i.id = p.itemFk
|
||||||
|
JOIN ticket t ON t.id = tp.ticketFk
|
||||||
|
JOIN client c ON c.id = t.clientFk
|
||||||
|
JOIN supplier su ON su.nif = c.fi
|
||||||
|
WHERE su.id = vSupplierFk
|
||||||
|
AND t.shipped >= vFromDated
|
||||||
|
AND p.isPackageReturnable
|
||||||
|
GROUP BY p.itemFk
|
||||||
ORDER BY itemFk, landed, entryFk
|
ORDER BY itemFk, landed, entryFk
|
||||||
) sub
|
) sub
|
||||||
WHERE `out` OR `in`;
|
WHERE `out` OR `in`;
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE floranet.`order` ADD IF NOT EXISTS observations TEXT NULL;
|
|
@ -62,12 +62,12 @@ module.exports = Self => {
|
||||||
|
|
||||||
const clone = await models.Roadmap.create(roadmap, options);
|
const clone = await models.Roadmap.create(roadmap, options);
|
||||||
|
|
||||||
const expeditionTrucks = roadmap.expeditionTruck();
|
const roadmapStops = roadmap.roadmapStop();
|
||||||
expeditionTrucks.map(expeditionTruck => {
|
roadmapStops.map(roadmapStop => {
|
||||||
expeditionTruck.roadmapFk = clone.id;
|
roadmapStop.roadmapFk = clone.id;
|
||||||
return expeditionTruck;
|
return roadmapStop;
|
||||||
});
|
});
|
||||||
await models.ExpeditionTruck.create(expeditionTrucks, options);
|
await models.RoadmapStop.create(roadmapStops, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
await tx.commit();
|
await tx.commit();
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"DeliveryPoint": {
|
"DeliveryPoint": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"ExpeditionTruck": {
|
"RoadmapStop": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Roadmap": {
|
"Roadmap": {
|
||||||
|
|
|
@ -54,9 +54,9 @@
|
||||||
"model": "Supplier",
|
"model": "Supplier",
|
||||||
"foreignKey": "supplierFk"
|
"foreignKey": "supplierFk"
|
||||||
},
|
},
|
||||||
"expeditionTruck": {
|
"roadmapStop": {
|
||||||
"type": "hasMany",
|
"type": "hasMany",
|
||||||
"model": "ExpeditionTruck",
|
"model": "RoadmapStop",
|
||||||
"foreignKey": "roadmapFk"
|
"foreignKey": "roadmapFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ExpeditionTruck",
|
"name": "RoadmapStop",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "expeditionTruck"
|
"table": "roadmapStop"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
|
@ -1,22 +1,22 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="ExpeditionTrucks"
|
url="RoadmapStops"
|
||||||
where="{roadmapFk: $ctrl.$params.id}"
|
where="{roadmapFk: $ctrl.$params.id}"
|
||||||
order="eta ASC"
|
order="eta ASC"
|
||||||
data="$ctrl.expeditionTrucks"
|
data="$ctrl.roadmapStops"
|
||||||
auto-load="true">
|
auto-load="true">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-watcher
|
<vn-watcher
|
||||||
vn-id="watcher"
|
vn-id="watcher"
|
||||||
data="$ctrl.expeditionTrucks"
|
data="$ctrl.roadmapStops"
|
||||||
form="form">
|
form="form">
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
<form class="vn-w-md" name="form" ng-submit="$ctrl.onSubmit()">
|
<form class="vn-w-md" name="form" ng-submit="$ctrl.onSubmit()">
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-horizontal ng-repeat="expeditionTruck in $ctrl.expeditionTrucks">
|
<vn-horizontal ng-repeat="roadmapStop in $ctrl.roadmapStops">
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
label="Warehouse"
|
label="Warehouse"
|
||||||
ng-model="expeditionTruck.warehouseFk"
|
ng-model="roadmapStop.warehouseFk"
|
||||||
url="Warehouses"
|
url="Warehouses"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
|
@ -25,18 +25,18 @@
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-date-picker vn-one
|
<vn-date-picker vn-one
|
||||||
label="ETA date"
|
label="ETA date"
|
||||||
ng-model="expeditionTruck.eta"
|
ng-model="roadmapStop.eta"
|
||||||
rule>
|
rule>
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
<vn-input-time
|
<vn-input-time
|
||||||
vn-one
|
vn-one
|
||||||
label="ETA hour"
|
label="ETA hour"
|
||||||
ng-model="expeditionTruck.eta">
|
ng-model="roadmapStop.eta">
|
||||||
</vn-input-time>
|
</vn-input-time>
|
||||||
<vn-textArea
|
<vn-textArea
|
||||||
vn-one
|
vn-one
|
||||||
label="Description"
|
label="Description"
|
||||||
ng-model="expeditionTruck.description"
|
ng-model="roadmapStop.description"
|
||||||
rule>
|
rule>
|
||||||
</vn-textArea>
|
</vn-textArea>
|
||||||
<vn-none>
|
<vn-none>
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
vn-bind="+"
|
vn-bind="+"
|
||||||
vn-tooltip="Add stop"
|
vn-tooltip="Add stop"
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
vn-click-stop="addExpeditionTruck.show()">
|
vn-click-stop="addRoadmapStop.show()">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
@ -61,9 +61,9 @@
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="expeditionTruck in summary.expeditionTruck">
|
<vn-tr ng-repeat="roadmapStop in summary.roadmapStop">
|
||||||
<vn-td>{{expeditionTruck.warehouse.name}}</vn-td>
|
<vn-td>{{roadmapStop.warehouse.name}}</vn-td>
|
||||||
<vn-td expand>{{expeditionTruck.eta | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
<vn-td expand>{{roadmapStop.eta | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
|
@ -75,14 +75,14 @@
|
||||||
</vn-supplier-descriptor-popover>
|
</vn-supplier-descriptor-popover>
|
||||||
|
|
||||||
<vn-dialog
|
<vn-dialog
|
||||||
vn-id="addExpeditionTruck"
|
vn-id="addRoadmapStop"
|
||||||
on-open="$ctrl.getETD()"
|
on-open="$ctrl.getETD()"
|
||||||
on-accept="$ctrl.onAddAccept()">
|
on-accept="$ctrl.onAddAccept()">
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Warehouse"
|
label="Warehouse"
|
||||||
ng-model="$ctrl.expeditionTruck.warehouseFk"
|
ng-model="$ctrl.roadmapStop.warehouseFk"
|
||||||
url="Warehouses"
|
url="Warehouses"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
|
@ -93,18 +93,18 @@
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
label="ETA date"
|
label="ETA date"
|
||||||
ng-model="$ctrl.expeditionTruck.eta"
|
ng-model="$ctrl.roadmapStop.eta"
|
||||||
rule>
|
rule>
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
<vn-input-time
|
<vn-input-time
|
||||||
label="ETA hour"
|
label="ETA hour"
|
||||||
ng-model="$ctrl.expeditionTruck.eta">
|
ng-model="$ctrl.roadmapStop.eta">
|
||||||
</vn-input-time>
|
</vn-input-time>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textArea
|
<vn-textArea
|
||||||
label="Description"
|
label="Description"
|
||||||
ng-model="$ctrl.expeditionTruck.description"
|
ng-model="$ctrl.roadmapStop.description"
|
||||||
rule>
|
rule>
|
||||||
</vn-textArea>
|
</vn-textArea>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Controller extends Component {
|
||||||
include: [
|
include: [
|
||||||
{relation: 'supplier'},
|
{relation: 'supplier'},
|
||||||
{relation: 'worker'},
|
{relation: 'worker'},
|
||||||
{relation: 'expeditionTruck',
|
{relation: 'roadmapStop',
|
||||||
scope: {
|
scope: {
|
||||||
include: [
|
include: [
|
||||||
{relation: 'warehouse'}
|
{relation: 'warehouse'}
|
||||||
|
@ -36,19 +36,19 @@ class Controller extends Component {
|
||||||
const eta = new Date(this.roadmap.etd);
|
const eta = new Date(this.roadmap.etd);
|
||||||
eta.setDate(eta.getDate() + 1);
|
eta.setDate(eta.getDate() + 1);
|
||||||
|
|
||||||
this.expeditionTruck = {eta: eta};
|
this.roadmapStop = {eta: eta};
|
||||||
}
|
}
|
||||||
|
|
||||||
onAddAccept() {
|
onAddAccept() {
|
||||||
try {
|
try {
|
||||||
const data = {
|
const data = {
|
||||||
roadmapFk: this.roadmap.id,
|
roadmapFk: this.roadmap.id,
|
||||||
warehouseFk: this.expeditionTruck.warehouseFk,
|
warehouseFk: this.roadmapStop.warehouseFk,
|
||||||
eta: this.expeditionTruck.eta,
|
eta: this.roadmapStop.eta,
|
||||||
description: this.expeditionTruck.description
|
description: this.roadmapStop.description
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$http.post(`ExpeditionTrucks`, data)
|
this.$http.post(`RoadmapStops`, data)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"expeditionTruck": {
|
"roadmapStop": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "ExpeditionTruck",
|
"model": "RoadmapStop",
|
||||||
"foreignKey": "truckFk"
|
"foreignKey": "truckFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "number",
|
||||||
|
"id": true
|
||||||
},
|
},
|
||||||
"originFk": {
|
"originFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
|
|
@ -37,18 +37,19 @@ class Controller extends Section {
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: ['originFk', 'creationDate', 'newInstance'],
|
fields: ['id', 'originFk', 'creationDate', 'newInstance'],
|
||||||
where: {
|
where: {
|
||||||
originFk: value,
|
originFk: value,
|
||||||
newInstance: {like: '%"isDeleted":true%'}
|
newInstance: {like: '%"isDeleted":true%'}
|
||||||
},
|
},
|
||||||
order: 'creationDate DESC'
|
order: 'creationDate DESC',
|
||||||
|
limit: 1
|
||||||
};
|
};
|
||||||
this.$http.get(`TicketLogs/findOne`, {filter})
|
this.$http.get(`TicketLogs`, {filter})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res && res.data) {
|
if (res && res.data && res.data.length) {
|
||||||
const now = Date.vnNew();
|
const now = Date.vnNew();
|
||||||
const maxDate = new Date(res.data.creationDate);
|
const maxDate = new Date(res.data[0].creationDate);
|
||||||
maxDate.setHours(maxDate.getHours() + 1);
|
maxDate.setHours(maxDate.getHours() + 1);
|
||||||
if (now <= maxDate)
|
if (now <= maxDate)
|
||||||
return this.canRestoreTicket = true;
|
return this.canRestoreTicket = true;
|
||||||
|
|
|
@ -227,7 +227,7 @@ localFixtures:
|
||||||
- expeditionScan
|
- expeditionScan
|
||||||
- expeditionState
|
- expeditionState
|
||||||
- expeditionStateType
|
- expeditionStateType
|
||||||
- expeditionTruck
|
- roadmapStop
|
||||||
- expense
|
- expense
|
||||||
- genus
|
- genus
|
||||||
- greuge
|
- greuge
|
||||||
|
|
Loading…
Reference in New Issue