diff --git a/client/item/routes.json b/client/item/routes.json index 9d0dd3dd6..89f6b442e 100644 --- a/client/item/routes.json +++ b/client/item/routes.json @@ -121,6 +121,18 @@ "icon": "icon-transaction" }, "acl": ["employee"] + }, { + "url" : "/last-entries", + "state": "item.card.last-entries", + "component": "vn-item-last-entries", + "params": { + "item": "$ctrl.item" + }, + "menu": { + "description": "Last entries", + "icon": "icon-transaction" + }, + "acl": ["employee"] } ] } \ No newline at end of file diff --git a/client/item/src/item.js b/client/item/src/item.js index fd896c724..7b364c3a5 100644 --- a/client/item/src/item.js +++ b/client/item/src/item.js @@ -11,6 +11,7 @@ import './data'; import './tags'; import './tax'; import './history'; +import './last-entries'; import './niche'; import './botanical'; import './barcode'; diff --git a/client/item/src/last-entries/index.html b/client/item/src/last-entries/index.html new file mode 100644 index 000000000..1a2735a32 --- /dev/null +++ b/client/item/src/last-entries/index.html @@ -0,0 +1,68 @@ + + + + Last entries + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IgWarehouseLandedEntryP.P.UP.P.PLabelPackingGroupingStemsQuantityCostCubeProvider
+ + + {{entries.warehouse| dashIfEmpty}}{{entries.landed | date:'dd/MM/yyyy HH:mm'}}{{entries.entryFk | dashIfEmpty}}{{entries.price2 | dashIfEmpty}}{{entries.price3 | dashIfEmpty}}{{entries.stickers | dashIfEmpty}} +
{{entries.packing | dashIfEmpty}}
+
+
{{entries.grouping | dashIfEmpty}}
+
{{entries.stems | dashIfEmpty}}{{entries.quantity}}{{entries.buyingValue | dashIfEmpty}}{{entries.packageFk | dashIfEmpty}}{{entries.supplier | dashIfEmpty}}
No results
+
+
+ + +
diff --git a/client/item/src/last-entries/index.js b/client/item/src/last-entries/index.js new file mode 100644 index 000000000..1d721b744 --- /dev/null +++ b/client/item/src/last-entries/index.js @@ -0,0 +1,58 @@ +import ngModule from '../module'; +import './style.scss'; + +class Controller { + constructor($scope, $http) { + this.$ = $scope; + this.$http = $http; + this.entries = []; + } + + $onInit() { + this._defaultEntriesDate(); + } + + set item(value) { + this._item = value; + this._getLastEntries(this.entriesDate); + } + + get item() { + return this._item; + } + + _defaultEntriesDate() { + let defaultDate; + defaultDate = new Date(); + defaultDate.setDate(defaultDate.getDate() - 75); + this.entriesDate = defaultDate; + } + + set entriesDate(value) { + this._entriesDate = value; + this._getLastEntries(value); + } + + get entriesDate() { + return this._entriesDate; + } + + _getLastEntries(entriesDate) { + if (!entriesDate || !this.item) + return; + let filter = {itemFk: this.item.id, date: entriesDate}; + this.$http.get(`/item/api/Items/getLastEntries?filter=${JSON.stringify(filter)}`).then(res => { + this.entries = res.data; + }); + } +} + +Controller.$inject = ['$scope', '$http']; + +ngModule.component('vnItemLastEntries', { + template: require('./index.html'), + controller: Controller, + bindings: { + item: '<' + } +}); diff --git a/client/item/src/last-entries/locale/es.yml b/client/item/src/last-entries/locale/es.yml new file mode 100644 index 000000000..fb231ada4 --- /dev/null +++ b/client/item/src/last-entries/locale/es.yml @@ -0,0 +1,13 @@ +Last entries: Ăšltimas entradas +Since: Desde +Landed: Llegada +Stems: Tallos +Quantity: Cantidad +Cost: Coste +Label: Etiquetas +Entry: Entrada +Ignored: Ignorado +Provider: Proveedor +Cube: Cubo +Price Per Unit: Precio Por Unidad +Price Per Package: Precio Por Paquete \ No newline at end of file diff --git a/client/item/src/last-entries/style.scss b/client/item/src/last-entries/style.scss new file mode 100644 index 000000000..d82464219 --- /dev/null +++ b/client/item/src/last-entries/style.scss @@ -0,0 +1,26 @@ +@import "colors"; +vn-item-last-entries { + .round { + background-color: $lines; + border-radius: 25px; + float: right; + width: 25px; + color: white; + text-align: center; + font-weight: bold; + } + & vn-horizontal { + justify-content: center; + } + & vn-date-picker { + flex: none!important; + & .mdl-textfield{ + width: 400px!important; + } + } + @media screen and (max-width: 1440px) { + .expendable{ + display: none; + } + } +} diff --git a/services/loopback/common/methods/item/getLastEntries.js b/services/loopback/common/methods/item/getLastEntries.js new file mode 100644 index 000000000..ec414f60f --- /dev/null +++ b/services/loopback/common/methods/item/getLastEntries.js @@ -0,0 +1,26 @@ +module.exports = Self => { + Self.remoteMethod('getLastEntries', { + description: 'Returns last entries', + accessType: 'READ', + accepts: [{ + arg: 'filter', + type: 'object', + required: true, + description: 'itemFk, id' + }], + returns: { + type: 'Array', + root: true + }, + http: { + path: `/getLastEntries`, + verb: 'GET' + } + }); + + Self.getLastEntries = async filter => { + let query = `CALL vn.itemLastEntries(?, ?)`; + let [lastEntries] = await Self.rawSql(query, [filter.itemFk, filter.date]); + return lastEntries; + }; +}; diff --git a/services/loopback/common/models/item.js b/services/loopback/common/models/item.js index 5763f58d4..2f54244bf 100644 --- a/services/loopback/common/models/item.js +++ b/services/loopback/common/models/item.js @@ -4,6 +4,7 @@ module.exports = Self => { require('../methods/item/clone')(Self); require('../methods/item/updateTaxes')(Self); require('../methods/item/getDiary')(Self); + require('../methods/item/getLastEntries')(Self); Self.validatesPresenceOf('name', {message: 'Cannot be blank'}); Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});