Merge branch 'dev' into 2411-ticket-expedition-añadir-campo-packagingFk
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
cb4fe1f610
|
@ -0,0 +1,44 @@
|
|||
|
||||
USE `vn`;
|
||||
DROP procedure IF EXISTS `vn`.`itemLastEntries`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `itemLastEntries__`(IN `vItem` INT, IN `vDays` DATE)
|
||||
BEGIN
|
||||
SELECT
|
||||
w.id AS warehouseFk,
|
||||
w.name AS warehouse,
|
||||
tr.landed,
|
||||
b.entryFk,
|
||||
b.isIgnored,
|
||||
b.price2,
|
||||
b.price3,
|
||||
b.stickers,
|
||||
b.packing,
|
||||
b.`grouping`,
|
||||
b.groupingMode,
|
||||
b.weight,
|
||||
i.stems,
|
||||
b.quantity,
|
||||
b.buyingValue,
|
||||
b.packageFk ,
|
||||
s.id AS supplierFk,
|
||||
s.name AS supplier
|
||||
FROM itemType it
|
||||
RIGHT JOIN (entry e
|
||||
LEFT JOIN supplier s ON s.id = e.supplierFk
|
||||
RIGHT JOIN buy b ON b.entryFk = e.id
|
||||
LEFT JOIN item i ON i.id = b.itemFk
|
||||
LEFT JOIN ink ON ink.id = i.inkFk
|
||||
LEFT JOIN travel tr ON tr.id = e.travelFk
|
||||
LEFT JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||
LEFT JOIN origin o ON o.id = i.originFk
|
||||
) ON it.id = i.typeFk
|
||||
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
|
||||
WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND DATE_ADD(CURDATE(), INTERVAl + 10 DAY)
|
||||
ORDER BY tr.landed DESC , b.id DESC;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
|
@ -1,28 +0,0 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getLastEntries', {
|
||||
description: 'Returns last entries',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'itemFk, id'
|
||||
}],
|
||||
returns: {
|
||||
type: 'Array',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getLastEntries`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getLastEntries = async filter => {
|
||||
let where = filter.where;
|
||||
let query = `CALL vn.itemLastEntries(?, ?)`;
|
||||
let [lastEntries] = await Self.rawSql(query, [where.itemFk, where.date]);
|
||||
|
||||
return lastEntries;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('lastEntriesFilter', {
|
||||
description: 'Returns last entries',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'itemFk, id'
|
||||
}],
|
||||
returns: {
|
||||
type: 'Array',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/lastEntriesFilter`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.lastEntriesFilter = async filter => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const stmt = new ParameterizedSQL(
|
||||
`SELECT
|
||||
w.id AS warehouseFk,
|
||||
w.name AS warehouse,
|
||||
tr.landed,
|
||||
b.id AS buyFk,
|
||||
b.entryFk,
|
||||
b.isIgnored,
|
||||
b.price2,
|
||||
b.price3,
|
||||
b.stickers,
|
||||
b.packing,
|
||||
b.grouping,
|
||||
b.groupingMode,
|
||||
b.weight,
|
||||
i.stems,
|
||||
b.quantity,
|
||||
b.buyingValue,
|
||||
b.packageFk ,
|
||||
s.id AS supplierFk,
|
||||
s.name AS supplier
|
||||
FROM itemType it
|
||||
RIGHT JOIN (entry e
|
||||
LEFT JOIN supplier s ON s.id = e.supplierFk
|
||||
RIGHT JOIN buy b ON b.entryFk = e.id
|
||||
LEFT JOIN item i ON i.id = b.itemFk
|
||||
LEFT JOIN ink ON ink.id = i.inkFk
|
||||
LEFT JOIN travel tr ON tr.id = e.travelFk
|
||||
LEFT JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||
LEFT JOIN origin o ON o.id = i.originFk
|
||||
) ON it.id = i.typeFk
|
||||
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id`);
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
||||
return conn.executeStmt(stmt);
|
||||
};
|
||||
};
|
|
@ -1,22 +0,0 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('item getLastEntries()', () => {
|
||||
it('should return one entry for a given item', async() => {
|
||||
let date = new Date();
|
||||
let filter = {where: {itemFk: 1, date: date}};
|
||||
let result = await app.models.Item.getLastEntries(filter);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return five entries for a given item', async() => {
|
||||
let date = new Date();
|
||||
|
||||
date.setMonth(date.getMonth() - 2, 1);
|
||||
|
||||
let filter = {where: {itemFk: 1, date: date}};
|
||||
let result = await app.models.Item.getLastEntries(filter);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,24 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('item lastEntriesFilter()', () => {
|
||||
const minDate = new Date(value);
|
||||
minHour.setHours(0, 0, 0, 0);
|
||||
const maxDate = new Date(value);
|
||||
maxHour.setHours(23, 59, 59, 59);
|
||||
|
||||
it('should return one entry for a given item', async() => {
|
||||
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
|
||||
const result = await app.models.Item.lastEntriesFilter(filter);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return five entries for a given item', async() => {
|
||||
minDate.setMonth(minDate.getMonth() - 2, 1);
|
||||
|
||||
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
|
||||
const result = await app.models.Item.lastEntriesFilter(filter);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
});
|
||||
});
|
|
@ -5,7 +5,7 @@ module.exports = Self => {
|
|||
require('../methods/item/clone')(Self);
|
||||
require('../methods/item/updateTaxes')(Self);
|
||||
require('../methods/item/getBalance')(Self);
|
||||
require('../methods/item/getLastEntries')(Self);
|
||||
require('../methods/item/lastEntriesFilter')(Self);
|
||||
require('../methods/item/getSummary')(Self);
|
||||
require('../methods/item/getCard')(Self);
|
||||
require('../methods/item/regularize')(Self);
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Items/getLastEntries"
|
||||
url="Items/lastEntriesFilter"
|
||||
filter="::$ctrl.filter"
|
||||
data="entries"
|
||||
auto-load="false">
|
||||
auto-load="true"
|
||||
order="landed DESC, buyFk DESC"
|
||||
limit="20">
|
||||
</vn-crud-model>
|
||||
<vn-vertical>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
class="vn-mb-xl vn-w-xl">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-vertical>
|
||||
<vn-horizontal>
|
||||
|
@ -20,8 +24,8 @@
|
|||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th vn-tooltip="Ignored" center>Ig</vn-th>
|
||||
<vn-th>Warehouse</vn-th>
|
||||
<vn-th>Landed</vn-th>
|
||||
<vn-th field="warehouseFk">Warehouse</vn-th>
|
||||
<vn-th field="landed">Landed</vn-th>
|
||||
<vn-th number>Entry</vn-th>
|
||||
<vn-th number vn-tooltip="Price Per Unit">P.P.U</vn-th>
|
||||
<vn-th number vn-tooltip="Price Per Package">P.P.P</vn-th>
|
||||
|
@ -29,11 +33,11 @@
|
|||
<vn-th number>Packing</vn-th>
|
||||
<vn-th number>Grouping</vn-th>
|
||||
<vn-th number class="expendable">Stems</vn-th>
|
||||
<vn-th number>Quantity</vn-th>
|
||||
<vn-th field="quantity" number>Quantity</vn-th>
|
||||
<vn-th number class="expendable">Cost</vn-th>
|
||||
<vn-th number>Kg.</vn-th>
|
||||
<vn-th number>Cube</vn-th>
|
||||
<vn-th class="expendable">Provider</vn-th>
|
||||
<vn-th field="packageFk" number>Cube</vn-th>
|
||||
<vn-th field="supplierFk" class="expendable">Provider</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
|
@ -70,6 +74,30 @@
|
|||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-vertical>
|
||||
<vn-pagination model="model"></vn-pagination>
|
||||
</vn-card>
|
||||
</vn-vertical>
|
||||
</vn-data-viewer>
|
||||
|
||||
<vn-contextmenu vn-id="contextmenu" targets="['vn-data-viewer']" model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
<slot-menu>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.filterBySelection()">
|
||||
Filter by selection
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.excludeSelection()">
|
||||
Exclude selection
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.removeFilter()" >
|
||||
Remove filter
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-click="contextmenu.removeAllFilters()" >
|
||||
Remove all filters
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
</vn-contextmenu>
|
|
@ -6,17 +6,23 @@ class Controller extends Section {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
let defaultDate = new Date();
|
||||
defaultDate.setDate(defaultDate.getDate() - 75);
|
||||
defaultDate.setHours(0, 0, 0, 0);
|
||||
const from = new Date();
|
||||
from.setDate(from.getDate() - 75);
|
||||
from.setHours(0, 0, 0, 0);
|
||||
|
||||
const to = new Date();
|
||||
to.setDate(to.getDate() + 10);
|
||||
to.setHours(23, 59, 59, 59);
|
||||
|
||||
this.filter = {
|
||||
where: {
|
||||
itemFk: this.$params.id,
|
||||
date: defaultDate
|
||||
shipped: {
|
||||
between: [from, to]
|
||||
}
|
||||
}
|
||||
};
|
||||
this._date = defaultDate;
|
||||
this._date = from;
|
||||
}
|
||||
|
||||
set date(value) {
|
||||
|
@ -31,6 +37,32 @@ class Controller extends Section {
|
|||
get date() {
|
||||
return this._date;
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'id':
|
||||
case 'quantity':
|
||||
case 'packageFk':
|
||||
return {[`b.${param}`]: value};
|
||||
case 'supplierFk':
|
||||
return {[`s.id`]: value};
|
||||
case 'warehouseFk':
|
||||
return {'tr.warehouseInFk': value};
|
||||
case 'landed':
|
||||
return {'tr.landed': {
|
||||
between: this.dateRange(value)}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
dateRange(value) {
|
||||
const minHour = new Date(value);
|
||||
minHour.setHours(0, 0, 0, 0);
|
||||
const maxHour = new Date(value);
|
||||
maxHour.setHours(23, 59, 59, 59);
|
||||
|
||||
return [minHour, maxHour];
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope'];
|
||||
|
|
Loading…
Reference in New Issue