pull request changed
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-04-21 09:34:13 +02:00
parent c1edb8206e
commit 0ec51202e0
4 changed files with 12 additions and 8 deletions

View File

@ -1,6 +1,6 @@
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('deleteSalesClaimed', { Self.remoteMethodCtx('deleteClamedSales', {
description: 'Deletes the selected sales', description: 'Deletes the claimed sales',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [{ accepts: [{
arg: 'sales', arg: 'sales',
@ -13,12 +13,12 @@ module.exports = Self => {
root: true root: true
}, },
http: { http: {
path: `/deleteSalesClaimed`, path: `/deleteClamedSales`,
verb: 'POST' verb: 'POST'
} }
}); });
Self.deleteSalesClaimed = async(ctx, sales, options) => { Self.deleteClamedSales = async(ctx, sales, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
const tx = await Self.beginTransaction({}); const tx = await Self.beginTransaction({});

View File

@ -35,14 +35,18 @@ module.exports = Self => {
try { try {
const models = Self.app.models; const models = Self.app.models;
const promises = [];
for (let row of rows) { for (let row of rows) {
const claimEnd = await models.ClaimEnd.findById(row.id, null, myOptions); const claimEnd = await models.ClaimEnd.findById(row.id, null, myOptions);
await claimEnd.updateAttribute('claimDestinationFk', claimDestinationFk, myOptions); const updatedClaimEnd = claimEnd.updateAttribute('claimDestinationFk', claimDestinationFk, myOptions);
promises.push(updatedClaimEnd);
} }
const updatedSales = await Promise.all(promises);
if (tx) await tx.commit(); if (tx) await tx.commit();
return {}; return updatedSales;
} catch (e) { } catch (e) {
if (tx) await tx.rollback(); if (tx) await tx.rollback();
throw e; throw e;

View File

@ -1,4 +1,4 @@
module.exports = Self => { module.exports = Self => {
require('../methods/claim-end/filter')(Self); require('../methods/claim-end/filter')(Self);
require('../methods/claim-end/deleteSalesClaimed')(Self); require('../methods/claim-end/deleteClamedSales')(Self);
}; };

View File

@ -93,7 +93,7 @@ export default class Controller extends Section {
removeSales(saleClaimed) { removeSales(saleClaimed) {
const params = {sales: [saleClaimed]}; const params = {sales: [saleClaimed]};
this.$http.post(`ClaimEnds/deleteSalesClaimed`, params).then(() => { this.$http.post(`ClaimEnds/deleteClamedSales`, params).then(() => {
this.$.model.refresh(); this.$.model.refresh();
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
}); });