#1031 order.create que se puedan crear tickets para clientes con riesgo
This commit is contained in:
parent
aeb0f65fec
commit
05933781dc
|
@ -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,
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in New Issue