#1555 ticket.lines transer to a new ticket
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-06-25 11:17:58 +02:00
parent 1227f7ac83
commit 2ce442a022
4 changed files with 20 additions and 2 deletions

View File

@ -1,6 +1,5 @@
import ngModule from '../../module';
import Component from '../../lib/component';
import {focus} from '../../directives/focus';
import './style.scss';
export default class Controller extends Component {

View File

@ -91,5 +91,6 @@
"NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
"This item doesn't exists": "El artículo no existe",
"NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
"Extension format is invalid": "El formato de la extensión es inválido"
"Extension format is invalid": "El formato de la extensión es inválido",
"Invalid parameters to create a new ticket": "Parámetros inválidos para crear un nuevo ticket"
}

View File

@ -39,6 +39,9 @@ module.exports = Self => {
if (!params.receiverTicket.id) {
let travelDates = await models.Agency.getFirstShipped(params.currentTicket);
if (!travelDates)
throw new UserError(`Invalid parameters to create a new ticket`);
let shipped = new Date(travelDates.shipped);
let landed = new Date(travelDates.landed);

View File

@ -38,6 +38,21 @@ describe('sale moveToTicket()', () => {
expect(error).toBeDefined();
});
it('should throw an error when attempting to create a new ticket without delivery dates', async() => {
const ctx = {req: {accessToken: {userId: 101}}};
let error;
const params = {currentTicket: {currentTicketId: 18}, receiverTicket: {id: undefined}};
await app.models.Sale.moveToTicket(ctx, params)
.catch(response => {
expect(response.message).toEqual(`Invalid parameters to create a new ticket`);
error = response;
});
expect(error).toBeDefined();
});
it('should 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);