2525 - Ticket basic data validate zone

This commit is contained in:
Joan Sanchez 2020-10-20 10:19:12 +02:00
parent 2842b66cbd
commit d68aacc78a
3 changed files with 32 additions and 10 deletions

View File

@ -56,8 +56,16 @@ class Controller extends Component {
set warehouseId(value) { set warehouseId(value) {
if (value != this.ticket.warehouseFk) { if (value != this.ticket.warehouseFk) {
this.ticket.warehouseFk = value; this.ticket.warehouseFk = value;
this.getShipped({
landed: this.ticket.landed,
addressFk: this.ticket.addressFk,
agencyModeFk: this.ticket.agencyModeFk,
warehouseFk: value
}).then(() => {
if (this.zoneId == null)
this.ticket.agencyModeFk = null; this.ticket.agencyModeFk = null;
this.ticket.zoneFk = null; });
} }
} }
@ -177,8 +185,8 @@ class Controller extends Component {
); );
} }
let query = `tickets/${this.ticket.id}/priceDifference`; const query = `tickets/${this.ticket.id}/priceDifference`;
let params = { const params = {
landed: this.ticket.landed, landed: this.ticket.landed,
addressId: this.ticket.addressFk, addressId: this.ticket.addressFk,
agencyModeId: this.ticket.agencyModeFk, agencyModeId: this.ticket.agencyModeFk,
@ -202,9 +210,13 @@ class Controller extends Component {
* Returns a landing date * Returns a landing date
*/ */
getLanded(params) { getLanded(params) {
const validParams = this.shipped && this.addressId
&& this.agencyModeId && this.warehouseId;
if (!validParams) return this.$q.resolve();
this.ticket.zoneFk = null; this.ticket.zoneFk = null;
const query = `Agencies/getLanded`; const query = `Agencies/getLanded`;
this.$http.get(query, {params}).then(res => { return this.$http.get(query, {params}).then(res => {
if (res.data) { if (res.data) {
this.ticket.zoneFk = res.data.zoneFk; this.ticket.zoneFk = res.data.zoneFk;
this.ticket.landed = res.data.landed; this.ticket.landed = res.data.landed;
@ -221,9 +233,13 @@ class Controller extends Component {
* Returns a shipment date * Returns a shipment date
*/ */
getShipped(params) { getShipped(params) {
const validParams = this.landed && this.addressId
&& this.agencyModeId && this.warehouseId;
if (!validParams) return this.$q.resolve();
this.ticket.zoneFk = null; this.ticket.zoneFk = null;
const query = `Agencies/getShipped`; const query = `Agencies/getShipped`;
this.$http.get(query, {params}).then(res => { return this.$http.get(query, {params}).then(res => {
if (res.data) { if (res.data) {
this.ticket.zoneFk = res.data.zoneFk; this.ticket.zoneFk = res.data.zoneFk;
this.ticket.landed = params.landed; this.ticket.landed = params.landed;

View File

@ -37,9 +37,12 @@ module.exports = Self => {
Self.getLanded = async(ctx, shipped, addressFk, agencyModeFk, warehouseFk) => { Self.getLanded = async(ctx, shipped, addressFk, agencyModeFk, warehouseFk) => {
const userId = ctx.req.accessToken.userId; const userId = ctx.req.accessToken.userId;
const models = Self.app.models; const models = Self.app.models;
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss'); const roles = await models.Account.getRoles(userId);
const canSeeExpired = roles.filter(role =>
role == 'productionBoss' || role == 'administrative'
);
let showExpired = false; let showExpired = false;
if (isProductionBoss) showExpired = true; if (canSeeExpired.length) showExpired = true;
let stmts = []; let stmts = [];
stmts.push(new ParameterizedSQL( stmts.push(new ParameterizedSQL(

View File

@ -32,9 +32,12 @@ module.exports = Self => {
&& where.agencyModeFk && where.warehouseFk; && where.agencyModeFk && where.warehouseFk;
if (filterByAvailability) { if (filterByAvailability) {
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss'); const roles = await models.Account.getRoles(userId);
const canSeeExpired = roles.filter(role =>
role == 'productionBoss' || role == 'administrative'
);
let showExpired = false; let showExpired = false;
if (isProductionBoss) showExpired = true; if (canSeeExpired.length) showExpired = true;
stmt = new ParameterizedSQL(`CALL vn.zone_getLanded(?, ?, ?, ?, ?)`, [ stmt = new ParameterizedSQL(`CALL vn.zone_getLanded(?, ?, ?, ?, ?)`, [
where.shipped, where.shipped,