Requested changes
This commit is contained in:
parent
e29dd4db42
commit
be37334f49
|
@ -13,7 +13,7 @@
|
||||||
</section>
|
</section>
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
accept="{{$ctrl.acceptTypes}}"
|
accept="{{$ctrl.accept}}"
|
||||||
style="display: none;">
|
style="display: none;">
|
||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -69,7 +69,7 @@ module.exports = Self => {
|
||||||
packing: buy.packing,
|
packing: buy.packing,
|
||||||
grouping: buy.grouping,
|
grouping: buy.grouping,
|
||||||
buyingValue: buy.buyingValue,
|
buyingValue: buy.buyingValue,
|
||||||
packageFk: 1
|
packageFk: buy.packageFk
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,6 @@ describe('entry import()', () => {
|
||||||
expect(entryBuys.length).toEqual(2);
|
expect(entryBuys.length).toEqual(2);
|
||||||
|
|
||||||
// Restores
|
// Restores
|
||||||
await newEntry.destroy(options);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@ const app = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('entry importBuysPreview()', () => {
|
describe('entry importBuysPreview()', () => {
|
||||||
|
const entryId = 1;
|
||||||
beforeAll(async done => {
|
beforeAll(async done => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
active: activeCtx
|
active: activeCtx
|
||||||
|
@ -30,7 +31,7 @@ describe('entry importBuysPreview()', () => {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const result = await app.models.Entry.importBuysPreview(1, buys);
|
const result = await app.models.Entry.importBuysPreview(entryId, buys);
|
||||||
const randomIndex = Math.floor(Math.random() * result.length);
|
const randomIndex = Math.floor(Math.random() * result.length);
|
||||||
const buy = result[randomIndex];
|
const buy = result[randomIndex];
|
||||||
|
|
||||||
|
|
|
@ -75,13 +75,13 @@
|
||||||
<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>
|
||||||
<vn-chip translate-attr="line.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 2}">
|
<vn-chip>
|
||||||
<span translate>{{::buy.packing | dashIfEmpty}}</span>
|
<span>{{::buy.packing | dashIfEmpty}}</span>
|
||||||
</vn-chip>
|
</vn-chip>
|
||||||
</td>
|
</td>
|
||||||
<td center>
|
<td center>
|
||||||
<vn-chip translate-attr="line.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': line.groupingMode == 1}">
|
<vn-chip>
|
||||||
<span translate>{{::buy.grouping | dashIfEmpty}}</span>
|
<span>{{::buy.grouping | dashIfEmpty}}</span>
|
||||||
</vn-chip>
|
</vn-chip>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<td>{{::buy.buyingValue | currency: 'EUR':2}}</td>
|
<td>{{::buy.buyingValue | currency: 'EUR':2}}</td>
|
||||||
|
@ -108,7 +108,8 @@
|
||||||
<vn-button
|
<vn-button
|
||||||
class="cancel"
|
class="cancel"
|
||||||
label="Cancel"
|
label="Cancel"
|
||||||
ui-sref="entry.card.buy.index"></vn-button>
|
ui-sref="entry.card.buy.index">
|
||||||
|
</vn-button>
|
||||||
</vn-button>
|
</vn-button>
|
||||||
</vn-button-bar>
|
</vn-button-bar>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -62,11 +62,23 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
|
try {
|
||||||
const params = this.import;
|
const params = this.import;
|
||||||
|
const hasAnyEmptyRow = params.buys.some(buy => {
|
||||||
|
return buy.itemFk == null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasAnyEmptyRow)
|
||||||
|
throw new Error(`Some of the imported buys doesn't have an item`);
|
||||||
|
|
||||||
const query = `Entries/${this.entry.id}/importBuys`;
|
const query = `Entries/${this.entry.id}/importBuys`;
|
||||||
return this.$http.post(query, params)
|
return this.$http.post(query, params)
|
||||||
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')))
|
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')))
|
||||||
.then(() => this.$state.go('entry.card.buy.index'));
|
.then(() => this.$state.go('entry.card.buy.index'));
|
||||||
|
} catch (e) {
|
||||||
|
this.vnApp.showError(this.$t(e.message));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
itemSearchFunc($search) {
|
itemSearchFunc($search) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
reference: Referencia
|
reference: Referencia
|
||||||
Observation: Observación
|
Observation: Observación
|
||||||
Box: Embalage
|
Box: Embalaje
|
||||||
Import buys: Importar compras
|
Import buys: Importar compras
|
||||||
|
Some of the imported buys doesn't have an item: Algunas de las compras importadas no tienen un artículo
|
Loading…
Reference in New Issue