enpoint now receives all data for a buy + css refactor

This commit is contained in:
Carlos Jimenez Ruiz 2021-04-28 11:15:02 +02:00
parent 65457d6dac
commit ddc19ddbcd
4 changed files with 42 additions and 13 deletions

View File

@ -21,8 +21,8 @@ vn-chip {
}
}
&.white {
background-color: $color-bg-panel;
&.transparent {
background-color: transparent;
}
&.colored {
background-color: $color-main;

View File

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

View File

@ -83,12 +83,12 @@
</span>
</vn-td>
<vn-td number>
<vn-chip class="white" translate-attr="buy.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': buy.groupingMode == 2}">
<vn-chip class="transparent" translate-attr="buy.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': buy.groupingMode == 2}">
<span translate>{{::buy.packing | dashIfEmpty}}</span>
</vn-chip>
</vn-td>
<vn-td number>
<vn-chip class="white" translate-attr="buy.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': buy.groupingMode == 1}">
<vn-chip class="transparent" translate-attr="buy.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': buy.groupingMode == 1}">
<span translate>{{::buy.grouping | dashIfEmpty}}</span>
</vn-chip>
</vn-td>

View File

@ -102,12 +102,12 @@
<td center title="{{::line.packageFk | dashIfEmpty}}">{{::line.packageFk | dashIfEmpty}}</td>
<td center title="{{::line.weight}}">{{::line.weight}}</td>
<td center>
<vn-chip class="white" translate-attr="line.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 2}">
<vn-chip class="transparent" translate-attr="line.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 2}">
<span translate>{{::line.packing | dashIfEmpty}}</span>
</vn-chip>
</td>
<td center>
<vn-chip class="white" translate-attr="line.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': line.groupingMode == 1}">
<vn-chip class="transparent" translate-attr="line.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': line.groupingMode == 1}">
<span translate>{{::line.grouping | dashIfEmpty}}</span>
</vn-chip>
</vn-td>