Merge & fixes
This commit is contained in:
commit
84572dc398
|
@ -652,8 +652,8 @@ export default {
|
||||||
kmStartInput: 'vn-route-basic-data vn-input-number[field="$ctrl.route.kmStart"] input',
|
kmStartInput: 'vn-route-basic-data vn-input-number[field="$ctrl.route.kmStart"] input',
|
||||||
kmEndInput: 'vn-route-basic-data vn-input-number[model="$ctrl.route.kmEnd"] input',
|
kmEndInput: 'vn-route-basic-data vn-input-number[model="$ctrl.route.kmEnd"] input',
|
||||||
createdDateInput: 'vn-route-basic-data vn-date-picker[model="$ctrl.route.created"] > div > input',
|
createdDateInput: 'vn-route-basic-data vn-date-picker[model="$ctrl.route.created"] > div > input',
|
||||||
startedDateInput: 'vn-route-basic-data vn-date-picker[model="$ctrl.route.started"] > div > input',
|
startedHourInput: 'vn-route-basic-data vn-input-time[model="$ctrl.route.started"] input',
|
||||||
finishedDateInput: 'vn-route-basic-data vn-date-picker[model="$ctrl.route.finished"] > div > input',
|
finishedHourInput: 'vn-route-basic-data vn-input-time[model="$ctrl.route.finished"] input',
|
||||||
saveButton: 'vn-route-basic-data vn-submit[label="Save"] input'
|
saveButton: 'vn-route-basic-data vn-submit[label="Save"] input'
|
||||||
},
|
},
|
||||||
routeTickets: {
|
routeTickets: {
|
||||||
|
|
|
@ -20,8 +20,8 @@ describe('Route basic Data path', () => {
|
||||||
.write(selectors.routeBasicData.kmStartInput, 1)
|
.write(selectors.routeBasicData.kmStartInput, 1)
|
||||||
.clearInput(selectors.routeBasicData.kmEndInput)
|
.clearInput(selectors.routeBasicData.kmEndInput)
|
||||||
.write(selectors.routeBasicData.kmEndInput, 2)
|
.write(selectors.routeBasicData.kmEndInput, 2)
|
||||||
.datePicker(selectors.routeBasicData.startedDateInput, 1, null)
|
.write(selectors.routeBasicData.startedHourInput, '0800')
|
||||||
.datePicker(selectors.routeBasicData.finishedDateInput, 1, null)
|
.write(selectors.routeBasicData.finishedHourInput, '1230')
|
||||||
.waitToClick(selectors.routeBasicData.saveButton)
|
.waitToClick(selectors.routeBasicData.saveButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
form="form"
|
form="form"
|
||||||
save="patch">
|
save="patch">
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
<form name="form" ng-submit="watcher.submit()" compact>
|
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
@ -56,18 +56,21 @@
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-date-picker
|
<vn-input-time
|
||||||
|
label="Hour started"
|
||||||
|
model="$ctrl.route.started">
|
||||||
|
</vn-input-time>
|
||||||
|
<vn-input-time
|
||||||
|
label="Hour finished"
|
||||||
|
model="$ctrl.route.finished">
|
||||||
|
</vn-input-time>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
vn-one
|
vn-one
|
||||||
label="Date started"
|
label="Description"
|
||||||
model="$ctrl.route.started"
|
field="$ctrl.route.description" vn-focus>
|
||||||
ini-options="{dateFormat: 'd-m-Y'}">
|
</vn-textfield>
|
||||||
</vn-date-picker>
|
|
||||||
<vn-date-picker
|
|
||||||
vn-one
|
|
||||||
label="Date finished"
|
|
||||||
model="$ctrl.route.finished"
|
|
||||||
ini-options="{dateFormat: 'd-m-Y'}">
|
|
||||||
</vn-date-picker>
|
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-button-bar>
|
<vn-button-bar>
|
||||||
|
|
|
@ -1,8 +1,24 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
constructor($scope, $state) {
|
||||||
|
this.$scope = $scope;
|
||||||
|
this.$state = $state;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
this.$scope.watcher.submit().then(() => {
|
||||||
|
this.card.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
ngModule.component('vnRouteBasicData', {
|
ngModule.component('vnRouteBasicData', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
bindings: {
|
bindings: {
|
||||||
route: '<'
|
route: '<'
|
||||||
|
},
|
||||||
|
require: {
|
||||||
|
card: '^vnRouteCard'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,3 +2,4 @@ Date finished: Fecha fin
|
||||||
Date started: Fecha inicio
|
Date started: Fecha inicio
|
||||||
Km start: Km de inicio
|
Km start: Km de inicio
|
||||||
Km end: Km de fin
|
Km end: Km de fin
|
||||||
|
Description: Descripción
|
|
@ -40,7 +40,7 @@
|
||||||
<vn-icon
|
<vn-icon
|
||||||
vn-tooltip="Volume exceded"
|
vn-tooltip="Volume exceded"
|
||||||
icon="icon-volume"
|
icon="icon-volume"
|
||||||
ng-class="{bright: $ctrl.route.m3 > $ctrl.route.vehicle.m3}">
|
ng-class="{bright: $ctrl.route.m3 > $ctrl.route.vehicle.m3 && $ctrl.route.vehicle.m3 != NULL}">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="quicklinks">
|
<div class="quicklinks">
|
||||||
|
@ -74,5 +74,5 @@
|
||||||
<vn-confirm
|
<vn-confirm
|
||||||
vn-id="updateVolumeConfirmation"
|
vn-id="updateVolumeConfirmation"
|
||||||
on-response="$ctrl.updateVolume(response)"
|
on-response="$ctrl.updateVolume(response)"
|
||||||
question="Are you sure you want to book this invoice?">
|
question="Are you sure you want to update the volume?">
|
||||||
</vn-confirm>
|
</vn-confirm>
|
|
@ -1,5 +1,4 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import {createDecipher} from 'crypto';
|
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor($, $http, vnApp, $translate, aclService) {
|
constructor($, $http, vnApp, $translate, aclService) {
|
||||||
|
|
|
@ -4,3 +4,4 @@ Send route report: Enviar informe de ruta
|
||||||
Show route report: Ver informe de ruta
|
Show route report: Ver informe de ruta
|
||||||
Update volume: Actualizar volumen
|
Update volume: Actualizar volumen
|
||||||
Volume updated: Volumen actualizado
|
Volume updated: Volumen actualizado
|
||||||
|
Are you sure you want to update the volume?: Estas seguro que quieres actualizar el volumen?
|
|
@ -6,8 +6,8 @@
|
||||||
"dependencies": ["client", "worker", "ticket"],
|
"dependencies": ["client", "worker", "ticket"],
|
||||||
"menu": [
|
"menu": [
|
||||||
{"state": "route.card.basicData", "icon": "settings"},
|
{"state": "route.card.basicData", "icon": "settings"},
|
||||||
{"state": "route.card.log", "icon": "history"},
|
{"state": "route.card.tickets", "icon": "icon-ticket"},
|
||||||
{"state": "route.card.tickets", "icon": "icon-ticket"}],
|
{"state": "route.card.log", "icon": "history"}],
|
||||||
"routes": [
|
"routes": [
|
||||||
{
|
{
|
||||||
"url": "/route",
|
"url": "/route",
|
||||||
|
|
|
@ -2,9 +2,12 @@ const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('sale transferSales()', () => {
|
describe('sale transferSales()', () => {
|
||||||
let createdTicketId;
|
let createdTicketId;
|
||||||
|
let createdTicketsIds = [];
|
||||||
|
|
||||||
afterAll(async done => {
|
afterAll(async done => {
|
||||||
|
createdTicketsIds.forEach(async createdTicketId => {
|
||||||
await app.models.Ticket.destroyById(createdTicketId);
|
await app.models.Ticket.destroyById(createdTicketId);
|
||||||
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -62,22 +65,23 @@ describe('sale transferSales()', () => {
|
||||||
it('should transfer the sales from one ticket to a new one', async() => {
|
it('should transfer the sales from one ticket to a new one', async() => {
|
||||||
const ctx = {req: {accessToken: {userId: 101}}};
|
const ctx = {req: {accessToken: {userId: 101}}};
|
||||||
let currentTicket = await app.models.Ticket.findById(11);
|
let currentTicket = await app.models.Ticket.findById(11);
|
||||||
let currentTicketSales = await app.models.Ticket.getSales(currentTicket.id);
|
let originalTicketSales = await app.models.Ticket.getSales(currentTicket.id);
|
||||||
|
salesToRestone = originalTicketSales;
|
||||||
|
|
||||||
expect(currentTicketSales.length).toEqual(2);
|
expect(originalTicketSales.length).toEqual(2);
|
||||||
|
|
||||||
const currentTicketId = currentTicket.id;
|
const currentTicketId = currentTicket.id;
|
||||||
const receiverTicketId = undefined;
|
const receiverTicketId = undefined;
|
||||||
const sales = currentTicketSales;
|
|
||||||
|
|
||||||
let createdTicket = await app.models.Ticket.transferSales(
|
let createdTicket = await app.models.Ticket.transferSales(
|
||||||
ctx, currentTicketId, receiverTicketId, sales);
|
ctx, currentTicketId, receiverTicketId, originalTicketSales);
|
||||||
createdTicketId = createdTicket.id;
|
createdTicketId = createdTicket.id;
|
||||||
|
createdTicketsIds.push(createdTicket.id);
|
||||||
|
|
||||||
currentTicketSales = await app.models.Ticket.getSales(currentTicket.id);
|
originalTicketSales = await app.models.Ticket.getSales(currentTicket.id);
|
||||||
receiverTicketSales = await app.models.Ticket.getSales(createdTicket.id);
|
receiverTicketSales = await app.models.Ticket.getSales(createdTicket.id);
|
||||||
|
|
||||||
expect(currentTicketSales.length).toEqual(0);
|
expect(originalTicketSales.length).toEqual(0);
|
||||||
expect(receiverTicketSales.length).toEqual(2);
|
expect(receiverTicketSales.length).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -108,4 +112,67 @@ describe('sale transferSales()', () => {
|
||||||
expect(createdTicketSales.length).toEqual(0);
|
expect(createdTicketSales.length).toEqual(0);
|
||||||
expect(receiverTicketSales.length).toEqual(2);
|
expect(receiverTicketSales.length).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('sale transferPartialSales()', () => {
|
||||||
|
it('should throw an error in the quantity to transfer exceeds the amount from the original sale', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: 101}}};
|
||||||
|
let error;
|
||||||
|
let currentTicket = await app.models.Ticket.findById(11);
|
||||||
|
let currentTicketSales = await app.models.Ticket.getSales(currentTicket.id);
|
||||||
|
|
||||||
|
const currentTicketId = currentTicket.id;
|
||||||
|
const receiverTicketId = undefined;
|
||||||
|
|
||||||
|
currentTicketSales[0].quantity = 99;
|
||||||
|
|
||||||
|
await app.models.Ticket.transferSales(
|
||||||
|
ctx, currentTicketId, receiverTicketId, currentTicketSales)
|
||||||
|
.catch(response => {
|
||||||
|
expect(response.message).toEqual(`Invalid quantity`);
|
||||||
|
error = response;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(error).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should partially transfer the sales from one ticket to a new one', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: 101}}};
|
||||||
|
let currentTicket = await app.models.Ticket.findById(11);
|
||||||
|
let currentTicketSales = [];
|
||||||
|
let saleToRestore = await app.models.Sale.findById(7);
|
||||||
|
currentTicketSales.push(saleToRestore);
|
||||||
|
|
||||||
|
expect(currentTicketSales[0].quantity).toEqual(15);
|
||||||
|
|
||||||
|
const currentTicketId = currentTicket.id;
|
||||||
|
const receiverTicketId = undefined;
|
||||||
|
|
||||||
|
const originalQuantity = currentTicketSales[0].quantity;
|
||||||
|
currentTicketSales[0].quantity = 1;
|
||||||
|
let salesToPartiallyTransfer = [currentTicketSales[0]];
|
||||||
|
const saleIdToRestore = currentTicketSales[0].id;
|
||||||
|
|
||||||
|
let createdTicket = await app.models.Ticket.transferSales(
|
||||||
|
ctx, currentTicketId, receiverTicketId, salesToPartiallyTransfer);
|
||||||
|
|
||||||
|
createdTicketId = createdTicket.id;
|
||||||
|
createdTicketsIds.push(createdTicket.id);
|
||||||
|
|
||||||
|
currentTicketSales = await app.models.Ticket.getSales(currentTicket.id);
|
||||||
|
receiverTicketSales = await app.models.Ticket.getSales(createdTicket.id);
|
||||||
|
|
||||||
|
expect(currentTicketSales.length).toEqual(2);
|
||||||
|
expect(currentTicketSales[0].quantity).toEqual(14);
|
||||||
|
expect(receiverTicketSales.length).toEqual(1);
|
||||||
|
expect(receiverTicketSales[0].quantity).toEqual(1);
|
||||||
|
|
||||||
|
saleToRestore.updateAttribute('quantity', originalQuantity);
|
||||||
|
|
||||||
|
currentTicketSales = await app.models.Ticket.getSales(currentTicket.id);
|
||||||
|
|
||||||
|
|
||||||
|
expect(currentTicketSales[0].quantity).toEqual(15);
|
||||||
|
expect(currentTicketSales[0].id).toEqual(saleIdToRestore);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -72,7 +72,7 @@ module.exports = Self => {
|
||||||
await models.Sale.updateAll({
|
await models.Sale.updateAll({
|
||||||
id: sale.id
|
id: sale.id
|
||||||
}, {ticketFk: ticketId}, options);
|
}, {ticketFk: ticketId}, options);
|
||||||
} else if (sale.quantity < originalSale.quantity) {
|
} else if (sale.quantity != originalSale.quantity) {
|
||||||
await transferPartialSale(
|
await transferPartialSale(
|
||||||
ticketId, originalSale, sale, options);
|
ticketId, originalSale, sale, options);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue