#1064 quitar comprobación isTaxDataChecked
This commit is contained in:
parent
b791195b89
commit
21e30bcaef
|
@ -34,9 +34,6 @@ module.exports = Self => {
|
||||||
if (!address.client().isActive)
|
if (!address.client().isActive)
|
||||||
throw new UserError(`You can't create an order for a inactive client`);
|
throw new UserError(`You can't create an order for a inactive client`);
|
||||||
|
|
||||||
if (!address.client().isTaxDataChecked)
|
|
||||||
throw new UserError(`You can't create an order for a client that doesn't has tax data verified`);
|
|
||||||
|
|
||||||
query = `CALL vn.orderListCreate(?, ?, ?, ?);`;
|
query = `CALL vn.orderListCreate(?, ?, ?, ?);`;
|
||||||
[result] = await Self.rawSql(query, [
|
[result] = await Self.rawSql(query, [
|
||||||
params.landed,
|
params.landed,
|
||||||
|
|
|
@ -32,18 +32,6 @@ describe('order new()', () => {
|
||||||
expect(error).toEqual(new UserError(`You can't create an order for a inactive client`));
|
expect(error).toEqual(new UserError(`You can't create an order for a inactive client`));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the client isnt frozen and is active but doesnt have data checked', async() => {
|
|
||||||
let error;
|
|
||||||
let params = {addressFk: 7};
|
|
||||||
|
|
||||||
await app.models.Order.new(params)
|
|
||||||
.catch(e => {
|
|
||||||
error = e;
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(error).toEqual(new UserError(`You can't create an order for a client that doesn't has tax data verified`));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create a new order for the user with id 105 when all conditions are met', async() => {
|
it('should create a new order for the user with id 105 when all conditions are met', async() => {
|
||||||
let params = {
|
let params = {
|
||||||
landed: new Date(),
|
landed: new Date(),
|
||||||
|
|
|
@ -39,9 +39,6 @@ module.exports = Self => {
|
||||||
if (!address.client().isActive)
|
if (!address.client().isActive)
|
||||||
throw new UserError(`You can't create a ticket for a inactive client`);
|
throw new UserError(`You can't create a ticket for a inactive client`);
|
||||||
|
|
||||||
if (!address.client().isTaxDataChecked)
|
|
||||||
throw new UserError(`You can't create a ticket for a client that doesn't has tax data verified`);
|
|
||||||
|
|
||||||
let clientFk = address.clientFk;
|
let clientFk = address.clientFk;
|
||||||
let agency;
|
let agency;
|
||||||
if (params.agencyModeFk)
|
if (params.agencyModeFk)
|
||||||
|
|
|
@ -1,15 +1,41 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
let UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
|
||||||
describe('ticket new()', () => {
|
describe('ticket new()', () => {
|
||||||
let ticket;
|
let ticket;
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
let ctx = {req: {accessToken: {userId: 1}}};
|
let ctx = {req: {accessToken: {userId: 1}}};
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async() => {
|
||||||
await app.models.Ticket.destroyById(ticket.id);
|
await app.models.Ticket.destroyById(ticket.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the address doesnt exist', async () => {
|
it('should throw an error if the client is frozen', async() => {
|
||||||
|
let error;
|
||||||
|
let params = {addressFk: 121};
|
||||||
|
|
||||||
|
await app.models.Ticket.new(ctx, params)
|
||||||
|
.catch(e => {
|
||||||
|
error = e;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(error).toEqual(new UserError(`You can't create a ticket for a frozen client`));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error if the client isnt frozen and isnt active', async() => {
|
||||||
|
let error;
|
||||||
|
let params = {addressFk: 6};
|
||||||
|
|
||||||
|
await app.models.Ticket.new(ctx, params)
|
||||||
|
.catch(e => {
|
||||||
|
error = e;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(error).toEqual(new UserError(`You can't create a ticket for a inactive client`));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error if the address doesnt exist', async() => {
|
||||||
let error;
|
let error;
|
||||||
let params = {addressFk: 'invalid address', clientFk: 104};
|
let params = {addressFk: 'invalid address', clientFk: 104};
|
||||||
|
|
||||||
|
@ -22,7 +48,7 @@ describe('ticket new()', () => {
|
||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the id of the created ticket', async () => {
|
it('should return the id of the created ticket', async() => {
|
||||||
let params = {
|
let params = {
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
clientFk: 104,
|
clientFk: 104,
|
||||||
|
|
Loading…
Reference in New Issue