Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2438-export_production
This commit is contained in:
commit
d91a354e4e
|
@ -894,6 +894,7 @@ export default {
|
||||||
header: 'vn-entry-summary > vn-card > h5',
|
header: 'vn-entry-summary > vn-card > h5',
|
||||||
reference: 'vn-entry-summary vn-label-value[label="Reference"]',
|
reference: 'vn-entry-summary vn-label-value[label="Reference"]',
|
||||||
confirmed: 'vn-entry-summary vn-check[label="Confirmed"]',
|
confirmed: 'vn-entry-summary vn-check[label="Confirmed"]',
|
||||||
|
anyBuyLine: 'vn-entry-summary tr.dark-row'
|
||||||
},
|
},
|
||||||
entryDescriptor: {
|
entryDescriptor: {
|
||||||
agency: 'vn-entry-descriptor div.body vn-label-value:nth-child(1) span',
|
agency: 'vn-entry-descriptor div.body vn-label-value:nth-child(1) span',
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe('Entry summary path', () => {
|
||||||
browser = await getBrowser();
|
browser = await getBrowser();
|
||||||
page = browser.page;
|
page = browser.page;
|
||||||
await page.loginAndModule('buyer', 'entry');
|
await page.loginAndModule('buyer', 'entry');
|
||||||
await page.waitToClick('vn-entry-index vn-tbody > a:nth-child(2)');
|
await page.accessToSearchResult('4');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async() => {
|
||||||
|
@ -30,7 +30,7 @@ describe('Entry summary path', () => {
|
||||||
it('should display some entry details like the reference', async() => {
|
it('should display some entry details like the reference', async() => {
|
||||||
const result = await page.waitToGetProperty(selectors.entrySummary.reference, 'innerText');
|
const result = await page.waitToGetProperty(selectors.entrySummary.reference, 'innerText');
|
||||||
|
|
||||||
expect(result).toContain('Movement 2');
|
expect(result).toContain('Movement 4');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display other entry details like the confirmed', async() => {
|
it('should display other entry details like the confirmed', async() => {
|
||||||
|
@ -38,4 +38,10 @@ describe('Entry summary path', () => {
|
||||||
|
|
||||||
expect(result).toContain('unchecked');
|
expect(result).toContain('unchecked');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should display all buys for the entry', async() => {
|
||||||
|
const result = await page.countElement(selectors.entrySummary.anyBuyLine);
|
||||||
|
|
||||||
|
expect(result).toEqual(4);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('getBuys', {
|
||||||
|
description: 'Returns buys for one entry',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: {
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The entry id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
},
|
||||||
|
returns: {
|
||||||
|
type: ['Object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/getBuys`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getBuys = async id => {
|
||||||
|
let filter = {
|
||||||
|
where: {entryFk: id},
|
||||||
|
fields: [
|
||||||
|
'id',
|
||||||
|
'itemFk',
|
||||||
|
'stickers',
|
||||||
|
'packing',
|
||||||
|
'grouping',
|
||||||
|
'quantity',
|
||||||
|
'packageFk',
|
||||||
|
'weight',
|
||||||
|
'buyingValue',
|
||||||
|
'price2',
|
||||||
|
'price3'
|
||||||
|
],
|
||||||
|
include: {
|
||||||
|
relation: 'item',
|
||||||
|
scope: {
|
||||||
|
fields: [
|
||||||
|
'id',
|
||||||
|
'typeFk',
|
||||||
|
'name',
|
||||||
|
'size',
|
||||||
|
'minPrice',
|
||||||
|
'tag5',
|
||||||
|
'value5',
|
||||||
|
'tag6',
|
||||||
|
'value6',
|
||||||
|
'tag7',
|
||||||
|
'value7',
|
||||||
|
'tag8',
|
||||||
|
'value8',
|
||||||
|
'tag9',
|
||||||
|
'value9',
|
||||||
|
'tag10',
|
||||||
|
'value10',
|
||||||
|
'groupingMode'
|
||||||
|
],
|
||||||
|
include: {
|
||||||
|
relation: 'itemType',
|
||||||
|
scope: {
|
||||||
|
fields: ['code', 'description']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let buys = await Self.app.models.Buy.find(filter);
|
||||||
|
return buys;
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,14 @@
|
||||||
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('entry getBuys()', () => {
|
||||||
|
const entryId = 4;
|
||||||
|
it('should get the buys and items of an entry', async() => {
|
||||||
|
const result = await app.models.Entry.getBuys(entryId);
|
||||||
|
|
||||||
|
const length = result.length;
|
||||||
|
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
||||||
|
|
||||||
|
expect(result.length).toEqual(4);
|
||||||
|
expect(anyResult.item).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
|
@ -31,6 +31,12 @@
|
||||||
"grouping": {
|
"grouping": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"stickers": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"packageFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
"groupingMode": {
|
"groupingMode": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
@ -56,6 +62,12 @@
|
||||||
"model": "Entry",
|
"model": "Entry",
|
||||||
"foreignKey": "entryFk",
|
"foreignKey": "entryFk",
|
||||||
"required": true
|
"required": true
|
||||||
|
},
|
||||||
|
"item": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Item",
|
||||||
|
"foreignKey": "itemFk",
|
||||||
|
"required": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/entry/filter')(Self);
|
require('../methods/entry/filter')(Self);
|
||||||
require('../methods/entry/getEntry')(Self);
|
require('../methods/entry/getEntry')(Self);
|
||||||
|
require('../methods/entry/getBuys')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,8 +19,12 @@
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
<vn-one>
|
<vn-one>
|
||||||
<vn-label-value label="Agency"
|
<vn-label-value label="Agency">
|
||||||
value="{{$ctrl.entryData.travel.agency.name}}">
|
<span
|
||||||
|
ng-click="travelDescriptor.show($event, $ctrl.entry.travel.agencyFk)"
|
||||||
|
class="link">
|
||||||
|
{{$ctrl.entryData.travel.agency.name}}
|
||||||
|
</span>
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value label="Shipped"
|
<vn-label-value label="Shipped"
|
||||||
value="{{$ctrl.entryData.travel.shipped | date: 'dd/MM/yyyy'}}">
|
value="{{$ctrl.entryData.travel.shipped | date: 'dd/MM/yyyy'}}">
|
||||||
|
@ -65,4 +69,89 @@
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-auto name="buys">
|
||||||
|
<h4 translate>Buys</h4>
|
||||||
|
<table class="vn-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th translate center field="quantity">Quantity</th>
|
||||||
|
<th translate center field="sticker">Stickers</th>
|
||||||
|
<th translate center field="packageFk">Package</th>
|
||||||
|
<th translate center field="weight">Weight</th>
|
||||||
|
<th translate center field="packing">Packing</th>
|
||||||
|
<th translate center field="grouping">Grouping</th>
|
||||||
|
<th translate center field="buyingValue">Buying value</th>
|
||||||
|
<th translate center field="price3">Import</th>
|
||||||
|
<th translate center expand field="price2">Grouping price</th>
|
||||||
|
<th translate center expand field="price3">Packing price</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody ng-repeat="line in $ctrl.buys">
|
||||||
|
<tr>
|
||||||
|
<td center title="{{::line.quantity}}">{{::line.quantity}}</td>
|
||||||
|
<td center title="{{::line.stickers | dashIfEmpty}}">{{::line.stickers | dashIfEmpty}}</td>
|
||||||
|
<td center title="{{::line.packageFk | dashIfEmpty}}">{{::line.packageFk | dashIfEmpty}}</td>
|
||||||
|
<td center title="{{::line.weight}}">{{::line.weight}}</td>
|
||||||
|
<td center>
|
||||||
|
<vn-chip 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 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>
|
||||||
|
<td center title="{{::line.buyingValue | currency: 'EUR':2}}">{{::line.buyingValue | currency: 'EUR':2}}</td>
|
||||||
|
<td center title="{{::line.quantity * line.buyingValue | currency: 'EUR':2}}">{{::line.quantity * line.buyingValue | currency: 'EUR':2}}</td>
|
||||||
|
<td center title="{{::line.price2 | currency: 'EUR':2}}">{{::line.price2 | currency: 'EUR':2}}</td>
|
||||||
|
<td center title="{{::line.price3 | currency: 'EUR':2}}">{{::line.price3 | currency: 'EUR':2}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="dark-row">
|
||||||
|
<td shrink>
|
||||||
|
<span
|
||||||
|
translate-attr="{title: 'Item type'}">
|
||||||
|
{{::line.item.itemType.code}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td shrink>
|
||||||
|
<span
|
||||||
|
ng-click="itemDescriptor.show($event, line.item.id)"
|
||||||
|
class="link">
|
||||||
|
{{::line.item.id | zeroFill:6}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td number shrink>
|
||||||
|
<span
|
||||||
|
translate-attr="{title: 'Item size'}">
|
||||||
|
{{::line.item.size}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td center>
|
||||||
|
<span
|
||||||
|
translate-attr="{title: 'Minimum price'}">
|
||||||
|
{{::line.item.minPrice | currency: 'EUR':2}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td expand colspan="6">
|
||||||
|
<vn-fetched-tags
|
||||||
|
expand
|
||||||
|
item="::line.item"
|
||||||
|
name="::line.item.name"
|
||||||
|
sub-name="::line.item.subName">
|
||||||
|
</vn-fetched-tags>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</vn-auto>
|
||||||
|
</vn-horizontal>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
<vn-item-descriptor-popover
|
||||||
|
vn-id="itemDescriptor">
|
||||||
|
</vn-item-descriptor-popover>
|
||||||
|
<vn-travel-descriptor-popover
|
||||||
|
vn-id="travelDescriptor">
|
||||||
|
</vn-travel-descriptor-popover>
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,23 @@ class Controller extends Section {
|
||||||
set entry(value) {
|
set entry(value) {
|
||||||
this._entry = value;
|
this._entry = value;
|
||||||
|
|
||||||
if (value && value.id)
|
if (value && value.id) {
|
||||||
this.getEntryData();
|
this.getEntryData();
|
||||||
|
this.getBuys();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getEntryData() {
|
getEntryData() {
|
||||||
return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => {
|
return this.$http.get(`Entries/${this.entry.id}/getEntry`).then(response => {
|
||||||
this.entryData = response.data;
|
this.entryData = response.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBuys() {
|
||||||
|
return this.$http.get(`Entries/${this.entry.id}/getBuys`).then(response => {
|
||||||
|
this.buys = response.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnEntrySummary', {
|
ngModule.vnComponent('vnEntrySummary', {
|
||||||
|
|
|
@ -38,7 +38,7 @@ describe('component vnEntrySummary', () => {
|
||||||
it('should perform a get and then store data on the controller', () => {
|
it('should perform a get and then store data on the controller', () => {
|
||||||
controller._entry = {id: 999};
|
controller._entry = {id: 999};
|
||||||
|
|
||||||
const query = `/api/Entries/${controller._entry.id}/getEntry`;
|
const query = `Entries/${controller._entry.id}/getEntry`;
|
||||||
$httpBackend.expectGET(query).respond('I am the entryData');
|
$httpBackend.expectGET(query).respond('I am the entryData');
|
||||||
controller.getEntryData();
|
controller.getEntryData();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -46,4 +46,20 @@ describe('component vnEntrySummary', () => {
|
||||||
expect(controller.entryData).toEqual('I am the entryData');
|
expect(controller.entryData).toEqual('I am the entryData');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getBuys()', () => {
|
||||||
|
it('should perform a get asking for the buys of an entry', () => {
|
||||||
|
controller._entry = {id: 999};
|
||||||
|
|
||||||
|
const thatQuery = `Entries/${controller._entry.id}/getEntry`;
|
||||||
|
const query = `Entries/${controller._entry.id}/getBuys`;
|
||||||
|
|
||||||
|
$httpBackend.whenGET(thatQuery).respond('My Entries');
|
||||||
|
$httpBackend.expectGET(query).respond('Some buys');
|
||||||
|
controller.getBuys();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.buys).toEqual('Some buys');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
Inventory: Inventario
|
Inventory: Inventario
|
||||||
Virtual: Redada
|
Virtual: Redada
|
||||||
Entry: Entrada
|
Entry: Entrada
|
||||||
|
Stickers: Etiquetas
|
||||||
|
Item size: Tamaño
|
||||||
|
Item type: Tipo
|
||||||
|
Minimum price: Precio mínimo
|
||||||
|
Buys: Compras
|
||||||
|
|
|
@ -3,4 +3,18 @@
|
||||||
|
|
||||||
vn-entry-summary .summary {
|
vn-entry-summary .summary {
|
||||||
max-width: $width-lg;
|
max-width: $width-lg;
|
||||||
|
|
||||||
|
.dark-row {
|
||||||
|
background-color: lighten($color-marginal, 10%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tbody {
|
||||||
|
border: 2px solid $color-marginal;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$color-font-link-medium: lighten($color-font-link, 20%)
|
Loading…
Reference in New Issue