231801_test_to_master #1519
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE `vn`.`ticketConfig` ADD daysForWarningClaim INT DEFAULT 2 NOT NULL COMMENT 'dias restantes hasta que salte el aviso de reclamación fuerade plazo';
|
|
@ -14,6 +14,15 @@
|
||||||
},
|
},
|
||||||
"scopeDays": {
|
"scopeDays": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"pickingDelay": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"packagingInvoicingDated": {
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
"daysForWarningClaim": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,6 +481,13 @@
|
||||||
on-accept="$ctrl.transferSales($ctrl.transfer.ticketId)">
|
on-accept="$ctrl.transferSales($ctrl.transfer.ticketId)">
|
||||||
</vn-confirm>
|
</vn-confirm>
|
||||||
|
|
||||||
|
<vn-confirm
|
||||||
|
vn-id="claimConfirm"
|
||||||
|
question="Do you want to continue?"
|
||||||
|
message="Claim out of time"
|
||||||
|
on-accept="$ctrl.onCreateClaimAccepted()">
|
||||||
|
</vn-confirm>
|
||||||
|
|
||||||
<vn-menu vn-id="moreOptions">
|
<vn-menu vn-id="moreOptions">
|
||||||
<vn-item translate
|
<vn-item translate
|
||||||
name="sms"
|
name="sms"
|
||||||
|
@ -503,6 +510,7 @@
|
||||||
ng-click="$ctrl.createClaim()"
|
ng-click="$ctrl.createClaim()"
|
||||||
ng-if="$ctrl.isClaimable">
|
ng-if="$ctrl.isClaimable">
|
||||||
Add claim
|
Add claim
|
||||||
|
|
||||||
</vn-item>
|
</vn-item>
|
||||||
<vn-item translate
|
<vn-item translate
|
||||||
name="reserve"
|
name="reserve"
|
||||||
|
|
|
@ -7,6 +7,7 @@ class Controller extends Section {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
this._sales = [];
|
this._sales = [];
|
||||||
this.manaCode = 'mana';
|
this.manaCode = 'mana';
|
||||||
|
this.getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
get manaCode() {
|
get manaCode() {
|
||||||
|
@ -43,6 +44,15 @@ class Controller extends Section {
|
||||||
|
|
||||||
return ticketState && ticketState.state.code;
|
return ticketState && ticketState.state.code;
|
||||||
}
|
}
|
||||||
|
getConfig() {
|
||||||
|
let filter = {
|
||||||
|
fields: ['daysForWarningClaim'],
|
||||||
|
};
|
||||||
|
this.$http.get(`TicketConfigs`, {filter})
|
||||||
|
.then(res => {
|
||||||
|
this.ticketConfig = res.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
get isClaimable() {
|
get isClaimable() {
|
||||||
if (this.ticket) {
|
if (this.ticket) {
|
||||||
|
@ -184,6 +194,16 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
createClaim() {
|
createClaim() {
|
||||||
|
const timeDifference = new Date().getTime() - new Date(this.ticket.shipped).getTime();
|
||||||
|
const pastDays = Math.floor(timeDifference / 86400000);
|
||||||
|
|
||||||
|
if (pastDays >= this.ticketConfig[0].daysForWarningClaim)
|
||||||
|
this.$.claimConfirm.show();
|
||||||
|
else
|
||||||
|
this.onCreateClaimAccepted();
|
||||||
|
}
|
||||||
|
|
||||||
|
onCreateClaimAccepted() {
|
||||||
const sales = this.selectedValidSales();
|
const sales = this.selectedValidSales();
|
||||||
const params = {ticketId: this.ticket.id, sales: sales};
|
const params = {ticketId: this.ticket.id, sales: sales};
|
||||||
this.resetChanges();
|
this.resetChanges();
|
||||||
|
|
|
@ -45,6 +45,7 @@ describe('Ticket', () => {
|
||||||
$scope.model = crudModel;
|
$scope.model = crudModel;
|
||||||
$scope.editDiscount = {relocate: () => {}, hide: () => {}};
|
$scope.editDiscount = {relocate: () => {}, hide: () => {}};
|
||||||
$scope.editPricePopover = {relocate: () => {}};
|
$scope.editPricePopover = {relocate: () => {}};
|
||||||
|
$scope.claimConfirm = {show: () => {}};
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
Object.defineProperties($state.params, {
|
Object.defineProperties($state.params, {
|
||||||
id: {
|
id: {
|
||||||
|
@ -61,6 +62,10 @@ describe('Ticket', () => {
|
||||||
controller.card = {reload: () => {}};
|
controller.card = {reload: () => {}};
|
||||||
controller._ticket = ticket;
|
controller._ticket = ticket;
|
||||||
controller._sales = sales;
|
controller._sales = sales;
|
||||||
|
controller.ticketConfig = [
|
||||||
|
{daysForWarningClaim: 1}
|
||||||
|
];
|
||||||
|
$httpBackend.expect('GET', 'TicketConfigs').respond(200);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('ticket() setter', () => {
|
describe('ticket() setter', () => {
|
||||||
|
@ -113,7 +118,6 @@ describe('Ticket', () => {
|
||||||
it('should make an HTTP GET query and return the worker mana', () => {
|
it('should make an HTTP GET query and return the worker mana', () => {
|
||||||
controller.edit = {};
|
controller.edit = {};
|
||||||
const expectedAmount = 250;
|
const expectedAmount = 250;
|
||||||
|
|
||||||
$httpBackend.expect('GET', 'Tickets/1/getSalesPersonMana').respond(200, expectedAmount);
|
$httpBackend.expect('GET', 'Tickets/1/getSalesPersonMana').respond(200, expectedAmount);
|
||||||
$httpBackend.expect('GET', 'Sales/usesMana').respond(200);
|
$httpBackend.expect('GET', 'Sales/usesMana').respond(200);
|
||||||
$httpBackend.expect('GET', 'WorkerManas/getCurrentWorkerMana').respond(200, expectedAmount);
|
$httpBackend.expect('GET', 'WorkerManas/getCurrentWorkerMana').respond(200, expectedAmount);
|
||||||
|
@ -279,7 +283,17 @@ describe('Ticket', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('createClaim()', () => {
|
describe('createClaim()', () => {
|
||||||
it('should perform a query and call windows open', () => {
|
it('should call to the claimConfirm show() method', () => {
|
||||||
|
jest.spyOn(controller.$.claimConfirm, 'show').mockReturnThis();
|
||||||
|
|
||||||
|
controller.createClaim();
|
||||||
|
|
||||||
|
expect(controller.$.claimConfirm.show).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('onCreateClaimAccepted()', () => {
|
||||||
|
it('should perform a query and call window open', () => {
|
||||||
jest.spyOn(controller, 'resetChanges').mockReturnThis();
|
jest.spyOn(controller, 'resetChanges').mockReturnThis();
|
||||||
jest.spyOn(controller.$state, 'go').mockReturnThis();
|
jest.spyOn(controller.$state, 'go').mockReturnThis();
|
||||||
|
|
||||||
|
@ -290,7 +304,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
const expectedParams = {ticketId: 1, sales: [firstSale]};
|
const expectedParams = {ticketId: 1, sales: [firstSale]};
|
||||||
$httpBackend.expect('POST', `Claims/createFromSales`, expectedParams).respond(200, {id: 1});
|
$httpBackend.expect('POST', `Claims/createFromSales`, expectedParams).respond(200, {id: 1});
|
||||||
controller.createClaim();
|
controller.onCreateClaimAccepted();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.resetChanges).toHaveBeenCalledWith();
|
expect(controller.resetChanges).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -40,4 +40,5 @@ Refund: Abono
|
||||||
Promotion mana: Maná promoción
|
Promotion mana: Maná promoción
|
||||||
Claim mana: Maná reclamación
|
Claim mana: Maná reclamación
|
||||||
History: Historial
|
History: Historial
|
||||||
Select lines to see the options: Seleccione lineas para ver las opciones
|
Do you want to continue?: ¿Desea continuar?
|
||||||
|
Claim out of time: Reclamación fuera de plazo
|
||||||
|
|
Loading…
Reference in New Issue