6336-claimState_removeSome #2125

Merged
alexm merged 4 commits from 6336-claimState_removeSome into dev 2024-03-06 08:15:09 +00:00
6 changed files with 20 additions and 133 deletions

View File

@ -1819,19 +1819,16 @@ INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk
INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify`)
VALUES
( 1, 'pending', 'Pendiente', 1, 1, 0),
( 2, 'managed', 'Gestionado', 72, 5, 0),
( 3, 'resolved', 'Resuelto', 72, 7, 0),
( 4, 'canceled', 'Anulado', 72, 6, 1),
( 5, 'incomplete', 'Incompleta', 1, 3, 1),
( 6, 'mana', 'Mana', 72, 4, 0),
( 7, 'lack', 'Faltas', 72, 2, 0);
( 5, 'incomplete', 'Incompleta', 1, 3, 1);
INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `ticketFk`)
VALUES
(1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, 11),
(2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, 16),
(3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, 7),
(4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, 8);
(2, util.VN_CURDATE(), 4, 1101, 18, 3, 0, util.VN_CURDATE(), 1, 16),
(3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, 7),
(4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, 8);
INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`)
VALUES

View File

@ -0,0 +1,8 @@
UPDATE vn.claim c
JOIN vn.claimState cs ON cs.id = c.claimStateFk
JOIN vn.claimState ns ON ns.code = 'resolved'
SET c.claimStateFk = ns.id
WHERE cs.code IN ('managed', 'mana', 'lack', 'relocation');
Review

No se gastaven, menos el de mana que se gastava 49 vegades

No se gastaven, menos el de mana que se gastava 49 vegades
DELETE FROM vn.claimState
WHERE code IN ('managed', 'mana', 'lack', 'relocation');

View File

@ -21,7 +21,7 @@ describe('Claim edit basic data path', () => {
});
it(`should edit claim state and observation fields`, async() => {
await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Gestionado');
await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Resuelto');
await page.clearInput(selectors.claimBasicData.packages);
await page.write(selectors.claimBasicData.packages, '2');
await page.waitToClick(selectors.claimBasicData.saveButton);
@ -48,7 +48,7 @@ describe('Claim edit basic data path', () => {
await page.waitForSelector(selectors.claimBasicData.claimState);
const result = await page.waitToGetProperty(selectors.claimBasicData.claimState, 'value');
expect(result).toEqual('Gestionado');
expect(result).toEqual('Resuelto');
});
it('should confirm the "is paid with mana" and "Pick up" checkbox are checked', async() => {

View File

@ -64,7 +64,7 @@ describe('claimstate isEditable()', () => {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: claimManagerId}}};
const result = await app.models.ClaimState.isEditable(ctx, 7, options);
const result = await app.models.ClaimState.isEditable(ctx, 5, options);
expect(result).toEqual(true);

View File

@ -21,12 +21,13 @@ describe('Update Claim', () => {
claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {});
});
const newDate = Date.vnNew();
const claimManagerId = 72;
const originalData = {
ticketFk: 3,
clientFk: 1101,
ticketCreated: newDate,
workerFk: 18,
claimStateFk: 2,
claimStateFk: 5,
isChargedToMana: true,
responsibility: 4,
observation: 'observation'
@ -77,7 +78,6 @@ describe('Update Claim', () => {
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const pendingState = claimStatesMap.pending;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
@ -104,85 +104,7 @@ describe('Update Claim', () => {
}
});
it(`should success to update the claimState to 'managed' and send a rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
const options = {transaction: tx};
const newClaim = await app.models.Claim.create(originalData, options);
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const managedState = claimStatesMap.managed;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
headers: {origin: url}
},
args: {
observation: 'valid observation',
claimStateFk: managedState,
hasToPickUp: false
}
};
ctx.req.__ = i18n.__;
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should success to update the claimState to 'resolved' and send a rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
const options = {transaction: tx};
const newClaim = await app.models.Claim.create(originalData, options);
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const resolvedState = claimStatesMap.resolved;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
headers: {origin: url}
},
args: {
observation: 'valid observation',
claimStateFk: resolvedState,
hasToPickUp: false
}
};
ctx.req.__ = i18n.__;
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should success to update the claimState to 'canceled' and send a rocket message`, async() => {
it(`should success to update the claimState to 'canceled' and send two rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
@ -194,7 +116,6 @@ describe('Update Claim', () => {
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const canceledState = claimStatesMap.canceled;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
@ -212,46 +133,7 @@ describe('Update Claim', () => {
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should success to update the claimState to 'incomplete' and send a rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
const options = {transaction: tx};
const newClaim = await app.models.Claim.create(originalData, options);
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const incompleteState = 5;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
headers: {origin: url}
},
args: {
observation: 'valid observation',
claimStateFk: incompleteState,
hasToPickUp: false
}
};
ctx.req.__ = i18n.__;
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(2);
await tx.rollback();
} catch (e) {

View File

@ -21,7 +21,7 @@ describe('Update Claim', () => {
clientFk: 1101,
ticketCreated: newDate,
workerFk: 18,
claimStateFk: 2,
claimStateFk: 1,
isChargedToMana: true,
responsibility: 4,
observation: 'observation'