Requested changes realized
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Jorge Padawan 2021-02-12 11:27:24 +01:00
parent 2a2009b287
commit dad3e7c155
7 changed files with 62 additions and 10 deletions

View File

@ -10,5 +10,8 @@
},
"SupplierContact": {
"dataSource": "vn"
},
"SupplierAccount": {
"dataSource": "vn"
}
}

View File

@ -0,0 +1,50 @@
{
"name": "SupplierAccount",
"base": "VnModel",
"options": {
"mysql": {
"table": "supplierAccount"
}
},
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"supplierFk": {
"type": "Number"
},
"iban": {
"type": "String"
},
"office": {
"type": "String"
},
"DC": {
"type": "String"
},
"number": {
"type": "String"
},
"description": {
"type": "String"
},
"bicSufix": {
"type": "String"
},
"bankEntityFk": {
"type": "Number"
},
"bankFk": {
"type": "Number"
}
},
"relations": {
"supplier": {
"type": "belongsTo",
"model": "Supplier",
"foreignKey": "supplierFk"
}
}
}

View File

@ -1,6 +1,6 @@
module.exports = Self => {
Self.remoteMethod('getTravelData', {
description: 'Returns the days of travel duration',
Self.remoteMethod('getAverageDays', {
description: 'Returns the average days duration and the two warehouses of the travel.',
accessType: 'READ',
accepts: [{
arg: 'agencyModeFk',
@ -12,12 +12,12 @@ module.exports = Self => {
root: true
},
http: {
path: `/getTravelData`,
path: `/getAverageDays`,
verb: 'GET'
}
});
Self.getTravelData = async agencyModeFk => {
Self.getAverageDays = async agencyModeFk => {
const query = `
SELECT t.id, t.warehouseInFk, t.warehouseOutFk,
(SELECT ROUND(AVG(DATEDIFF(t.landed, t.shipped )))
@ -26,7 +26,7 @@ module.exports = Self => {
FROM travel t
WHERE t.agencyFk = ? ORDER BY t.id DESC LIMIT 1;`;
const [result] = await Self.rawSql(query, [agencyModeFk, agencyModeFk]);
return result;
const [avgDays] = await Self.rawSql(query, [agencyModeFk, agencyModeFk]);
return avgDays;
};
};

View File

@ -8,7 +8,7 @@ module.exports = Self => {
require('../methods/travel/deleteThermograph')(Self);
require('../methods/travel/updateThermograph')(Self);
require('../methods/travel/extraCommunityFilter')(Self);
require('../methods/travel/getTravelData')(Self);
require('../methods/travel/getAverageDays')(Self);
require('../methods/travel/cloneWithEntries')(Self);
Self.rewriteDbError(function(err) {

View File

@ -22,7 +22,6 @@
<vn-date-picker
on-change="$ctrl.onShippedChange(value)"
label="Shipped"
id="dateShipped"
ng-model="$ctrl.travel.shipped">
</vn-date-picker>
<vn-date-picker

View File

@ -17,7 +17,7 @@ class Controller extends Section {
if (!hasAgencyMode || hasFilledProperties)
return;
const query = `travels/getTravelData`;
const query = `travels/getAverageDays`;
const params = {
agencyModeFk: this.travel.agencyModeFk
};

View File

@ -61,7 +61,7 @@ describe('Travel Component vnTravelCreate', () => {
warehouseOutFk: 2
};
const query = `travels/getTravelData?agencyModeFk=${controller.travel.agencyModeFk}`;
const query = `travels/getAverageDays?agencyModeFk=${controller.travel.agencyModeFk}`;
$httpBackend.expectGET(query).respond(expectedResponse);
controller.onShippedChange(tomorrow);
$httpBackend.flush();