Merge pull request '3791-travel_extra-community' (#918) from 3791-travel_extra-community into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #918
Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2022-03-29 10:27:31 +00:00
commit 419ec4ac18
9 changed files with 102 additions and 91 deletions

View File

@ -28,16 +28,6 @@ module.exports = Self => {
type: 'date',
description: 'The shipped from date filter'
},
{
arg: 'shippedTo',
type: 'date',
description: 'The shipped to date filter'
},
{
arg: 'landedFrom',
type: 'date',
description: 'The landed from date filter'
},
{
arg: 'landedTo',
type: 'date',
@ -101,10 +91,6 @@ module.exports = Self => {
return {'t.ref': {like: `%${value}%`}};
case 'shippedFrom':
return {'t.shipped': {gte: value}};
case 'shippedTo':
return {'t.shipped': {lte: value}};
case 'landedFrom':
return {'t.landed': {gte: value}};
case 'landedTo':
return {'t.landed': {lte: value}};
case 'continent':
@ -162,6 +148,7 @@ module.exports = Self => {
stmt.merge(conn.makeWhere(filter.where));
stmt.merge(conn.makeGroupBy('t.id'));
stmt.merge(conn.makeOrderBy(filter.order));
stmt.merge(conn.makeLimit(filter));
stmts.push(stmt);

View File

@ -46,15 +46,64 @@ describe('Travel extraCommunityFilter()', () => {
expect(result.length).toEqual(3);
});
it('should return the routes matching "landed from" and "landed to"', async() => {
const from = new Date();
const to = new Date();
from.setHours(0, 0, 0, 0);
to.setHours(23, 59, 59, 999);
to.setDate(to.getDate() + 14);
it('should return the travel matching "warehouse in"', async() => {
const ctx = {
args: {
landedFrom: from,
warehouseInFk: 1
}
};
const result = await app.models.Travel.extraCommunityFilter(ctx, filter);
expect(result.length).toEqual(4);
});
it('should return the travel matching "continent"', async() => {
const ctx = {
args: {
continent: 'AM'
}
};
const result = await app.models.Travel.extraCommunityFilter(ctx, filter);
expect(result.length).toEqual(3);
});
it('should return the travel matching "agencyFk"', async() => {
const ctx = {
args: {
agencyFk: 1
}
};
const result = await app.models.Travel.extraCommunityFilter(ctx, filter);
expect(result.length).toEqual(8);
});
it('should return the travel matching "cargoSupplierFk"', async() => {
const ctx = {
args: {
cargoSupplierFk: 1
}
};
const result = await app.models.Travel.extraCommunityFilter(ctx, filter);
expect(result.length).toEqual(4);
});
it('should return the routes matching "shipped from" and "landed to"', async() => {
const from = new Date();
from.setDate(from.getDate() - 2);
from.setHours(0, 0, 0, 0);
const to = new Date();
to.setHours(23, 59, 59, 999);
to.setDate(to.getDate() + 7);
const ctx = {
args: {
shippedFrom: from,
landedTo: to
}
};

View File

@ -47,17 +47,6 @@
ng-model="$ctrl.landedTo">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker
vn-one
label="Shipped to"
ng-model="$ctrl.shippedTo">
</vn-date-picker>
<vn-date-picker
vn-one
label="Landed from"
ng-model="$ctrl.landedFrom">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one

View File

@ -14,31 +14,6 @@ class Controller extends SearchPanel {
set shippedFrom(value) {
this.filter.shippedFrom = value;
if (!this.filter.landedFrom)
this.filter.landedFrom = value;
}
get shippedTo() {
return this.filter.shippedTo;
}
set shippedTo(value) {
this.filter.shippedTo = value;
if (!this.filter.landedTo)
this.filter.landedTo = value;
}
get landedFrom() {
return this.filter.landedFrom;
}
set landedFrom(value) {
this.filter.landedFrom = value;
if (!this.filter.shippedFrom)
this.filter.shippedFrom = value;
}
get landedTo() {
@ -47,9 +22,6 @@ class Controller extends SearchPanel {
set landedTo(value) {
this.filter.landedTo = value;
if (!this.filter.shippedTo)
this.filter.shippedTo = value;
}
}

View File

@ -2,7 +2,7 @@
vn-id="model"
url="Travels/extraCommunityFilter"
data="travels"
order="landed ASC, shipped ASC, travelFk, loadPriority, agencyModeFk, evaNotes"
order="shipped ASC, landed ASC, travelFk, loadPriority, agencyModeFk, evaNotes"
limit="20"
auto-load="true">
</vn-crud-model>

View File

@ -17,16 +17,18 @@ class Controller extends Section {
this.draggableElement = 'a[draggable]';
this.droppableElement = 'vn-tbody[vn-droppable]';
const scopeDays = 14;
const landedFrom = new Date();
landedFrom.setHours(0, 0, 0, 0);
const twoDays = 2;
const shippedFrom = new Date();
shippedFrom.setDate(shippedFrom.getDate() - twoDays);
shippedFrom.setHours(0, 0, 0, 0);
const sevenDays = 7;
const landedTo = new Date();
landedTo.setDate(landedTo.getDate() + scopeDays);
landedTo.setDate(landedTo.getDate() + sevenDays);
landedTo.setHours(23, 59, 59, 59);
this.defaultFilter = {
landedFrom: landedFrom,
shippedFrom: shippedFrom,
landedTo: landedTo,
continent: 'AM'
};
@ -34,10 +36,12 @@ class Controller extends Section {
get hasDateRange() {
const userParams = this.$.model.userParams;
const hasLanded = userParams.landedFrom || userParams.landedTo;
const hasShipped = userParams.shippedFrom || userParams.shippedTo;
const hasLanded = userParams.landedTo;
const hasShipped = userParams.shippedFrom;
const hasContinent = userParams.continent;
const hasWarehouseOut = userParams.warehouseOutFk;
return hasLanded || hasShipped;
return hasLanded || hasShipped || hasContinent || hasWarehouseOut;
}
findDraggable($event) {

View File

@ -9,8 +9,8 @@ vn-travel-extra-community {
padding-bottom: 7px;
padding-bottom: 4px;
font-weight: lighter;
background-color: #fde6ca;
color: $color-font-light;
background-color: $color-bg;
color: white;
border-bottom: 1px solid #f7931e;
white-space: nowrap;
overflow: hidden;

View File

@ -8,11 +8,16 @@ module.exports = {
async serverPrefetch() {
this.filters = this.$options.filters;
const args = {
landedFrom: this.landedStart,
landedTo: this.landedEnd,
shippedFrom: this.shippedStart,
shippedTo: this.shippedEnd,
continent: this.continent
continent: this.continent,
id: this.id,
agencyFk: this.agencyFk,
warehouseInFk: this.warehouseInFk,
warehouseOutFk: this.warehouseOutFk,
totalEntries: this.totalEntries,
ref: this.ref,
cargoSupplierFk: this.cargoSupplierFk
};
const travels = await this.fetchTravels(args);
@ -38,11 +43,6 @@ module.exports = {
dated: function() {
return this.filters.date(new Date(), '%d-%m-%Y');
},
landedStart: function() {
if (!this.landedFrom) return;
return this.filters.date(this.landedFrom, '%Y-%m-%d');
},
landedEnd: function() {
if (!this.landedTo) return;
@ -52,11 +52,6 @@ module.exports = {
if (!this.shippedFrom) return;
return this.filters.date(this.shippedFrom, '%Y-%m-%d');
},
shippedEnd: function() {
if (!this.shippedTo) return;
return this.filters.date(this.shippedTo, '%Y-%m-%d');
}
},
methods: {
@ -65,20 +60,29 @@ module.exports = {
switch (key) {
case 'shippedFrom':
return `t.shipped >= ${value}`;
case 'shippedTo':
return `t.shipped <= ${value}`;
case 'landedFrom':
return `t.landed >= ${value}`;
case 'landedTo':
return `t.landed <= ${value}`;
case 'continent':
return `cnt.code = ${value}`;
case 'ref':
return {'t.ref': {like: `%${value}%`}};
case 'id':
return `t.id = ${value}`;
case 'agencyFk':
return `am.id = ${value}`;
case 'warehouseOutFk':
return `wo.id = ${value}`;
case 'warehouseInFk':
return `w.id = ${value}`;
case 'cargoSupplierFk':
return `s.id = ${value}`;
}
});
let query = this.getSqlFromDef('travels');
query = db.merge(query, where);
query = db.merge(query, 'GROUP BY t.id');
query = db.merge(query, 'ORDER BY `shipped` ASC, `landed` ASC, `travelFk`, `loadPriority`, `agencyModeFk`, `evaNotes`');
return this.rawSql(query);
},
@ -92,10 +96,15 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: [
'landedFrom',
'landedTo',
'shippedFrom',
'shippedTo',
'continent'
'continent',
'ref',
'id',
'agencyFk',
'warehouseOutFk',
'warehouseInFk',
'totalEntries',
'cargoSupplierFk'
]
};

View File

@ -4,6 +4,7 @@ SELECT
t.shipped,
t.landed,
t.kg,
am.id AS agencyModeFk,
SUM(b.stickers) AS stickers,
CAST(SUM(i.density * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0)) as loadedKg,
CAST(SUM(167.5 * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0)) as volumeKg