console.logs
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b40b8d931d
commit
e140c9d1f4
|
@ -12,13 +12,16 @@ module.exports = Self => {
|
||||||
where: {clientFk: instance.clientFk},
|
where: {clientFk: instance.clientFk},
|
||||||
order: 'created DESC'
|
order: 'created DESC'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (clientCredit.length > maxCreditRows) {
|
if (clientCredit.length > maxCreditRows) {
|
||||||
const creditToDestroy = [];
|
const creditToDestroy = [];
|
||||||
for (const [index, credit] of clientCredit.entries()) {
|
for (const [index, credit] of clientCredit.entries()) {
|
||||||
if (index >= maxCreditRows)
|
console.log(index);
|
||||||
|
if (index >= maxCreditRows) {
|
||||||
|
console.log(index, 'BORRAR');
|
||||||
creditToDestroy.push(credit.id);
|
creditToDestroy.push(credit.id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await models.ClientCredit.destroyAll({
|
await models.ClientCredit.destroyAll({
|
||||||
id: {inq: creditToDestroy}
|
id: {inq: creditToDestroy}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,23 +9,20 @@ describe('Client Credit', () => {
|
||||||
const clientConfig = await models.ClientConfig.findOne({
|
const clientConfig = await models.ClientConfig.findOne({
|
||||||
where: {id: 1}
|
where: {id: 1}
|
||||||
});
|
});
|
||||||
let rowsBefore;
|
|
||||||
let rowsAfter;
|
let rowsAfter;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const context = {options};
|
const ctx = {options};
|
||||||
|
|
||||||
rowsBefore = await models.ClientCredit.find({
|
|
||||||
where: {clientFk: instance.id}
|
|
||||||
}, options);
|
|
||||||
|
|
||||||
const salesAssistant = await models.Account.findOne({
|
const salesAssistant = await models.Account.findOne({
|
||||||
where: {name: 'salesAssistant'}
|
where: {name: 'salesAssistant'}
|
||||||
}, options);
|
}, options);
|
||||||
context.options.accessToken = {userId: salesAssistant.id};
|
ctx.options.accessToken = {userId: salesAssistant.id};
|
||||||
|
await models.ClientCredit.create({
|
||||||
await models.Client.changeCredit(context, instance, {credit: 350});
|
amount: 355,
|
||||||
|
clientFk: instance.id,
|
||||||
|
workerFk: salesAssistant.id
|
||||||
|
}, ctx.options);
|
||||||
|
|
||||||
rowsAfter = await models.ClientCredit.find({
|
rowsAfter = await models.ClientCredit.find({
|
||||||
where: {clientFk: instance.id}
|
where: {clientFk: instance.id}
|
||||||
|
@ -37,7 +34,6 @@ describe('Client Credit', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(rowsBefore.length).toEqual(11);
|
|
||||||
expect(rowsAfter.length).toEqual(clientConfig.maxCreditRows);
|
expect(rowsAfter.length).toEqual(clientConfig.maxCreditRows);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue