2223 Added pickup checkbox
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2020-05-13 15:04:57 +02:00
parent 58be5ef78e
commit 94a219760c
10 changed files with 75 additions and 51 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE `vn`.`claim`
ADD COLUMN `hasToPickUp` TINYINT(1) NOT NULL AFTER `ticketFk`;

View File

@ -47,7 +47,7 @@ export default class Range extends FormInput {
} }
onValueUpdate() { onValueUpdate() {
this.change(this.input.value); this.change(parseInt(this.input.value));
this.$.$applyAsync(); this.$.$applyAsync();
} }
} }

View File

@ -62,6 +62,7 @@
"MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} (#{{clientId}})]({{{url}}}) to *{{credit}} €*", "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} (#{{clientId}})]({{{url}}}) to *{{credit}} €*",
"MESSAGE_CHANGED_PAYMETHOD": "I have changed the pay method for client [{{clientName}} (#{{clientId}})]({{{url}}})", "MESSAGE_CHANGED_PAYMETHOD": "I have changed the pay method for client [{{clientName}} (#{{clientId}})]({{{url}}})",
"Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})",
"Claim will be picked": "The product from the claim (#{{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked",
"This ticket is not an stowaway anymore": "The ticket id [#{{ticketId}}]({{{ticketUrl}}}) is not an stowaway anymore", "This ticket is not an stowaway anymore": "The ticket id [#{{ticketId}}]({{{ticketUrl}}}) is not an stowaway anymore",
"Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member",
"Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member",

View File

@ -125,6 +125,7 @@
"MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} (#{{clientId}})]({{{url}}}) a *{{credit}} €*", "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} (#{{clientId}})]({{{url}}}) a *{{credit}} €*",
"MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})", "MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})",
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})",
"Claim will be picked": "Se recogerá el género de la reclamación (#{{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*",
"This ticket is not an stowaway anymore": "El ticket id [#{{ticketId}}]({{{ticketUrl}}}) ha dejado de ser un polizón", "This ticket is not an stowaway anymore": "El ticket id [#{{ticketId}}]({{{ticketUrl}}}) ha dejado de ser un polizón",
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",

View File

@ -3,21 +3,22 @@ module.exports = Self => {
description: 'Imports lines from claimBeginning to a new ticket with specific shipped, landed dates, agency and company', description: 'Imports lines from claimBeginning to a new ticket with specific shipped, landed dates, agency and company',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [{ accepts: [{
arg: 'params', arg: 'id',
type: 'object', type: 'number',
http: {source: 'body'} description: 'The claim id',
http: {source: 'path'}
}], }],
returns: { returns: {
type: ['Object'], type: ['Object'],
root: true root: true
}, },
http: { http: {
path: `/regularizeClaim`, path: `/:id/regularizeClaim`,
verb: 'POST' verb: 'POST'
} }
}); });
Self.regularizeClaim = async(ctx, params) => { Self.regularizeClaim = async(ctx, claimFk) => {
const models = Self.app.models; const models = Self.app.models;
const $t = ctx.req.__; // $translate const $t = ctx.req.__; // $translate
const resolvedState = 3; const resolvedState = 3;
@ -31,7 +32,7 @@ module.exports = Self => {
relation: 'claimDestination', relation: 'claimDestination',
fields: ['addressFk'] fields: ['addressFk']
}, },
where: {claimFk: params.claimFk} where: {claimFk: claimFk}
}, options); }, options);
for (let i = 0; i < claimEnds.length; i++) { for (let i = 0; i < claimEnds.length; i++) {
@ -87,11 +88,32 @@ module.exports = Self => {
}, options); }, options);
} }
let claim = await Self.findById(params.claimFk, null, options); let claim = await Self.findById(claimFk, {
include: {
relation: 'client',
scope: {
include: {
relation: 'salesPerson'
}
}
}
}, options);
claim = await claim.updateAttributes({ claim = await claim.updateAttributes({
claimStateFk: resolvedState claimStateFk: resolvedState
}, options); }, options);
// Get sales person from claim client
const salesPerson = claim.client().salesPerson();
if (salesPerson) {
const origin = ctx.req.headers.origin;
const message = $t('Claim will be picked', {
claimId: claim.id,
clientName: claim.client().name,
claimUrl: `${origin}/#!/claim/${claim.id}/summary`
});
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
}
await tx.commit(); await tx.commit();
return claim; return claim;

View File

