#1031 order.create que se puedan crear tickets para clientes con riesgo

This commit is contained in:
Gerard 2019-01-23 12:34:42 +01:00
parent aeb0f65fec
commit 05933781dc
2 changed files with 0 additions and 22 deletions

View File

@ -27,7 +27,6 @@ module.exports = Self => {
{relation: 'client'}
]
});
let clientFk = address.clientFk;
if (address.client().isFreezed)
throw new UserError(`You can't create an order for a frozen client`);
@ -38,12 +37,6 @@ module.exports = Self => {
if (!address.client().isTaxDataChecked)
throw new UserError(`You can't create an order for a client that doesn't has tax data verified`);
let query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`;
let clientDebt = await Self.rawSql(query, [clientFk]);
if (address.client().credit - clientDebt[0].debt <= 0)
throw new UserError(`You can't create an order for a client that has a debt`);
query = `CALL vn.orderListCreate(?, ?, ?, ?);`;
[result] = await Self.rawSql(query, [
params.landed,

View File

@ -44,21 +44,6 @@ describe('order new()', () => {
expect(error).toEqual(new UserError(`You can't create an order for a client that doesn't has tax data verified`));
});
it('should throw an error if the client isnt frozen and is active, has data checked but has a debt', async() => {
let error;
let params = {
addressFk: 123,
landed: new Date()
};
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 has a debt`));
});
it('should create a new order for the user with id 105 when all conditions are met', async() => {
let params = {
landed: new Date(),