2879 - Autocomplete item field from imported buys
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
4eabba115f
commit
ff71e6f2c7
|
@ -0,0 +1,14 @@
|
||||||
|
create table `vn`.`buyImportReference`
|
||||||
|
(
|
||||||
|
itemFk int not null,
|
||||||
|
name varchar(80) not null,
|
||||||
|
company varchar(80) not null,
|
||||||
|
size int not null,
|
||||||
|
constraint buyImportReference_pk
|
||||||
|
primary key (itemFk, name, company, size),
|
||||||
|
constraint itemFk___fk
|
||||||
|
foreign key (itemFk) references item (id)
|
||||||
|
on update cascade on delete cascade
|
||||||
|
)
|
||||||
|
comment 'Referencias de compras importadas';
|
||||||
|
|
|
@ -71,6 +71,13 @@ module.exports = Self => {
|
||||||
buyingValue: buy.buyingValue,
|
buyingValue: buy.buyingValue,
|
||||||
packageFk: buy.packageFk
|
packageFk: buy.packageFk
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await models.BuyImportReference.upsert({
|
||||||
|
itemFk: buy.itemFk,
|
||||||
|
name: buy.description,
|
||||||
|
company: buy.companyName,
|
||||||
|
size: buy.size
|
||||||
|
}, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
const createdBuys = await models.Buy.create(buys, options);
|
const createdBuys = await models.Buy.create(buys, options);
|
||||||
|
|
|
@ -37,7 +37,21 @@ module.exports = Self => {
|
||||||
where: {volume: {gte: buy.volume}},
|
where: {volume: {gte: buy.volume}},
|
||||||
order: 'volume ASC'
|
order: 'volume ASC'
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
buy.packageFk = packaging.id;
|
|
||||||
|
if (packaging)
|
||||||
|
buy.packageFk = packaging.id;
|
||||||
|
|
||||||
|
const reference = await models.BuyImportReference.findOne({
|
||||||
|
fields: ['itemFk'],
|
||||||
|
where: {
|
||||||
|
name: buy.description,
|
||||||
|
company: buy.companyName,
|
||||||
|
size: buy.size
|
||||||
|
}
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
|
if (reference)
|
||||||
|
buy.itemFk = reference.itemFk;
|
||||||
}
|
}
|
||||||
|
|
||||||
return buys;
|
return buys;
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
"Buy": {
|
"Buy": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"BuyImportReference": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"EntryLog": {
|
"EntryLog": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
"name": "BuyImportReference",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "buyImportReference"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"itemFk": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"company": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"item": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Item",
|
||||||
|
"foreignKey": "itemFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,20 +9,6 @@
|
||||||
class="vn-ma-md">
|
class="vn-ma-md">
|
||||||
<div class="vn-w-lg">
|
<div class="vn-w-lg">
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-horizontal>
|
|
||||||
<vn-textfield vn-focus
|
|
||||||
vn-one
|
|
||||||
label="Reference"
|
|
||||||
ng-model="$ctrl.import.ref">
|
|
||||||
</vn-textfield>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-textarea
|
|
||||||
vn-one
|
|
||||||
label="Observation"
|
|
||||||
ng-model="$ctrl.import.observation">
|
|
||||||
</vn-textarea>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-input-file
|
<vn-input-file
|
||||||
vn-one
|
vn-one
|
||||||
|
@ -40,6 +26,20 @@
|
||||||
</append>
|
</append>
|
||||||
</vn-input-file>
|
</vn-input-file>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
<vn-horizontal ng-show="$ctrl.import.ref">
|
||||||
|
<vn-textfield vn-focus
|
||||||
|
vn-one
|
||||||
|
label="Reference"
|
||||||
|
ng-model="$ctrl.import.ref">
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal ng-show="$ctrl.import.observation">
|
||||||
|
<vn-textarea
|
||||||
|
vn-one
|
||||||
|
label="Observation"
|
||||||
|
ng-model="$ctrl.import.observation">
|
||||||
|
</vn-textarea>
|
||||||
|
</vn-horizontal>
|
||||||
<vn-horizontal ng-show="$ctrl.import.buys.length > 0">
|
<vn-horizontal ng-show="$ctrl.import.buys.length > 0">
|
||||||
<table class="vn-table">
|
<table class="vn-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -51,7 +51,6 @@
|
||||||
<th translate center>Grouping</th>
|
<th translate center>Grouping</th>
|
||||||
<th translate center>Buying value</th>
|
<th translate center>Buying value</th>
|
||||||
<th translate center>Box</th>
|
<th translate center>Box</th>
|
||||||
<th translate center>Volume</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody ng-repeat="buy in $ctrl.import.buys">
|
<tbody ng-repeat="buy in $ctrl.import.buys">
|
||||||
|
@ -74,16 +73,8 @@
|
||||||
</td>
|
</td>
|
||||||
<td title="{{::buy.description}}" expand>{{::buy.description | dashIfEmpty}}</td>
|
<td title="{{::buy.description}}" expand>{{::buy.description | dashIfEmpty}}</td>
|
||||||
<td center title="{{::buy.size}}">{{::buy.size | dashIfEmpty}}</td>
|
<td center title="{{::buy.size}}">{{::buy.size | dashIfEmpty}}</td>
|
||||||
<td center>
|
<td center>{{::buy.packing | dashIfEmpty}}</td>
|
||||||
<vn-chip>
|
<td center>{{::buy.grouping | dashIfEmpty}}</td>
|
||||||
<span>{{::buy.packing | dashIfEmpty}}</span>
|
|
||||||
</vn-chip>
|
|
||||||
</td>
|
|
||||||
<td center>
|
|
||||||
<vn-chip>
|
|
||||||
<span>{{::buy.grouping | dashIfEmpty}}</span>
|
|
||||||
</vn-chip>
|
|
||||||
</vn-td>
|
|
||||||
<td>{{::buy.buyingValue | currency: 'EUR':2}}</td>
|
<td>{{::buy.buyingValue | currency: 'EUR':2}}</td>
|
||||||
<td center title="{{::buy.packageFk | dashIfEmpty}}">
|
<td center title="{{::buy.packageFk | dashIfEmpty}}">
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
@ -95,7 +86,6 @@
|
||||||
ng-model="buy.packageFk">
|
ng-model="buy.packageFk">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</td>
|
</td>
|
||||||
<td center title="{{::buy.volume}}">{{::buy.volume | number}}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -29,6 +29,7 @@ class Controller extends Section {
|
||||||
this.$.$applyAsync(() => {
|
this.$.$applyAsync(() => {
|
||||||
this.import.observation = invoice.tx_awb;
|
this.import.observation = invoice.tx_awb;
|
||||||
|
|
||||||
|
const companyName = invoice.tx_company;
|
||||||
const boxes = invoice.boxes;
|
const boxes = invoice.boxes;
|
||||||
const buys = [];
|
const buys = [];
|
||||||
for (let box of boxes) {
|
for (let box of boxes) {
|
||||||
|
@ -37,11 +38,12 @@ class Controller extends Section {
|
||||||
const packing = product.nu_stems_bunch * product.nu_bunches;
|
const packing = product.nu_stems_bunch * product.nu_bunches;
|
||||||
buys.push({
|
buys.push({
|
||||||
description: product.nm_product,
|
description: product.nm_product,
|
||||||
|
companyName: companyName,
|
||||||
size: product.nu_length,
|
size: product.nu_length,
|
||||||
packing: packing,
|
packing: packing,
|
||||||
grouping: product.nu_stems_bunch,
|
grouping: product.nu_stems_bunch,
|
||||||
buyingValue: parseFloat(product.mny_rate_stem),
|
buyingValue: parseFloat(product.mny_rate_stem),
|
||||||
volume: boxVolume
|
volume: boxVolume,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue