getVisible sql
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2021-12-17 12:38:56 +01:00
parent 87f994aa77
commit 850ea2ef39
6 changed files with 80 additions and 7 deletions

View File

@ -0,0 +1,50 @@
DROP PROCEDURE IF EXISTS `vn`.`ticket_getVisibleAvailable`;
DELIMITER $$
$$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticket_getVisibleAvailable`(vTicket INT, vDate DATE)
BEGIN
DECLARE vVisibleCalc INT;
DECLARE vAvailableCalc INT;
DECLARE vShipped DATE;
DECLARE vWarehouse TINYINT;
DECLARE vAlertLevel INT;
SELECT t.warehouseFk, t.shipped, ts.alertLevel
INTO vWarehouse, vShipped, vAlertLevel
FROM ticket t
LEFT JOIN ticketState ts ON ts.ticketFk = vTicket
WHERE t.id = vTicket;
IF vDate IS NULL THEN
SET vDate = vShipped;
END IF;
IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN
IF vDate >= CURDATE() THEN
CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vDate);
END IF;
IF vDate = CURDATE() THEN
CALL cache.visible_refresh(vVisibleCalc, FALSE, vWarehouse);
END IF;
END IF;
SELECT s.id,
s.itemFk,
s.quantity,
s.concept,
s.price,
s.reserved,
s.discount,
v.visible,
av.available,
it.image,
it.subName
FROM sale s
LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCalc
LEFT JOIN cache.available av ON av.item_id = s.itemFk AND av.calc_id = vAvailableCalc
LEFT JOIN item it ON it.id = s.itemFk
WHERE s.ticketFk = vTicket
ORDER BY s.concept;
END$$
DELIMITER ;

View File

@ -0,0 +1,9 @@
DROP PROCEDURE IF EXISTS vn.ticketGetVisibleAvailable;
DELIMITER $$
$$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticketGetVisibleAvailable`(vTicket INT)
BEGIN
CALL `ticket_getVisibleAvailable`(vTicket, null);
END$$
DELIMITER ;

View File

@ -1 +0,0 @@
Delete me!

View File

@ -40,6 +40,12 @@ module.exports = Self => {
type: 'number',
description: 'The warehouse id',
required: true
},
{
arg: 'shipped',
type: 'date',
description: 'shipped',
required: true
}],
returns: {
type: ['object'],
@ -101,16 +107,22 @@ module.exports = Self => {
};
// Get items visible
let query = `CALL ticketGetVisibleAvailable(?)`;
const [salesVisible] = await Self.rawSql(query, [args.id], myOptions);
let query = `CALL ticket_getVisibleAvailable(?,?)`;
let params = [args.id, args.shipped];
const [salesVisible] = await Self.rawSql(query, params, myOptions);
const itemVisible = new Map();
for (sale of salesVisible)
itemVisible.set(sale.id, sale.visible);
for (sale of salesVisible) {
let visible = sale.available;
if (visible == null)
visible = 0;
itemVisible.set(sale.id, visible);
}
// Sale price component, one per sale
query = `CALL vn.ticket_priceDifference(?, ?, ?, ?, ?)`;
const params = [args.id, args.landed, args.addressId, args.zoneId, args.warehouseId];
params = [args.id, args.landed, args.addressId, args.zoneId, args.warehouseId];
const [difComponents] = await Self.rawSql(query, params, myOptions);
const map = new Map();

View File

@ -201,7 +201,8 @@ class Controller extends Component {
addressId: this.ticket.addressFk,
agencyModeId: this.ticket.agencyModeFk,
zoneId: this.ticket.zoneFk,
warehouseId: this.ticket.warehouseFk
warehouseId: this.ticket.warehouseFk,
shipped: this.ticket.shipped
};
return this.$http.post(query, params).then(res => {

View File

@ -79,6 +79,7 @@ class Controller extends Component {
this.$t('Choose an option')
);
}
if (this.ticket.withoutNegatives) {
let salesNewTicket = [];
this.ticket.sale.items.forEach(item => {
@ -93,6 +94,7 @@ class Controller extends Component {
const query = `tickets/${this.ticket.id}/transferSales`;
this.$http.post(query, params);
}
const query = `tickets/${this.ticket.id}/componentUpdate`;
const params = {
clientFk: this.ticket.clientFk,