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": {
|
||||
"type": "number"
|
||||
},
|
||||
"pickingDelay": {
|
||||
"type": "number"
|
||||
},
|
||||
"packagingInvoicingDated": {
|
||||
"type": "date"
|
||||
},
|
||||
"daysForWarningClaim": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -481,6 +481,13 @@
|
|||
on-accept="$ctrl.transferSales($ctrl.transfer.ticketId)">
|
||||
</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-item translate
|
||||
name="sms"
|
||||
|
@ -503,6 +510,7 @@
|
|||
ng-click="$ctrl.createClaim()"
|
||||
ng-if="$ctrl.isClaimable">
|
||||
Add claim
|
||||
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
name="reserve"
|
||||
|
|
|
@ -7,6 +7,7 @@ class Controller extends Section {
|
|||
super($element, $);
|
||||
this._sales = [];
|
||||
this.manaCode = 'mana';
|
||||
this.getConfig();
|
||||
}
|
||||
|
||||
get manaCode() {
|
||||
|
@ -43,6 +44,15 @@ class Controller extends Section {
|
|||
|
||||
return ticketState && ticketState.state.code;
|
||||
}
|
||||
getConfig() {
|
||||
let filter = {
|
||||
fields: ['daysForWarningClaim'],
|
||||
};
|
||||
this.$http.get(`TicketConfigs`, {filter})
|
||||
.then(res => {
|
||||
this.ticketConfig = res.data;
|
||||
});
|
||||
}
|
||||
|
||||
get isClaimable() {
|
||||
if (this.ticket) {
|
||||
|
@ -184,6 +194,16 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
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 params = {ticketId: this.ticket.id, sales: sales};
|
||||
this.resetChanges();
|
||||
|
|
|
@ -45,6 +45,7 @@ describe('Ticket', () => {
|
|||
$scope.model = crudModel;
|
||||
$scope.editDiscount = {relocate: () => {}, hide: () => {}};
|
||||
$scope.editPricePopover = {relocate: () => {}};
|
||||
$scope.claimConfirm = {show: () => {}};
|
||||
$httpBackend = _$httpBackend_;
|
||||
Object.defineProperties($state.params, {
|
||||
id: {
|
||||
|
@ -61,6 +62,10 @@ describe('Ticket', () => {
|
|||
controller.card = {reload: () => {}};
|
||||
controller._ticket = ticket;
|
||||
controller._sales = sales;
|
||||
controller.ticketConfig = [
|
||||
{daysForWarningClaim: 1}
|
||||
];
|
||||
$httpBackend.expect('GET', 'TicketConfigs').respond(200);
|
||||
}));
|
||||
|
||||
describe('ticket() setter', () => {
|
||||
|
@ -113,7 +118,6 @@ describe('Ticket', () => {
|
|||
it('should make an HTTP GET query and return the worker mana', () => {
|
||||
controller.edit = {};
|
||||
const expectedAmount = 250;
|
||||
|
||||
$httpBackend.expect('GET', 'Tickets/1/getSalesPersonMana').respond(200, expectedAmount);
|
||||
$httpBackend.expect('GET', 'Sales/usesMana').respond(200);
|
||||
$httpBackend.expect('GET', 'WorkerManas/getCurrentWorkerMana').respond(200, expectedAmount);
|
||||
|
@ -279,7 +283,17 @@ describe('Ticket', () => {
|
|||
});
|
||||
|
||||
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.$state, 'go').mockReturnThis();
|
||||
|
||||
|
@ -290,7 +304,7 @@ describe('Ticket', () => {
|
|||
|
||||
const expectedParams = {ticketId: 1, sales: [firstSale]};
|
||||
$httpBackend.expect('POST', `Claims/createFromSales`, expectedParams).respond(200, {id: 1});
|
||||
controller.createClaim();
|
||||
controller.onCreateClaimAccepted();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.resetChanges).toHaveBeenCalledWith();
|
||||
|
|
|
@ -40,4 +40,5 @@ Refund: Abono
|
|||
Promotion mana: Maná promoción
|
||||
Claim mana: Maná reclamación
|
||||
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