getVisible sql
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
87f994aa77
commit
850ea2ef39
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -1 +0,0 @@
|
||||||
Delete me!
|
|
|
@ -40,6 +40,12 @@ module.exports = Self => {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The warehouse id',
|
description: 'The warehouse id',
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'shipped',
|
||||||
|
type: 'date',
|
||||||
|
description: 'shipped',
|
||||||
|
required: true
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['object'],
|
type: ['object'],
|
||||||
|
@ -101,16 +107,22 @@ module.exports = Self => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get items visible
|
// Get items visible
|
||||||
let query = `CALL ticketGetVisibleAvailable(?)`;
|
let query = `CALL ticket_getVisibleAvailable(?,?)`;
|
||||||
const [salesVisible] = await Self.rawSql(query, [args.id], myOptions);
|
let params = [args.id, args.shipped];
|
||||||
|
const [salesVisible] = await Self.rawSql(query, params, myOptions);
|
||||||
|
|
||||||
const itemVisible = new Map();
|
const itemVisible = new Map();
|
||||||
for (sale of salesVisible)
|
for (sale of salesVisible) {
|
||||||
itemVisible.set(sale.id, sale.visible);
|
let visible = sale.available;
|
||||||
|
if (visible == null)
|
||||||
|
visible = 0;
|
||||||
|
|
||||||
|
itemVisible.set(sale.id, visible);
|
||||||
|
}
|
||||||
|
|
||||||
// Sale price component, one per sale
|
// Sale price component, one per sale
|
||||||
query = `CALL vn.ticket_priceDifference(?, ?, ?, ?, ?)`;
|
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 [difComponents] = await Self.rawSql(query, params, myOptions);
|
||||||
|
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
|
|
|
@ -201,7 +201,8 @@ class Controller extends Component {
|
||||||
addressId: this.ticket.addressFk,
|
addressId: this.ticket.addressFk,
|
||||||
agencyModeId: this.ticket.agencyModeFk,
|
agencyModeId: this.ticket.agencyModeFk,
|
||||||
zoneId: this.ticket.zoneFk,
|
zoneId: this.ticket.zoneFk,
|
||||||
warehouseId: this.ticket.warehouseFk
|
warehouseId: this.ticket.warehouseFk,
|
||||||
|
shipped: this.ticket.shipped
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.$http.post(query, params).then(res => {
|
return this.$http.post(query, params).then(res => {
|
||||||
|
|
|
@ -79,6 +79,7 @@ class Controller extends Component {
|
||||||
this.$t('Choose an option')
|
this.$t('Choose an option')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.ticket.withoutNegatives) {
|
if (this.ticket.withoutNegatives) {
|
||||||
let salesNewTicket = [];
|
let salesNewTicket = [];
|
||||||
this.ticket.sale.items.forEach(item => {
|
this.ticket.sale.items.forEach(item => {
|
||||||
|
@ -93,6 +94,7 @@ class Controller extends Component {
|
||||||
const query = `tickets/${this.ticket.id}/transferSales`;
|
const query = `tickets/${this.ticket.id}/transferSales`;
|
||||||
this.$http.post(query, params);
|
this.$http.post(query, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = `tickets/${this.ticket.id}/componentUpdate`;
|
const query = `tickets/${this.ticket.id}/componentUpdate`;
|
||||||
const params = {
|
const params = {
|
||||||
clientFk: this.ticket.clientFk,
|
clientFk: this.ticket.clientFk,
|
||||||
|
|
Loading…
Reference in New Issue