recalculate ticket components
gitea/salix/1770-calculate_components This commit has test failures
Details
gitea/salix/1770-calculate_components This commit has test failures
Details
This commit is contained in:
parent
615cfe15cc
commit
c6d1536500
|
@ -1,6 +1,7 @@
|
||||||
import ngModule from '../../module';
|
import ngModule from '../../module';
|
||||||
import Dialog from '../dialog';
|
import Dialog from '../dialog';
|
||||||
import template from './confirm.html';
|
import template from './confirm.html';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
export default class Confirm extends Dialog {
|
export default class Confirm extends Dialog {
|
||||||
constructor($element, $, $transclude) {
|
constructor($element, $, $transclude) {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
.vn-confirm .window {
|
||||||
|
max-width: 30em
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('recalculateComponents', {
|
||||||
|
description: 'Calculates the price of a sale and its components',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'id',
|
||||||
|
description: 'The ticket id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
http: {source: 'path'}
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'Number',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/recalculateComponents`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.recalculateComponents = async(ctx, id) => {
|
||||||
|
const isEditable = await Self.isEditable(ctx, id);
|
||||||
|
|
||||||
|
if (!isEditable)
|
||||||
|
throw new UserError(`The sales of this ticket can't be modified`);
|
||||||
|
|
||||||
|
return Self.rawSql('CALL vn.ticket_recalcComponents(?)', [id]);
|
||||||
|
};
|
||||||
|
};
|
|
@ -26,6 +26,7 @@ module.exports = Self => {
|
||||||
require('../methods/ticket/addSale')(Self);
|
require('../methods/ticket/addSale')(Self);
|
||||||
require('../methods/ticket/transferSales')(Self);
|
require('../methods/ticket/transferSales')(Self);
|
||||||
require('../methods/ticket/canHaveStowaway')(Self);
|
require('../methods/ticket/canHaveStowaway')(Self);
|
||||||
|
require('../methods/ticket/recalculateComponents')(Self);
|
||||||
|
|
||||||
Self.observe('before save', async function(ctx) {
|
Self.observe('before save', async function(ctx) {
|
||||||
if (ctx.isNewInstance) return;
|
if (ctx.isNewInstance) return;
|
||||||
|
|
|
@ -198,6 +198,13 @@
|
||||||
<vn-confirm
|
<vn-confirm
|
||||||
vn-id="confirm-delivery-note"
|
vn-id="confirm-delivery-note"
|
||||||
on-accept="$ctrl.sendDeliveryNote()"
|
on-accept="$ctrl.sendDeliveryNote()"
|
||||||
question="Send Delivery Note"
|
question="Are you sure you want to send it?"
|
||||||
message="Are you sure you want to send it?">
|
message="Send Delivery Note">
|
||||||
|
</vn-confirm>
|
||||||
|
|
||||||
|
<vn-confirm
|
||||||
|
vn-id="recalculate-components-confirmation"
|
||||||
|
on-accept="$ctrl.recalculateComponents()"
|
||||||
|
question="Are you sure you want to recalculate the components?"
|
||||||
|
message="Recalculate components">
|
||||||
</vn-confirm>
|
</vn-confirm>
|
|
@ -35,6 +35,11 @@ class Controller extends Component {
|
||||||
callback: this.showRegenerateInvoiceDialog,
|
callback: this.showRegenerateInvoiceDialog,
|
||||||
show: () => this.hasInvoice()
|
show: () => this.hasInvoice()
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Recalculate components',
|
||||||
|
callback: this.comfirmRecalculateComponents,
|
||||||
|
show: () => this.isEditable
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,9 +292,26 @@ class Controller extends Component {
|
||||||
return this.ticket.refFk !== null;
|
return this.ticket.refFk !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows a delivery-note send confirmation
|
||||||
|
*/
|
||||||
confirmDeliveryNote() {
|
confirmDeliveryNote() {
|
||||||
this.$.confirmDeliveryNote.show();
|
this.$.confirmDeliveryNote.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows an invoice confirmation
|
||||||
|
*/
|
||||||
|
comfirmRecalculateComponents() {
|
||||||
|
this.$.recalculateComponentsConfirmation.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
recalculateComponents() {
|
||||||
|
const query = `Tickets/${this.ticket.id}/recalculateComponents`;
|
||||||
|
this.$http.post(query).then(res => {
|
||||||
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$element', '$scope', 'aclService', '$httpParamSerializer'];
|
Controller.$inject = ['$element', '$scope', 'aclService', '$httpParamSerializer'];
|
||||||
|
|
|
@ -25,4 +25,6 @@ You are going to regenerate the invoice: Vas a regenerar la factura
|
||||||
Are you sure you want to regenerate the invoice?: ¿Seguro que quieres regenerar la factura?
|
Are you sure you want to regenerate the invoice?: ¿Seguro que quieres regenerar la factura?
|
||||||
Invoice sent for a regeneration, will be available in a few minutes: La factura ha sido enviada para ser regenerada, estará disponible en unos minutos
|
Invoice sent for a regeneration, will be available in a few minutes: La factura ha sido enviada para ser regenerada, estará disponible en unos minutos
|
||||||
Shipped hour updated: Hora de envio modificada
|
Shipped hour updated: Hora de envio modificada
|
||||||
Deleted ticket: Ticket eliminado
|
Deleted ticket: Ticket eliminado
|
||||||
|
Recalculate components: Recalcular componentes
|
||||||
|
Are you sure you want to recalculate the components?: ¿Seguro que quieres recalcular los componentes?
|
Loading…
Reference in New Issue