@ -1,6 +1,6 @@
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('updateClaimAction', { Self.remoteMethodCtx('updateClaimAction', {
description: 'Update a claim with privileges', description: 'Update a claim with privileges',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [{ accepts: [{
@ -10,11 +10,17 @@ module.exports = Self => {
description: 'Claim id', description: 'Claim id',
http: {source: 'path'} http: {source: 'path'}
}, { }, {
arg: 'data', arg: 'responsibility',
type: 'object', type: 'number',
required: true, required: false
description: 'Data to update on the model', }, {
http: {source: 'body'} arg: 'isChargedToMana',
type: 'boolean',
required: false
}, {
arg: 'hasToPickUp',
type: 'boolean',
required: false
}], }],
returns: { returns: {
type: 'object', type: 'object',
@ -22,22 +28,16 @@ module.exports = Self => {
}, },
http: { http: {
path: `/:id/updateClaimAction`, path: `/:id/updateClaimAction`,
verb: 'post' verb: 'patch'
} }
}); });
Self.updateClaimAction = async(id, data) => { Self.updateClaimAction = async(ctx, id) => {
let models = Self.app.models; const models = Self.app.models;
const claim = await models.Claim.findById(id);
const args = ctx.args;
delete args.ctx;
let claim = await models.Claim.findById(id); return await claim.updateAttributes(args);
let updatedData = {};
if (data.hasOwnProperty('responsibility'))
updatedData.responsibility = data.responsibility;
if (data.hasOwnProperty('isChargedToMana'))
updatedData.isChargedToMana = data.isChargedToMana;
return await claim.updateAttributes(updatedData);
}; };
}; };

View File

@ -13,7 +13,7 @@
"description": "Identifier" "description": "Identifier"
}, },
"observation": { "observation": {
"type": "String" "type": "string"
}, },
"ticketCreated": { "ticketCreated": {
"type": "date", "type": "date",
@ -26,16 +26,19 @@
"type": "date" "type": "date"
}, },
"responsibility": { "responsibility": {
"type": "Number" "type": "number"
},
"hasToPickUp": {
"type": "boolean"
}, },
"ticketFk": { "ticketFk": {
"type": "Number" "type": "number"
}, },
"claimStateFk": { "claimStateFk": {
"type": "Number" "type": "number"
}, },
"workerFk": { "workerFk": {
"type": "Number" "type": "number"
} }
}, },
"relations": { "relations": {

View File

@ -42,15 +42,18 @@
max="$ctrl.maxResponsibility" max="$ctrl.maxResponsibility"
min="1" min="1"
step="1" step="1"
vn-acl="salesAssistant" on-change="$ctrl.save({responsibility: value})">
on-change="$ctrl.saveResponsibility(value)">
</vn-range> </vn-range>
</vn-tool-bar> </vn-tool-bar>
<vn-check vn-one class="vn-mr-md"
label="Pickup"
ng-model="::$ctrl.claim.hasToPickUp"
on-change="$ctrl.save({hasToPickUp: value})">
</vn-check>
<vn-check vn-one <vn-check vn-one
label="Is paid with mana" label="Is paid with mana"
ng-model="$ctrl.claim.isChargedToMana" ng-model="$ctrl.claim.isChargedToMana"
vn-acl="salesAssistant" on-change="$ctrl.save({isChargedToMana: value})">
on-change="$ctrl.saveMana(value)">
</vn-check> </vn-check>
</section> </section>

View File

@ -116,8 +116,8 @@ export default class Controller extends Section {
} }
regularize() { regularize() {
let data = {claimFk: this.$params.id}; let data = {hasToPickUp: this.hasToPickUp};
let query = `Claims/regularizeClaim`; let query = `Claims/${this.$params.id}/regularizeClaim`;
return this.$http.post(query, data).then(() => { return this.$http.post(query, data).then(() => {
if (this.claim.responsibility >= Math.ceil(this.maxResponsibility) / 2) if (this.claim.responsibility >= Math.ceil(this.maxResponsibility) / 2)
this.$.updateGreuge.show(); this.$.updateGreuge.show();
@ -179,18 +179,9 @@ export default class Controller extends Section {
this.$.descriptor.show(); this.$.descriptor.show();
} }
saveResponsibility(value) { save(data) {
let query = `Claims/${this.$params.id}/updateClaimAction`; const query = `Claims/${this.$params.id}/updateClaimAction`;
this.$http.patch(query, data).then(() => {
this.$http.post(query, {responsibility: value}).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
saveMana(value) {
let query = `Claims/${this.$params.id}/updateClaimAction`;
this.$http.post(query, {isChargedToMana: value}).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!')); this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}); });
} }

View File

@ -10,3 +10,4 @@ Do you want to insert greuges?: Desea insertar greuges?
Insert greuges on client card: Insertar greuges en la ficha del cliente Insert greuges on client card: Insertar greuges en la ficha del cliente
Greuge inserted: Greuge insertado Greuge inserted: Greuge insertado
ClaimGreugeDescription: Reclamación id {{claimId}} ClaimGreugeDescription: Reclamación id {{claimId}}
Pickup: Recoger