#1195 claim.action regularize

This commit is contained in:
Javi Gallego 2019-04-16 08:09:16 +02:00
parent 34a630dcde
commit 28bbc024b2
5 changed files with 66 additions and 3 deletions

View File

@ -0,0 +1 @@
ALTER TABLE `vn2008`.`Greuges` CHANGE COLUMN `Fecha` `Fecha` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ;

View File

@ -30,7 +30,7 @@
vn-one
label="Responsability"
value="$ctrl.claim.responsibility"
max="5"
max="$ctrl.maxResponsibility"
min="1"
step="1"
vn-acl="salesAssistant"
@ -191,4 +191,10 @@
</vn-item-descriptor-popover>
<vn-ticket-descriptor-popover
vn-id="ticketDescriptor">
</vn-ticket-descriptor-popover>
</vn-ticket-descriptor-popover>
<vn-confirm
vn-id="update-greuge"
question="Insert greuges on client card"
message="Do you want to insert greuges?"
on-response="$ctrl.onUpdateGreugeResponse(response)">
</vn-confirm>

View File

@ -23,6 +23,7 @@ class Controller {
]
};
this.resolvedState = 3;
this.maxResponsibility = 5;
}
openAddSalesDialog() {
@ -135,9 +136,29 @@ class Controller {
this.$http.post(query, data).then(() => {
this.card.reload();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
if (this.claim.responsibility >= Math.ceil(this.maxResponsibility) / 2)
this.$.updateGreuge.show();
});
}
onUpdateGreugeResponse(response) {
if (response !== 'ACCEPT')
return;
let greugeTypeFreight = 7;
let query = `claim/api/Greuges/`;
let data = {
clientFk: this.claim.clientFk,
description: `claim: ${this.claim.id}`,
amount: 11,
greugeTypeFk: greugeTypeFreight,
ticketFk: this.claim.ticketFk
};
this.$http.post(query, data).then(() => {
this.card.reload();
this.vnApp.showSuccess(this.$translate.instant('Greuge inserted!'));
});
}
// Item Descriptor
showDescriptor(event, itemFk) {
this.quicklinks = {

View File

@ -158,5 +158,37 @@ describe('claim', () => {
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
});
});
describe('onUpdateGreugeResponse()', () => {
it('should do nothing', () => {
spyOn(controller.card, 'reload');
spyOn(controller.vnApp, 'showSuccess');
controller.onUpdateGreugeResponse('CANCEL');
expect(controller.card.reload).not.toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).not.toHaveBeenCalledWith('Greuge inserted!');
});
it('should perform a insert into greuges', () => {
spyOn(controller.card, 'reload');
spyOn(controller.vnApp, 'showSuccess');
controller.claim.clientFk = 101;
controller.claim.id = 11;
let data = {
clientFk: 101,
description: `claim: ${controller.claim.id}`,
amount: 11,
greugeTypeFk: 7,
ticketFk: controller.claim.ticketFk
};
$httpBackend.expect('POST', `claim/api/Greuges/`, data).respond();
controller.onUpdateGreugeResponse('ACCEPT');
$httpBackend.flush();
expect(controller.card.reload).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Greuge inserted!');
});
});
});
});

View File

@ -5,4 +5,7 @@ Import claim: Importar reclamacion
Imports claim details: Importa detalles de la reclamacion
Import ticket: Importar ticket
Imports ticket lines: Importa las lineas de un ticket
Regularize: Regularizar
Regularize: Regularizar
Do you want to insert greuges?: Desea insertar greuges?
Insert greuges on client card: Insertar greuges en la ficha del cliente
Greuge inserted: Greuge insertado