Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 4480-vnUser

This commit is contained in:
Joan Sanchez 2023-04-17 08:57:24 +02:00
commit 02c573bd23
6 changed files with 57 additions and 4 deletions

View File

@ -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';

View File

@ -14,6 +14,15 @@
},
"scopeDays": {
"type": "number"
},
"pickingDelay": {
"type": "number"
},
"packagingInvoicingDated": {
"type": "date"
},
"daysForWarningClaim": {
"type": "number"
}
}
}

View File

@ -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"

View File

@ -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();

View File

@ -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();

View File

@ -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