feat(ticket_basic-data_step-two): adapted for available and transfer sales in back
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
6426a629e0
commit
b0019d09ad
|
@ -2,7 +2,7 @@ DROP PROCEDURE IF EXISTS `vn`.`ticket_getVisibleAvailable`;
|
||||||
|
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
$$
|
$$
|
||||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticket_getVisibleAvailable`(vTicket INT, vDate DATE)
|
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticket_getVisibleAvailable`(`vTicket` INT, `vDate` DATE)
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vVisibleCalc INT;
|
DECLARE vVisibleCalc INT;
|
||||||
DECLARE vAvailableCalc INT;
|
DECLARE vAvailableCalc INT;
|
|
@ -1,9 +1,10 @@
|
||||||
DROP PROCEDURE IF EXISTS vn.ticketGetVisibleAvailable;
|
DROP PROCEDURE IF EXISTS `vn`.`ticketGetVisibleAvailable`;
|
||||||
|
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
$$
|
$$
|
||||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticketGetVisibleAvailable`(vTicket INT)
|
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticketGetVisibleAvailable`(`vTicket` INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
CALL `ticket_getVisibleAvailable`(vTicket, null);
|
CALL `ticket_getVisibleAvailable`(vTicket, null);
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -216,5 +216,6 @@
|
||||||
"The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
|
"The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
|
||||||
"You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días",
|
"You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días",
|
||||||
"The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
|
"The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
|
||||||
"The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día"
|
"The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día",
|
||||||
|
"isWithoutNegatives": "Tiene Negativos"
|
||||||
}
|
}
|
|
@ -77,6 +77,12 @@ module.exports = Self => {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'Action id',
|
description: 'Action id',
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'isWithoutNegatives',
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Is whithout negatives',
|
||||||
|
required: true
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['object'],
|
type: ['object'],
|
||||||
|
@ -112,11 +118,28 @@ module.exports = Self => {
|
||||||
|
|
||||||
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss', myOptions);
|
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss', myOptions);
|
||||||
if (!isProductionBoss) {
|
if (!isProductionBoss) {
|
||||||
const zoneShipped = await models.Agency.getShipped(args.landed, args.addressFk, args.agencyModeFk, args.warehouseFk, myOptions);
|
const params = [args.landed, args.addressFk, args.agencyModeFk, args.warehouseFk];
|
||||||
|
const zoneShipped = await models.Agency.getShipped(params, myOptions);
|
||||||
|
|
||||||
if (!zoneShipped || zoneShipped.zoneFk != args.zoneFk)
|
if (!zoneShipped || zoneShipped.zoneFk != args.zoneFk)
|
||||||
throw new UserError(`You don't have privileges to change the zone`);
|
throw new UserError(`You don't have privileges to change the zone`);
|
||||||
}
|
}
|
||||||
|
if (args.isWithoutNegatives) {
|
||||||
|
let query = `CALL ticket_getVisibleAvailable(?,?)`;
|
||||||
|
let params = [args.id, args.shipped];
|
||||||
|
const [salesAvailable] = await Self.rawSql(query, params, myOptions);
|
||||||
|
|
||||||
|
let salesNewTicket = [];
|
||||||
|
salesAvailable.forEach(sale => {
|
||||||
|
if (sale.available >= sale.quantity)
|
||||||
|
salesNewTicket.push(sale);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (salesNewTicket.length) {
|
||||||
|
const newTicket = await models.Ticket.transferSales(ctx, args.id, null, salesNewTicket, myOptions);
|
||||||
|
args.id = newTicket.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const originalTicket = await models.Ticket.findOne({
|
const originalTicket = await models.Ticket.findOne({
|
||||||
where: {id: args.id},
|
where: {id: args.id},
|
||||||
|
|
|
@ -106,18 +106,18 @@ module.exports = Self => {
|
||||||
totalDifference: 0.00,
|
totalDifference: 0.00,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get items visible
|
// Get items available
|
||||||
let query = `CALL ticket_getVisibleAvailable(?,?)`;
|
let query = `CALL ticket_getVisibleAvailable(?,?)`;
|
||||||
let params = [args.id, args.shipped];
|
let params = [args.id, args.shipped];
|
||||||
const [salesVisible] = await Self.rawSql(query, params, myOptions);
|
const [salesAvailable] = await Self.rawSql(query, params, myOptions);
|
||||||
|
|
||||||
const itemVisible = new Map();
|
const itemAvailable = new Map();
|
||||||
for (sale of salesVisible) {
|
for (sale of salesAvailable) {
|
||||||
let visible = sale.available;
|
let available = sale.available;
|
||||||
if (visible == null)
|
if (available == null)
|
||||||
visible = 0;
|
available = 0;
|
||||||
|
|
||||||
itemVisible.set(sale.id, visible);
|
itemAvailable.set(sale.id, available);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sale price component, one per sale
|
// Sale price component, one per sale
|
||||||
|
@ -143,7 +143,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
salesObj.totalUnitPrice += sale.price;
|
salesObj.totalUnitPrice += sale.price;
|
||||||
salesObj.totalUnitPrice = round(salesObj.totalUnitPrice);
|
salesObj.totalUnitPrice = round(salesObj.totalUnitPrice);
|
||||||
sale.visible = itemVisible.get(sale.id);
|
sale.available = itemAvailable.get(sale.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th number>Item</vn-th>
|
<vn-th number>Item</vn-th>
|
||||||
<vn-th class="align-center">Description</vn-th>
|
<vn-th class="align-center">Description</vn-th>
|
||||||
<vn-th number>Visible</vn-th>
|
<vn-th number>Available</vn-th>
|
||||||
<vn-th number>Quantity</vn-th>
|
<vn-th number>Quantity</vn-th>
|
||||||
<vn-th number>Price (PPU)</vn-th>
|
<vn-th number>Price (PPU)</vn-th>
|
||||||
<vn-th number>New (PPU)</vn-th>
|
<vn-th number>New (PPU)</vn-th>
|
||||||
|
@ -35,8 +35,8 @@
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
class="chip"
|
class="chip"
|
||||||
ng-class="{'alert': sale.quantity>sale.visible}">
|
ng-class="{'alert': sale.quantity>sale.available}">
|
||||||
{{::sale.visible}}
|
{{::sale.available}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>{{::sale.quantity}}</vn-td>
|
<vn-td number>{{::sale.quantity}}</vn-td>
|
||||||
|
|
|
@ -66,11 +66,16 @@ class Controller extends Component {
|
||||||
|
|
||||||
ticketHaveNegatives() {
|
ticketHaveNegatives() {
|
||||||
let haveNegatives = false;
|
let haveNegatives = false;
|
||||||
|
let haveNotNegatives = false;
|
||||||
|
|
||||||
this.ticket.sale.items.forEach(item => {
|
this.ticket.sale.items.forEach(item => {
|
||||||
if (item.quantity > item.visible)
|
if (item.quantity > item.available)
|
||||||
haveNegatives = true;
|
haveNegatives = true;
|
||||||
|
else
|
||||||
|
haveNotNegatives = true;
|
||||||
});
|
});
|
||||||
this.haveNegatives = haveNegatives;
|
|
||||||
|
this.haveNegatives = (haveNegatives && haveNotNegatives);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
|
@ -80,21 +85,6 @@ class Controller extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.ticket.withoutNegatives) {
|
|
||||||
let salesNewTicket = [];
|
|
||||||
this.ticket.sale.items.forEach(item => {
|
|
||||||
if (item.visible >= item.quantity)
|
|
||||||
salesNewTicket.push(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
const params = {
|
|
||||||
sales: salesNewTicket
|
|
||||||
};
|
|
||||||
|
|
||||||
const query = `tickets/${this.ticket.id}/transferSales`;
|
|
||||||
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,
|
||||||
|
@ -107,7 +97,8 @@ class Controller extends Component {
|
||||||
shipped: this.ticket.shipped,
|
shipped: this.ticket.shipped,
|
||||||
landed: this.ticket.landed,
|
landed: this.ticket.landed,
|
||||||
isDeleted: this.ticket.isDeleted,
|
isDeleted: this.ticket.isDeleted,
|
||||||
option: parseInt(this.ticket.option)
|
option: parseInt(this.ticket.option),
|
||||||
|
isWithoutNegatives: this.ticket.withoutNegatives
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$http.post(query, params).then(res => {
|
this.$http.post(query, params).then(res => {
|
||||||
|
|
Loading…
Reference in New Issue