hotFix: not transfer all sales if all sales is negatives
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
204eb52f78
commit
b769845a28
|
@ -137,9 +137,11 @@ module.exports = Self => {
|
||||||
const params = [args.id, args.shipped, args.warehouseFk];
|
const params = [args.id, args.shipped, args.warehouseFk];
|
||||||
const [salesMovable] = await Self.rawSql(query, params, myOptions);
|
const [salesMovable] = await Self.rawSql(query, params, myOptions);
|
||||||
|
|
||||||
|
const sales = await models.Sale.find({ticketFk: args.id}, myOptions);
|
||||||
const salesNewTicket = salesMovable.filter(sale => (sale.movable ? sale.movable : 0) >= sale.quantity);
|
const salesNewTicket = salesMovable.filter(sale => (sale.movable ? sale.movable : 0) >= sale.quantity);
|
||||||
|
|
||||||
if (salesNewTicket.length) {
|
const salesNewTicketLength = salesNewTicket.length;
|
||||||
|
if (salesNewTicketLength && sales.length != salesNewTicketLength) {
|
||||||
const newTicket = await models.Ticket.transferSales(ctx, args.id, null, salesNewTicket, myOptions);
|
const newTicket = await models.Ticket.transferSales(ctx, args.id, null, salesNewTicket, myOptions);
|
||||||
args.id = newTicket.id;
|
args.id = newTicket.id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ class Controller extends Component {
|
||||||
ticketHaveNegatives() {
|
ticketHaveNegatives() {
|
||||||
let haveNegatives = false;
|
let haveNegatives = false;
|
||||||
let haveNotNegatives = false;
|
let haveNotNegatives = false;
|
||||||
|
this.ticket.withoutNegatives = false;
|
||||||
const haveDifferences = this.ticket.sale.haveDifferences;
|
const haveDifferences = this.ticket.sale.haveDifferences;
|
||||||
|
|
||||||
this.ticket.sale.items.forEach(item => {
|
this.ticket.sale.items.forEach(item => {
|
||||||
|
@ -76,8 +77,9 @@ class Controller extends Component {
|
||||||
haveNotNegatives = true;
|
haveNotNegatives = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.ticket.withoutNegatives = true;
|
|
||||||
this.haveNegatives = (haveNegatives && haveNotNegatives && haveDifferences);
|
this.haveNegatives = (haveNegatives && haveNotNegatives && haveDifferences);
|
||||||
|
if (this.haveNegatives)
|
||||||
|
this.ticket.withoutNegatives = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
|
|
Loading…
Reference in New Issue