#2224item.diary provar directiva $anchorScroll
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
71b0f38b53
commit
8453d25852
|
@ -15,8 +15,8 @@ proc: BEGIN
|
||||||
DECLARE vWarehouseFk SMALLINT;
|
DECLARE vWarehouseFk SMALLINT;
|
||||||
DECLARE vAgencyModeFk INT;
|
DECLARE vAgencyModeFk INT;
|
||||||
DECLARE vAddressFk INT;
|
DECLARE vAddressFk INT;
|
||||||
DECLARE vTicket BIGINT;
|
DECLARE vTicketFk BIGINT;
|
||||||
DECLARE vItem BIGINT;
|
DECLARE vItemFk BIGINT;
|
||||||
DECLARE vLanded DATE;
|
DECLARE vLanded DATE;
|
||||||
DECLARE vIsEditable BOOLEAN;
|
DECLARE vIsEditable BOOLEAN;
|
||||||
DECLARE vZoneFk INTEGER;
|
DECLARE vZoneFk INTEGER;
|
||||||
|
@ -31,8 +31,8 @@ proc: BEGIN
|
||||||
t.agencyModeFk,
|
t.agencyModeFk,
|
||||||
t.landed
|
t.landed
|
||||||
INTO vIsEditable,
|
INTO vIsEditable,
|
||||||
vTicket,
|
vTicketFk,
|
||||||
vItem,
|
vItemFk,
|
||||||
vZoneFk,
|
vZoneFk,
|
||||||
vWarehouseFk,
|
vWarehouseFk,
|
||||||
vShipped,
|
vShipped,
|
||||||
|
@ -69,13 +69,13 @@ proc: BEGIN
|
||||||
-- rellena la tabla buyUltimate con la ultima compra
|
-- rellena la tabla buyUltimate con la ultima compra
|
||||||
CALL buyUltimate (vWarehouseFk, vShipped);
|
CALL buyUltimate (vWarehouseFk, vShipped);
|
||||||
|
|
||||||
DELETE FROM tmp.buyUltimate WHERE itemFk != vItem;
|
DELETE FROM tmp.buyUltimate WHERE itemFk != vItemFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
||||||
CREATE TEMPORARY TABLE tmp.ticketLot
|
CREATE TEMPORARY TABLE tmp.ticketLot
|
||||||
SELECT vWarehouseFk warehouseFk, NULL available, vItem itemFk, buyFk, vZoneFk zoneFk
|
SELECT vWarehouseFk warehouseFk, NULL available, vItemFk itemFk, buyFk, vZoneFk zoneFk
|
||||||
FROM tmp.buyUltimate
|
FROM tmp.buyUltimate
|
||||||
WHERE itemFk = vItem;
|
WHERE itemFk = vItemFk;
|
||||||
|
|
||||||
CALL catalog_componentPrepare();
|
CALL catalog_componentPrepare();
|
||||||
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
|
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
|
||||||
|
@ -92,7 +92,7 @@ proc: BEGIN
|
||||||
CALL ticketComponentUpdateSale(vOption);
|
CALL ticketComponentUpdateSale(vOption);
|
||||||
|
|
||||||
INSERT INTO ticketLog (originFk, userFk, `action`, description)
|
INSERT INTO ticketLog (originFk, userFk, `action`, description)
|
||||||
VALUES (vTicket, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale));
|
VALUES (vTicketFk, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale));
|
||||||
|
|
||||||
CALL catalog_componentPurge();
|
CALL catalog_componentPurge();
|
||||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
DROP procedure IF EXISTS `vn`.`item_getBalance`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
USE `vn`$$
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `item_getBalance`(IN vItemId INT, IN vWarehouse INT)
|
||||||
|
BEGIN
|
||||||
|
DECLARE vDateInventory DATETIME;
|
||||||
|
DECLARE vCurdate DATE DEFAULT CURDATE();
|
||||||
|
DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate);
|
||||||
|
|
||||||
|
SELECT inventoried INTO vDateInventory FROM config;
|
||||||
|
SET @a = 0;
|
||||||
|
SET @currentLineFk = 0;
|
||||||
|
SET @shipped = '';
|
||||||
|
|
||||||
|
SELECT DATE(@shipped:= shipped) shipped,
|
||||||
|
alertLevel,
|
||||||
|
stateName,
|
||||||
|
origin,
|
||||||
|
reference,
|
||||||
|
clientFk,
|
||||||
|
name,
|
||||||
|
`in`,
|
||||||
|
`out`,
|
||||||
|
@a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance,
|
||||||
|
@currentLineFk := IF (@shipped < CURDATE()
|
||||||
|
OR (@shipped = CURDATE() AND (isPicked OR alertLevel >= 2)),
|
||||||
|
lineFk,@currentLineFk) lastPreparedLineFk,
|
||||||
|
isTicket,
|
||||||
|
lineFk,isPicked
|
||||||
|
FROM
|
||||||
|
( SELECT tr.landed as shipped,
|
||||||
|
b.quantity as `in`,
|
||||||
|
NULL as `out`,
|
||||||
|
al.alertLevel as alertLevel,
|
||||||
|
st.name AS stateName,
|
||||||
|
s.name as name,
|
||||||
|
e.ref as reference,
|
||||||
|
e.id as origin,
|
||||||
|
s.id as clientFk,
|
||||||
|
IF(al.alertLevel = 3, TRUE, FALSE) isPicked,
|
||||||
|
FALSE AS isTicket,
|
||||||
|
b.id lineFk,
|
||||||
|
NULL `order`
|
||||||
|
FROM buy b
|
||||||
|
JOIN entry e ON e.id = b.entryFk
|
||||||
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
|
JOIN supplier s ON s.id = e.supplierFk
|
||||||
|
JOIN alertLevel al ON al.alertLevel =
|
||||||
|
CASE
|
||||||
|
WHEN tr.shipped < CURDATE() THEN 3
|
||||||
|
WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3
|
||||||
|
ELSE 0
|
||||||
|
END
|
||||||
|
JOIN state st ON st.code = al.code
|
||||||
|
WHERE tr.landed >= vDateInventory
|
||||||
|
AND vWarehouse = tr.warehouseInFk
|
||||||
|
AND b.itemFk = vItemId
|
||||||
|
AND e.isInventory = FALSE
|
||||||
|
AND e.isRaid = FALSE
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT tr.shipped,
|
||||||
|
NULL as `in`,
|
||||||
|
b.quantity as `out`,
|
||||||
|
al.alertLevel as alertLevel,
|
||||||
|
st.name AS stateName,
|
||||||
|
s.name as name,
|
||||||
|
e.ref as reference,
|
||||||
|
e.id as origin,
|
||||||
|
s.id as clientFk,
|
||||||
|
IF(al.alertLevel = 3, TRUE, FALSE) isPicked,
|
||||||
|
FALSE AS isTicket,
|
||||||
|
b.id,
|
||||||
|
NULL `order`
|
||||||
|
FROM buy b
|
||||||
|
JOIN entry e ON e.id = b.entryFk
|
||||||
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
|
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
||||||
|
JOIN supplier s ON s.id = e.supplierFk
|
||||||
|
JOIN alertLevel al ON al.alertLevel =
|
||||||
|
CASE
|
||||||
|
WHEN tr.shipped < CURDATE() THEN 3
|
||||||
|
WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3
|
||||||
|
ELSE 0
|
||||||
|
END
|
||||||
|
JOIN state st ON st.code = al.code
|
||||||
|
WHERE tr.shipped >= vDateInventory
|
||||||
|
AND vWarehouse =tr.warehouseOutFk
|
||||||
|
AND s.id <> 4
|
||||||
|
AND b.itemFk = vItemId
|
||||||
|
AND e.isInventory = FALSE
|
||||||
|
AND w.isFeedStock = FALSE
|
||||||
|
AND e.isRaid = FALSE
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT DATE(t.shipped),
|
||||||
|
NULL as `in`,
|
||||||
|
s.quantity as `out`,
|
||||||
|
al.alertLevel as alertLevel,
|
||||||
|
st.name AS stateName,
|
||||||
|
t.nickname as name,
|
||||||
|
t.refFk as reference,
|
||||||
|
t.id as origin,
|
||||||
|
t.clientFk,
|
||||||
|
stk.id as isPicked,
|
||||||
|
TRUE as isTicket,
|
||||||
|
s.id,
|
||||||
|
st.`order`
|
||||||
|
FROM sale s
|
||||||
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
|
LEFT JOIN ticketState ts ON ts.ticket = t.id
|
||||||
|
LEFT JOIN state st ON st.code = ts.code
|
||||||
|
JOIN client c ON c.id = t.clientFk
|
||||||
|
JOIN alertLevel al ON al.alertLevel =
|
||||||
|
CASE
|
||||||
|
WHEN t.shipped < curdate() THEN 3
|
||||||
|
WHEN t.shipped > util.dayEnd(curdate()) THEN 0
|
||||||
|
ELSE IFNULL(ts.alertLevel, 0)
|
||||||
|
END
|
||||||
|
LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
|
||||||
|
LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id
|
||||||
|
WHERE t.shipped >= vDateInventory
|
||||||
|
AND s.itemFk = vItemId
|
||||||
|
AND vWarehouse =t.warehouseFk
|
||||||
|
ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC
|
||||||
|
) AS itemDiary;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
delimiter ;
|
|
@ -354,7 +354,7 @@ export default {
|
||||||
firstSaleItemId: 'vn-ticket-summary [name="sales"] vn-table vn-tbody > :nth-child(1) > vn-td:nth-child(2) > span',
|
firstSaleItemId: 'vn-ticket-summary [name="sales"] vn-table vn-tbody > :nth-child(1) > vn-td:nth-child(2) > span',
|
||||||
firstSaleDescriptorImage: '.vn-popover.shown vn-item-descriptor img',
|
firstSaleDescriptorImage: '.vn-popover.shown vn-item-descriptor img',
|
||||||
itemDescriptorPopover: '.vn-popover.shown vn-item-descriptor',
|
itemDescriptorPopover: '.vn-popover.shown vn-item-descriptor',
|
||||||
itemDescriptorPopoverItemDiaryButton: 'vn-item-descriptor a[href="#!/item/2/diary?warehouseFk=5&ticketFk=20"]',
|
itemDescriptorPopoverItemDiaryButton: 'vn-item-descriptor a[href="#!/item/2/diary?warehouseFk=5&lineFk=16"]',
|
||||||
popoverDiaryButton: '.vn-popover.shown vn-item-descriptor vn-icon[icon="icon-transaction"]',
|
popoverDiaryButton: '.vn-popover.shown vn-item-descriptor vn-icon[icon="icon-transaction"]',
|
||||||
firstSaleQuantity: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3)',
|
firstSaleQuantity: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3)',
|
||||||
firstSaleDiscount: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6)',
|
firstSaleDiscount: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6)',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
import selectors from '../../helpers/selectors.js';
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
// #2221 Local MySQL8 crashes when rest method Items/getDiary is called
|
// #2221 Local MySQL8 crashes when rest method Items/getBalance is called
|
||||||
xdescribe('Ticket diary path', () => {
|
xdescribe('Ticket diary path', () => {
|
||||||
let page;
|
let page;
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
<vn-tr ng-repeat="saleClaimed in $ctrl.summary.salesClaimed">
|
<vn-tr ng-repeat="saleClaimed in $ctrl.summary.salesClaimed">
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
ng-click="$ctrl.showItemDescriptor($event, saleClaimed.sale.itemFk)"
|
ng-click="$ctrl.showItemDescriptor($event, saleClaimed.sale)"
|
||||||
class="link">
|
class="link">
|
||||||
{{::saleClaimed.sale.itemFk | zeroFill:6}}
|
{{::saleClaimed.sale.itemFk | zeroFill:6}}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -33,8 +33,8 @@ class Controller extends Section {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showItemDescriptor(event, itemFk) {
|
showItemDescriptor(event, sale) {
|
||||||
this.$.itemDescriptor.itemFk = itemFk;
|
this.$.itemDescriptor.itemFk = sale.itemFk;
|
||||||
this.$.itemDescriptor.parent = event.target;
|
this.$.itemDescriptor.parent = event.target;
|
||||||
this.$.itemDescriptor.show();
|
this.$.itemDescriptor.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('getDiary', {
|
Self.remoteMethod('getBalance', {
|
||||||
description: 'Returns the ',
|
description: 'Returns the ',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
|
@ -14,14 +14,14 @@ module.exports = Self => {
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
path: `/getDiary`,
|
path: `/getBalance`,
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.getDiary = async filter => {
|
Self.getBalance = async filter => {
|
||||||
let where = filter.where;
|
let where = filter.where;
|
||||||
let [diary] = await Self.rawSql(`CALL vn.itemDiary(?, ?)`, [where.itemFk, where.warehouseFk]);
|
let [diary] = await Self.rawSql(`CALL vn.item_getBalance(?, ?)`, [where.itemFk, where.warehouseFk]);
|
||||||
return diary;
|
return diary;
|
||||||
};
|
};
|
||||||
};
|
};
|
|
@ -1,9 +1,9 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('item getDiary()', () => {
|
describe('item getBalance()', () => {
|
||||||
it('should check the property balance of the 4 resultant entries', async() => {
|
it('should check the property balance of the 4 resultant entries', async() => {
|
||||||
let params = {where: {itemFk: 1, warehouseFk: 2}};
|
let params = {where: {itemFk: 1, warehouseFk: 2}};
|
||||||
let result = await app.models.Item.getDiary(params);
|
let result = await app.models.Item.getBalance(params);
|
||||||
|
|
||||||
expect(result.length).toBe(4);
|
expect(result.length).toBe(4);
|
||||||
expect(result[0].balance).toBe(-100);
|
expect(result[0].balance).toBe(-100);
|
||||||
|
|
|
@ -4,7 +4,7 @@ module.exports = Self => {
|
||||||
require('../methods/item/filter')(Self);
|
require('../methods/item/filter')(Self);
|
||||||
require('../methods/item/clone')(Self);
|
require('../methods/item/clone')(Self);
|
||||||
require('../methods/item/updateTaxes')(Self);
|
require('../methods/item/updateTaxes')(Self);
|
||||||
require('../methods/item/getDiary')(Self);
|
require('../methods/item/getBalance')(Self);
|
||||||
require('../methods/item/getLastEntries')(Self);
|
require('../methods/item/getLastEntries')(Self);
|
||||||
require('../methods/item/getSummary')(Self);
|
require('../methods/item/getSummary')(Self);
|
||||||
require('../methods/item/getCard')(Self);
|
require('../methods/item/getCard')(Self);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="Items/getDiary"
|
url="Items/getBalance"
|
||||||
filter="$ctrl.filter"
|
filter="$ctrl.filter"
|
||||||
data="sales"
|
data="sales"
|
||||||
auto-load="false">
|
auto-load="false">
|
||||||
|
@ -39,11 +39,12 @@
|
||||||
'balanceNegative': sale.balance < 0}"
|
'balanceNegative': sale.balance < 0}"
|
||||||
ng-repeat="sale in sales"
|
ng-repeat="sale in sales"
|
||||||
vn-repeat-last
|
vn-repeat-last
|
||||||
on-last="$ctrl.scrollToLine()">
|
on-last="$ctrl.scrollToLine(sale.lastPreparedLineFk)"
|
||||||
|
ng-attr-id="vnItemDiary-{{::sale.lineFk}}">
|
||||||
<vn-td expand>
|
<vn-td expand>
|
||||||
<span class="chip"
|
<span class="chip"
|
||||||
ng-class="::{warning: $ctrl.isToday(sale.date)}">
|
ng-class="::{warning: $ctrl.today == sale.shipped}">
|
||||||
{{::sale.date | date:'dd/MM/yyyy' }}
|
{{::sale.shipped | date:'dd/MM/yyyy' }}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
|
@ -66,7 +67,8 @@
|
||||||
<vn-td number class="in">{{::sale.in | dashIfEmpty}}</vn-td>
|
<vn-td number class="in">{{::sale.in | dashIfEmpty}}</vn-td>
|
||||||
<vn-td number>{{::sale.out | dashIfEmpty}}</vn-td>
|
<vn-td number>{{::sale.out | dashIfEmpty}}</vn-td>
|
||||||
<vn-td number class="balance">
|
<vn-td number class="balance">
|
||||||
<span class="chip balanceSpan">
|
<span class="chip balanceSpan"
|
||||||
|
ng-class="::{message: sale.lineFk == sale.lastPreparedLineFk}">
|
||||||
{{::sale.balance | dashIfEmpty}}
|
{{::sale.balance | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
|
|
@ -3,6 +3,15 @@ import Section from 'salix/components/section';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
|
constructor($element, $scope, $anchorScroll, $location) {
|
||||||
|
super($element, $scope);
|
||||||
|
this.$anchorScroll = $anchorScroll;
|
||||||
|
this.$location = $location;
|
||||||
|
let today = new Date();
|
||||||
|
today.setHours(0, 0, 0, 0);
|
||||||
|
this.today = today.toJSON();
|
||||||
|
}
|
||||||
|
|
||||||
get item() {
|
get item() {
|
||||||
return this._item;
|
return this._item;
|
||||||
}
|
}
|
||||||
|
@ -20,8 +29,8 @@ class Controller extends Section {
|
||||||
else if (value)
|
else if (value)
|
||||||
this.warehouseFk = value.itemType.warehouseFk;
|
this.warehouseFk = value.itemType.warehouseFk;
|
||||||
|
|
||||||
if (this.$params.ticketFk)
|
if (this.$params.lineFk)
|
||||||
this.ticketFk = this.$params.ticketFk;
|
this.lineFk = this.$params.lineFk;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,96 +51,11 @@ class Controller extends Section {
|
||||||
return this._warehouseFk;
|
return this._warehouseFk;
|
||||||
}
|
}
|
||||||
|
|
||||||
get freeLineIndex() {
|
scrollToLine(lineFk) {
|
||||||
let lines = this.$.model.data;
|
const hashFk = this.lineFk || lineFk;
|
||||||
let minDate = new Date();
|
const hash = `vnItemDiary-${hashFk}`;
|
||||||
minDate.setHours(0, 0, 0, 0);
|
this.$location.hash(hash);
|
||||||
|
this.$anchorScroll();
|
||||||
let maxDate = new Date();
|
|
||||||
maxDate.setHours(23, 59, 59, 59);
|
|
||||||
|
|
||||||
for (let i = 0; i < lines.length; i++) {
|
|
||||||
const dated = new Date(lines[i].date);
|
|
||||||
|
|
||||||
let isForFuture = dated > maxDate;
|
|
||||||
let isForToday = (dated >= minDate && dated <= maxDate);
|
|
||||||
if (isForFuture || isForToday)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get onPreparationLineIndex() {
|
|
||||||
let lines = this.$.model.data;
|
|
||||||
for (let i = this.freeLineIndex; i >= 0; i--) {
|
|
||||||
let line = lines[i];
|
|
||||||
|
|
||||||
let currentDate = new Date();
|
|
||||||
currentDate.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
let isPastDate = new Date(lines[i].date) < currentDate;
|
|
||||||
let isPicked = line.alertLevel == 1 && line.isPicked;
|
|
||||||
|
|
||||||
if ((isPicked) || line.alertLevel > 1 || isPastDate)
|
|
||||||
return i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get givenTicketIndex() {
|
|
||||||
let lines = this.$.model.data;
|
|
||||||
|
|
||||||
for (let i = lines.length - 1; i > 0; i--) {
|
|
||||||
let line = lines[i];
|
|
||||||
|
|
||||||
if (line.origin == this.ticketFk)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollToLine() {
|
|
||||||
let body = this.$window.document.body;
|
|
||||||
let selectedTicketLineIndex = this.givenTicketIndex;
|
|
||||||
let lineIndex = this.onPreparationLineIndex;
|
|
||||||
|
|
||||||
let lines = body.querySelector('vn-tbody').children;
|
|
||||||
|
|
||||||
if (lineIndex == undefined || !lines.length) return;
|
|
||||||
|
|
||||||
let onPreparationLine = lines[lineIndex];
|
|
||||||
|
|
||||||
let balance = onPreparationLine.querySelector('.balanceSpan');
|
|
||||||
balance.classList.add('message');
|
|
||||||
balance.title = this.$translate.instant('Visible quantity');
|
|
||||||
|
|
||||||
let headerOffset = body.querySelector('vn-topbar').getBoundingClientRect();
|
|
||||||
let headerHeight = headerOffset.height;
|
|
||||||
|
|
||||||
let offsetTop;
|
|
||||||
if (this.ticketFk) {
|
|
||||||
let selectedTicketLine = lines[selectedTicketLineIndex];
|
|
||||||
let id = selectedTicketLine.querySelector('[name=origin]');
|
|
||||||
id.classList.add('message');
|
|
||||||
offsetTop = selectedTicketLine.offsetTop - headerHeight;
|
|
||||||
} else
|
|
||||||
offsetTop = onPreparationLine.offsetTop - headerHeight;
|
|
||||||
|
|
||||||
this.$window.scrollTo(0, offsetTop);
|
|
||||||
this.ticketFk = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares a date with the current one
|
|
||||||
* @param {Object} date - Date to compare
|
|
||||||
* @return {Boolean} - Returns true if the two dates equals
|
|
||||||
*/
|
|
||||||
isToday(date) {
|
|
||||||
let today = new Date();
|
|
||||||
today.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
let comparedDate = new Date(date);
|
|
||||||
comparedDate.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
if (!(today - comparedDate))
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showDescriptor(event, sale) {
|
showDescriptor(event, sale) {
|
||||||
|
@ -159,6 +83,8 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location'];
|
||||||
|
|
||||||
ngModule.component('vnItemDiary', {
|
ngModule.component('vnItemDiary', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
controller: Controller,
|
controller: Controller,
|
||||||
|
|
|
@ -16,56 +16,6 @@ describe('Item', () => {
|
||||||
controller.$params = {id: 1};
|
controller.$params = {id: 1};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('isToday()', () => {
|
|
||||||
it(`should call isToday() an return true if an specified date is the current date`, () => {
|
|
||||||
let date = new Date();
|
|
||||||
|
|
||||||
let result = controller.isToday(date);
|
|
||||||
|
|
||||||
expect(result).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should call isToday() an return false if an specified date is the current date`, () => {
|
|
||||||
let date = '2018-07-03';
|
|
||||||
|
|
||||||
let result = controller.isToday(date);
|
|
||||||
|
|
||||||
expect(result).toBeFalsy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('freeLineIndex()', () => {
|
|
||||||
it(`should call freeLineIndex() and return an index from line with alertLevel 0 and current date`, () => {
|
|
||||||
let currentDate = new Date();
|
|
||||||
currentDate.setDate(currentDate.getDate() + 1);
|
|
||||||
|
|
||||||
controller.$.model = {data: [
|
|
||||||
{name: 'My item 1', alertLevel: 3, date: '2018-05-02'},
|
|
||||||
{name: 'My item 2', alertLevel: 1, date: '2018-05-03'},
|
|
||||||
{name: 'My item 3', alertLevel: 0, date: currentDate}]
|
|
||||||
};
|
|
||||||
let result = controller.freeLineIndex;
|
|
||||||
|
|
||||||
expect(result).toEqual(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onPreparationLineIndex()', () => {
|
|
||||||
it(`should call onPreparationLineIndex() and return an index from line with alertLevel 1 and isPicked true`, () => {
|
|
||||||
let currentDate = new Date();
|
|
||||||
currentDate.setDate(currentDate.getDate() + 1);
|
|
||||||
controller.$.model = {data: [
|
|
||||||
{name: 'My item 1', alertLevel: 3, isPicked: true, date: currentDate},
|
|
||||||
{name: 'My item 3', alertLevel: 1, isPicked: true, date: currentDate},
|
|
||||||
{name: 'My item 4', alertLevel: 1, isPicked: false, date: currentDate},
|
|
||||||
{name: 'My item 5', alertLevel: 0, isPicked: false, date: currentDate}]
|
|
||||||
};
|
|
||||||
let result = controller.onPreparationLineIndex;
|
|
||||||
|
|
||||||
expect(result).toEqual(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('set item()', () => {
|
describe('set item()', () => {
|
||||||
it('should set warehouseFk property based on itemType warehouseFk', () => {
|
it('should set warehouseFk property based on itemType warehouseFk', () => {
|
||||||
jest.spyOn(controller.$, '$applyAsync');
|
jest.spyOn(controller.$, '$applyAsync');
|
||||||
|
@ -90,21 +40,6 @@ describe('Item', () => {
|
||||||
expect(controller.item.id).toEqual(1);
|
expect(controller.item.id).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('givenTicketIndex() setter', () => {
|
|
||||||
it(`should return the index position of the line of a given ticket fk`, () => {
|
|
||||||
controller.$.model = {data: [
|
|
||||||
{name: 'My item 1', origin: 1, alertLevel: 3, isPicked: true, date: '2018-05-02'},
|
|
||||||
{name: 'My item 3', origin: 2, alertLevel: 1, isPicked: true, date: '2018-05-03'},
|
|
||||||
{name: 'My item 4', origin: 3, alertLevel: 1, isPicked: false, date: '2018-05-03'}]
|
|
||||||
};
|
|
||||||
controller.ticketFk = 2;
|
|
||||||
|
|
||||||
let index = controller.givenTicketIndex;
|
|
||||||
|
|
||||||
expect(controller.$.model.data[index].origin).toEqual(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@
|
||||||
"item": "$ctrl.item"
|
"item": "$ctrl.item"
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"url" : "/diary?warehouseFk&ticketFk",
|
"url" : "/diary?warehouseFk&lineFk",
|
||||||
"state": "item.card.diary",
|
"state": "item.card.diary",
|
||||||
"component": "vn-item-diary",
|
"component": "vn-item-diary",
|
||||||
"description": "Diary",
|
"description": "Diary",
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<tr style="height: initial;">
|
<tr style="height: initial;">
|
||||||
<td rowspan="{{::sale.components.length + 1}}" number>
|
<td rowspan="{{::sale.components.length + 1}}" number>
|
||||||
<span
|
<span
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, sale)"
|
||||||
class="link">
|
class="link">
|
||||||
{{sale.itemFk | zeroFill:6}}
|
{{sale.itemFk | zeroFill:6}}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -47,19 +47,19 @@ class Controller extends Section {
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
showDescriptor(event, itemFk) {
|
showDescriptor(event, sale) {
|
||||||
this.quicklinks = {
|
this.quicklinks = {
|
||||||
btnThree: {
|
btnThree: {
|
||||||
icon: 'icon-transaction',
|
icon: 'icon-transaction',
|
||||||
state: `item.card.diary({
|
state: `item.card.diary({
|
||||||
id: ${itemFk},
|
id: ${sale.itemFk},
|
||||||
warehouseFk: ${this.ticket.warehouseFk},
|
warehouseFk: ${this.ticket.warehouseFk},
|
||||||
ticketFk: ${this.ticket.id}
|
lineFk: ${sale.id}
|
||||||
})`,
|
})`,
|
||||||
tooltip: 'Item diary'
|
tooltip: 'Item diary'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$.descriptor.itemFk = itemFk;
|
this.$.descriptor.itemFk = sale.itemFk;
|
||||||
this.$.descriptor.parent = event.target;
|
this.$.descriptor.parent = event.target;
|
||||||
this.$.descriptor.show();
|
this.$.descriptor.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,20 +15,8 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showItemDescriptor(event, itemFk) {
|
showItemDescriptor(event, sale) {
|
||||||
if (!itemFk) return;
|
this.$.itemDescriptor.itemFk = sale.itemFk;
|
||||||
this.quicklinks = {
|
|
||||||
btnThree: {
|
|
||||||
icon: 'icon-transaction',
|
|
||||||
state: `item.card.diary({
|
|
||||||
id: ${itemFk},
|
|
||||||
warehouseFk: ${this.ticket.warehouseFk},
|
|
||||||
ticketFk: ${this.ticket.id}
|
|
||||||
})`,
|
|
||||||
tooltip: 'Item diary',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
this.$.itemDescriptor.itemFk = itemFk;
|
|
||||||
this.$.itemDescriptor.parent = event.target;
|
this.$.itemDescriptor.parent = event.target;
|
||||||
this.$.itemDescriptor.show();
|
this.$.itemDescriptor.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
ng-show="::request.saleFk"
|
ng-show="::request.saleFk"
|
||||||
ng-click="$ctrl.showItemDescriptor($event, request.sale.itemFk)"
|
ng-click="$ctrl.showItemDescriptor($event, request.sale)"
|
||||||
class="link">
|
class="link">
|
||||||
{{::request.saleFk | zeroFill:6}}
|
{{::request.saleFk | zeroFill:6}}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -44,18 +44,18 @@ class Controller extends Section {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showItemDescriptor(event, itemFk) {
|
showItemDescriptor(event, sale) {
|
||||||
this.quicklinks = {
|
this.quicklinks = {
|
||||||
btnThree: {
|
btnThree: {
|
||||||
icon: 'icon-transaction',
|
icon: 'icon-transaction',
|
||||||
state: `item.card.diary({
|
state: `item.card.diary({
|
||||||
id: ${itemFk},
|
id: ${sale.itemFk},
|
||||||
ticketFk: ${this.$params.id}
|
lineFk: ${sale.id}
|
||||||
})`,
|
})`,
|
||||||
tooltip: 'Item diary'
|
tooltip: 'Item diary'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$.itemDescriptor.itemFk = itemFk;
|
this.$.itemDescriptor.itemFk = sale.itemFk;
|
||||||
this.$.itemDescriptor.parent = event.target;
|
this.$.itemDescriptor.parent = event.target;
|
||||||
this.$.itemDescriptor.show();
|
this.$.itemDescriptor.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, sale)"
|
||||||
class="link">
|
class="link">
|
||||||
{{::sale.itemFk | zeroFill:6}}
|
{{::sale.itemFk | zeroFill:6}}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -17,19 +17,19 @@ class Controller extends Section {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
showDescriptor(event, itemFk) {
|
showDescriptor(event, sale) {
|
||||||
this.quicklinks = {
|
this.quicklinks = {
|
||||||
btnThree: {
|
btnThree: {
|
||||||
icon: 'icon-transaction',
|
icon: 'icon-transaction',
|
||||||
state: `item.card.diary({
|
state: `item.card.diary({
|
||||||
id: ${itemFk},
|
id: ${sale.itemFk},
|
||||||
warehouseFk: ${this.ticket.warehouseFk},
|
warehouseFk: ${this.ticket.warehouseFk},
|
||||||
ticketFk: ${this.ticket.id}
|
lineFk: ${sale.id}
|
||||||
})`,
|
})`,
|
||||||
tooltip: 'Item diary'
|
tooltip: 'Item diary'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$.descriptor.itemFk = itemFk;
|
this.$.descriptor.itemFk = sale.itemFk;
|
||||||
this.$.descriptor.parent = event.target;
|
this.$.descriptor.parent = event.target;
|
||||||
this.$.descriptor.show();
|
this.$.descriptor.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
ng-click="$ctrl.showItemDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showItemDescriptor($event, sale)"
|
||||||
class="link">
|
class="link">
|
||||||
{{sale.itemFk | zeroFill:6}}
|
{{sale.itemFk | zeroFill:6}}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -2,19 +2,19 @@ import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
showItemDescriptor(event, itemFk) {
|
showItemDescriptor(event, sale) {
|
||||||
this.quicklinks = {
|
this.quicklinks = {
|
||||||
btnThree: {
|
btnThree: {
|
||||||
icon: 'icon-transaction',
|
icon: 'icon-transaction',
|
||||||
state: `item.card.diary({
|
state: `item.card.diary({
|
||||||
id: ${itemFk},
|
id: ${sale.itemFk},
|
||||||
warehouseFk: ${this.ticket.warehouseFk},
|
warehouseFk: ${this.ticket.warehouseFk},
|
||||||
ticketFk: ${this.ticket.id}
|
lineFk: ${sale.id}
|
||||||
})`,
|
})`,
|
||||||
tooltip: 'Item diary',
|
tooltip: 'Item diary',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
this.$.itemDescriptor.itemFk = itemFk;
|
this.$.itemDescriptor.itemFk = sale.itemFk;
|
||||||
this.$.itemDescriptor.parent = event.target;
|
this.$.itemDescriptor.parent = event.target;
|
||||||
this.$.itemDescriptor.show();
|
this.$.itemDescriptor.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td vn-focus number>
|
<vn-td vn-focus number>
|
||||||
<span class="link" ng-if="sale.id"
|
<span class="link" ng-if="sale.id"
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)">
|
ng-click="$ctrl.showDescriptor($event, sale)">
|
||||||
{{sale.itemFk}}
|
{{sale.itemFk}}
|
||||||
</span>
|
</span>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
|
|
@ -296,19 +296,19 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item Descriptor
|
// Item Descriptor
|
||||||
showDescriptor(event, itemFk) {
|
showDescriptor(event, sale) {
|
||||||
this.quicklinks = {
|
this.quicklinks = {
|
||||||
btnThree: {
|
btnThree: {
|
||||||
icon: 'icon-transaction',
|
icon: 'icon-transaction',
|
||||||
state: `item.card.diary({
|
state: `item.card.diary({
|
||||||
id: ${itemFk},
|
id: ${sale.itemFk},
|
||||||
warehouseFk: ${this.ticket.warehouseFk},
|
warehouseFk: ${this.ticket.warehouseFk},
|
||||||
ticketFk: ${this.ticket.id}
|
lineFk: ${sale.id}
|
||||||
})`,
|
})`,
|
||||||
tooltip: 'Item diary'
|
tooltip: 'Item diary'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$.descriptor.itemFk = itemFk;
|
this.$.descriptor.itemFk = sale.itemFk;
|
||||||
this.$.descriptor.parent = event.target;
|
this.$.descriptor.parent = event.target;
|
||||||
this.$.descriptor.show();
|
this.$.descriptor.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number shrink>
|
<vn-td number shrink>
|
||||||
<span
|
<span
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, sale)"
|
||||||
class="link">
|
class="link">
|
||||||
{{sale.itemFk | zeroFill:6}}
|
{{sale.itemFk | zeroFill:6}}
|
||||||
</span>
|
</span>
|
||||||
|
@ -208,7 +208,7 @@
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
ng-show="::request.saleFk"
|
ng-show="::request.saleFk"
|
||||||
ng-click="$ctrl.showDescriptor($event, request.sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, request.sale)"
|
||||||
class="link">
|
class="link">
|
||||||
{{request.sale.itemFk | zeroFill:6}}
|
{{request.sale.itemFk | zeroFill:6}}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -44,19 +44,19 @@ class Controller extends Section {
|
||||||
this.$.routeDescriptor.show();
|
this.$.routeDescriptor.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
showDescriptor(event, itemFk) {
|
showDescriptor(event, sale) {
|
||||||
this.quicklinks = {
|
this.quicklinks = {
|
||||||
btnThree: {
|
btnThree: {
|
||||||
icon: 'icon-transaction',
|
icon: 'icon-transaction',
|
||||||
state: `item.card.diary({
|
state: `item.card.diary({
|
||||||
id: ${itemFk},
|
id: ${sale.itemFk},
|
||||||
warehouseFk: ${this.ticket.warehouseFk},
|
warehouseFk: ${this.ticket.warehouseFk},
|
||||||
ticketFk: ${this.ticket.id}
|
lineFk: ${sale.id}
|
||||||
})`,
|
})`,
|
||||||
tooltip: 'Item diary'
|
tooltip: 'Item diary'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$.descriptor.itemFk = itemFk;
|
this.$.descriptor.itemFk = sale.itemFk;
|
||||||
this.$.descriptor.parent = event.target;
|
this.$.descriptor.parent = event.target;
|
||||||
this.$.descriptor.show();
|
this.$.descriptor.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<vn-tr ng-repeat="sale in $ctrl.sales">
|
<vn-tr ng-repeat="sale in $ctrl.sales">
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, sale)"
|
||||||
class="link">
|
class="link">
|
||||||
{{sale.itemFk | zeroFill:6}}
|
{{sale.itemFk | zeroFill:6}}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -44,19 +44,19 @@ class Controller extends Section {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showDescriptor(event, itemFk) {
|
showDescriptor(event, sale) {
|
||||||
this.quicklinks = {
|
this.quicklinks = {
|
||||||
btnThree: {
|
btnThree: {
|
||||||
icon: 'icon-transaction',
|
icon: 'icon-transaction',
|
||||||
state: `item.card.diary({
|
state: `item.card.diary({
|
||||||
id: ${itemFk},
|
id: ${sale.itemFk},
|
||||||
warehouseFk: ${this.ticket.warehouseFk},
|
warehouseFk: ${this.ticket.warehouseFk},
|
||||||
ticketFk: ${this.ticket.id}
|
lineFk: ${sale.id}
|
||||||
})`,
|
})`,
|
||||||
tooltip: 'Item diary'
|
tooltip: 'Item diary'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$.descriptor.itemFk = itemFk;
|
this.$.descriptor.itemFk = sale.itemFk;
|
||||||
this.$.descriptor.parent = event.target;
|
this.$.descriptor.parent = event.target;
|
||||||
this.$.descriptor.show();
|
this.$.descriptor.show();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue