#154 credito ya inserta el usuario que efectua el cambio
This commit is contained in:
parent
8ee3c18cbc
commit
a47769f7c0
|
@ -127,7 +127,7 @@ export default {
|
||||||
addCreditFloatButton: `${components.vnFloatButton}`,
|
addCreditFloatButton: `${components.vnFloatButton}`,
|
||||||
creditInput: `${components.vnTextfield}[name="credit"]`,
|
creditInput: `${components.vnTextfield}[name="credit"]`,
|
||||||
saveButton: `${components.vnSubmit}`,
|
saveButton: `${components.vnSubmit}`,
|
||||||
firstCreditText: 'vn-client-credit-list .list-element > vn-one'
|
firstCreditText: 'vn-client-credit-list .list-element'
|
||||||
},
|
},
|
||||||
clientGreuge: {
|
clientGreuge: {
|
||||||
greugeButton: `${components.vnMenuItem}[ui-sref="clientCard.greuge.list"]`,
|
greugeButton: `${components.vnMenuItem}[ui-sref="clientCard.greuge.list"]`,
|
||||||
|
|
|
@ -72,6 +72,7 @@ describe('Add credit path', () => {
|
||||||
.getInnerText(selectors.clientCredit.firstCreditText)
|
.getInnerText(selectors.clientCredit.firstCreditText)
|
||||||
.then(value => {
|
.then(value => {
|
||||||
expect(value).toContain(999);
|
expect(value).toContain(999);
|
||||||
|
expect(value).toContain('developer');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -97,12 +97,22 @@ module.exports = function(Self) {
|
||||||
throw new UserError('Unable to mark the equivalence surcharge');
|
throw new UserError('Unable to mark the equivalence surcharge');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changes.credit !== undefined)
|
if (changes.credit !== undefined) {
|
||||||
try {
|
try {
|
||||||
await validateCreditChange(ctx, finalState);
|
await validateCreditChange(ctx, finalState);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new UserError('You are not allowed to change the credit');
|
throw new UserError('You are not allowed to change the credit');
|
||||||
}
|
}
|
||||||
|
let filter = {fields: ['id'], where: {userFk: ctx.options.accessToken.userId}};
|
||||||
|
let worker = await Self.app.models.Worker.findOne(filter);
|
||||||
|
|
||||||
|
let newCredit = {
|
||||||
|
amount: changes.credit,
|
||||||
|
clientFk: finalState.id,
|
||||||
|
workerFk: worker ? worker.id : null
|
||||||
|
};
|
||||||
|
await Self.app.models.ClientCredit.create(newCredit);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
async function validateCreditChange(ctx, finalState) {
|
async function validateCreditChange(ctx, finalState) {
|
||||||
|
|
Loading…
Reference in New Issue