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,
|
||||
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);
|
||||
|
|
|
@ -37,7 +37,21 @@ module.exports = Self => {
|
|||
where: {volume: {gte: buy.volume}},
|
||||
order: 'volume ASC'
|
||||
}, 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;
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
"Buy": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"BuyImportReference": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"EntryLog": {
|
||||
"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">
|
||||
<div class="vn-w-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-input-file
|
||||
vn-one
|
||||
|
@ -40,6 +26,20 @@
|
|||
</append>
|
||||
</vn-input-file>
|
||||
</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">
|
||||
<table class="vn-table">
|
||||
<thead>
|
||||
|
@ -51,7 +51,6 @@
|
|||
<th translate center>Grouping</th>
|
||||
<th translate center>Buying value</th>
|
||||
<th translate center>Box</th>
|
||||
<th translate center>Volume</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody ng-repeat="buy in $ctrl.import.buys">
|
||||
|
@ -74,16 +73,8 @@
|
|||
</td>
|
||||
<td title="{{::buy.description}}" expand>{{::buy.description | dashIfEmpty}}</td>
|
||||
<td center title="{{::buy.size}}">{{::buy.size | dashIfEmpty}}</td>
|
||||
<td center>
|
||||
<vn-chip>
|
||||
<span>{{::buy.packing | dashIfEmpty}}</span>
|
||||
</vn-chip>
|
||||
</td>
|
||||
<td center>
|
||||
<vn-chip>
|
||||
<span>{{::buy.grouping | dashIfEmpty}}</span>
|
||||
</vn-chip>
|
||||
</vn-td>
|
||||
<td center>{{::buy.packing | dashIfEmpty}}</td>
|
||||
<td center>{{::buy.grouping | dashIfEmpty}}</td>
|
||||
<td>{{::buy.buyingValue | currency: 'EUR':2}}</td>
|
||||
<td center title="{{::buy.packageFk | dashIfEmpty}}">
|
||||
<vn-autocomplete
|
||||
|
@ -95,7 +86,6 @@
|
|||
ng-model="buy.packageFk">
|
||||
</vn-autocomplete>
|
||||
</td>
|
||||
<td center title="{{::buy.volume}}">{{::buy.volume | number}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -29,6 +29,7 @@ class Controller extends Section {
|
|||
this.$.$applyAsync(() => {
|
||||
this.import.observation = invoice.tx_awb;
|
||||
|
||||
const companyName = invoice.tx_company;
|
||||
const boxes = invoice.boxes;
|
||||
const buys = [];
|
||||
for (let box of boxes) {
|
||||
|
@ -37,11 +38,12 @@ class Controller extends Section {
|
|||
const packing = product.nu_stems_bunch * product.nu_bunches;
|
||||
buys.push({
|
||||
description: product.nm_product,
|
||||
companyName: companyName,
|
||||
size: product.nu_length,
|
||||
packing: packing,
|
||||
grouping: product.nu_stems_bunch,
|
||||
buyingValue: parseFloat(product.mny_rate_stem),
|
||||
volume: boxVolume
|
||||
volume: boxVolume,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue