From ddc19ddbcd2b11a9aa813cf5c0e063b4f360a10f Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 28 Apr 2021 11:15:02 +0200 Subject: [PATCH] enpoint now receives all data for a buy + css refactor --- front/core/components/chip/style.scss | 4 +- modules/entry/back/methods/entry/addBuy.js | 43 ++++++++++++++++++---- modules/entry/front/latest-buys/index.html | 4 +- modules/entry/front/summary/index.html | 4 +- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/front/core/components/chip/style.scss b/front/core/components/chip/style.scss index c89cf2b828..f6e4a388f9 100644 --- a/front/core/components/chip/style.scss +++ b/front/core/components/chip/style.scss @@ -21,8 +21,8 @@ vn-chip { } } - &.white { - background-color: $color-bg-panel; + &.transparent { + background-color: transparent; } &.colored { background-color: $color-main; diff --git a/modules/entry/back/methods/entry/addBuy.js b/modules/entry/back/methods/entry/addBuy.js index 015a6fc23a..a7d2f46461 100644 --- a/modules/entry/back/methods/entry/addBuy.js +++ b/modules/entry/back/methods/entry/addBuy.js @@ -3,7 +3,7 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; module.exports = Self => { Self.remoteMethodCtx('addBuy', { - description: 'Inserts or updates buy for the current entry', + description: 'Inserts a new buy for the current entry', accessType: 'WRITE', accepts: [{ arg: 'id', @@ -26,6 +26,34 @@ module.exports = Self => { arg: 'packageFk', type: 'string', required: true + }, + { + arg: 'packing', + type: 'number', + }, + { + arg: 'grouping', + type: 'number' + }, + { + arg: 'weight', + type: 'number', + }, + { + arg: 'stickers', + type: 'number', + }, + { + arg: 'price2', + type: 'number', + }, + { + arg: 'price3', + type: 'number', + }, + { + arg: 'buyingValue', + type: 'number' }], returns: { type: 'object', @@ -53,12 +81,13 @@ module.exports = Self => { try { const models = Self.app.models; - const newBuy = await models.Buy.create({ - itemFk: ctx.args.itemFk, - entryFk: ctx.args.id, - packageFk: ctx.args.packageFk, - quantity: ctx.args.quantity - }, myOptions); + ctx.args.entryFk = ctx.args.id; + + // remove unwanted properties + delete ctx.args.id; + delete ctx.args.ctx; + + const newBuy = await models.Buy.create(ctx.args, myOptions); let filter = { fields: [ diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index a8fac79609..277b1b3475 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -83,12 +83,12 @@ - + {{::buy.packing | dashIfEmpty}} - + {{::buy.grouping | dashIfEmpty}} diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 8b31df0b27..24cedcdb20 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -102,12 +102,12 @@ {{::line.packageFk | dashIfEmpty}} {{::line.weight}} - + {{::line.packing | dashIfEmpty}} - + {{::line.grouping | dashIfEmpty}}