recalcPrices
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
eed0ac66c6
commit
a446e0650f
|
@ -0,0 +1,47 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('recalcPrices', {
|
||||
description: 'Recalc all prices in the entry',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The entry id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/recalcPrices`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.recalcPrices = async(ctx, id, options) => {
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
await Self.rawSql('CALL vn.buy_recalcPricesByEntry(?)', [
|
||||
id
|
||||
], myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -6,4 +6,5 @@ module.exports = Self => {
|
|||
require('../methods/entry/importBuys')(Self);
|
||||
require('../methods/entry/importBuysPreview')(Self);
|
||||
require('../methods/entry/lastItemBuys')(Self);
|
||||
require('../methods/entry/recalcPrices')(Self);
|
||||
};
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
translate>
|
||||
Show entry report
|
||||
</vn-item>
|
||||
<vn-item
|
||||
ng-click="$ctrl.recalcPrices()"
|
||||
translate>
|
||||
Recalc prices
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
<slot-body>
|
||||
<div class="attributes">
|
||||
|
|
|
@ -90,6 +90,12 @@ class Controller extends Descriptor {
|
|||
entryId: this.entry.id
|
||||
});
|
||||
}
|
||||
|
||||
recalcPrices() {
|
||||
this.$http.post(`Entries/${this.id}/recalcPrices`).then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Prices recalculated!'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnEntryDescriptor', {
|
||||
|
|
|
@ -4,4 +4,6 @@ All travels with current agency: Todos los envios con la agencia actual
|
|||
All entries with current supplier: Todas las entradas con el proveedor actual
|
||||
Show entry report: Ver informe del pedido
|
||||
Is inventory entry: Es una entrada de inventario
|
||||
Is virtual entry: Es una redada
|
||||
Is virtual entry: Es una redada
|
||||
Recalc prices: Recalcular precios
|
||||
Prices recalculated: Precios recalculados
|
Loading…
Reference in New Issue