2525 - Ticket basic data validate zone
gitea/salix/pipeline/head There was a failure building this commit Details

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

View File

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

View File

@ -37,9 +37,12 @@ module.exports = Self => {
Self.getLanded = async(ctx, shipped, addressFk, agencyModeFk, warehouseFk) => {
const userId = ctx.req.accessToken.userId;
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;
if (isProductionBoss) showExpired = true;
if (canSeeExpired.length) showExpired = true;
let stmts = [];
stmts.push(new ParameterizedSQL(

View File

@ -32,9 +32,12 @@ module.exports = Self => {
&& where.agencyModeFk && where.warehouseFk;
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;
if (isProductionBoss) showExpired = true;
if (canSeeExpired.length) showExpired = true;
stmt = new ParameterizedSQL(`CALL vn.zone_getLanded(?, ?, ?, ?, ?)`, [
where.shipped,