Tarea #316 Nuevo formulario del registro de compra-venta
This commit is contained in:
parent
7f99d370f3
commit
c0c3925470
|
@ -109,6 +109,18 @@
|
|||
"params": {
|
||||
"item": "$ctrl.item"
|
||||
}
|
||||
}, {
|
||||
"url" : "/diary",
|
||||
"state": "item.card.diary",
|
||||
"component": "vn-item-diary",
|
||||
"params": {
|
||||
"item": "$ctrl.item"
|
||||
},
|
||||
"menu": {
|
||||
"description": "Diary",
|
||||
"icon": "icon-transaction"
|
||||
},
|
||||
"acl": ["employee"]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<vn-vertical>
|
||||
<vn-card pad-large>
|
||||
<vn-vertical>
|
||||
<vn-title>Item diary</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-focus
|
||||
url="/item/api/Warehouses"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
initial-data="$ctrl.warehouseFk"
|
||||
field="$ctrl.warehouseFk"
|
||||
label="Select warehouse">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<table class="vn-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th number translate>Date</th>
|
||||
<th number translate>State</th>
|
||||
<th number translate>Origin</th>
|
||||
<th number translate>Reference</th>
|
||||
<th style="text-align: center" translate>Name</th>
|
||||
<th number translate>In</th>
|
||||
<th number translate>Out</th>
|
||||
<th number translate>Balance</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="diary in $ctrl.diary">
|
||||
<td number>{{diary.date | date:'dd/MM/yyyy HH:mm' }}</td>
|
||||
<td number>{{diary.alertLevel | dashIfEmpty}}</td>
|
||||
<td number>{{diary.origin | dashIfEmpty}}</td>
|
||||
<td number>{{diary.reference | dashIfEmpty}}</td>
|
||||
<td style="text-align: center">{{diary.name | dashIfEmpty}}</td>
|
||||
<td number>{{diary.in | dashIfEmpty}}</td>
|
||||
<td number>{{diary.out | dashIfEmpty}}</td>
|
||||
<td number>{{diary.balance | dashIfEmpty}}</td>
|
||||
</tr>
|
||||
<tr ng-if="$ctrl.diary.length === 0" class="list list-element">
|
||||
<td colspan="8" style="text-align: center" translate>No results</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-paging margin-large-top vn-one index="$ctrl.diary" total="$ctrl.diary.count"></vn-paging>
|
||||
<!-- <vn-auto-paging margin-large-top vn-one index="index" total="index.model.count" items="$ctrl.instances"></vn-auto-paging> -->
|
||||
</vn-vertical>
|
|
@ -0,0 +1,38 @@
|
|||
import ngModule from '../module';
|
||||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($scope, $http) {
|
||||
this.$ = $scope;
|
||||
this.$http = $http;
|
||||
this.diary = [];
|
||||
}
|
||||
|
||||
set warehouseFk(value) {
|
||||
this._getItemDiary(value);
|
||||
this._warehouseFk = value;
|
||||
}
|
||||
|
||||
get warehouseFk() {
|
||||
return this._warehouseFk;
|
||||
}
|
||||
|
||||
_getItemDiary(warehouse) {
|
||||
if (warehouse == null)
|
||||
return;
|
||||
let params = {itemFk: this.item.id, warehouseFk: warehouse};
|
||||
this.$http.get(`/item/api/Items/getDiary?params=${JSON.stringify(params)}`).then(res => {
|
||||
this.diary = res.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$http'];
|
||||
|
||||
ngModule.component('vnItemDiary', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
item: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,42 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Item', () => {
|
||||
describe('Component vnItemDiary', () => {
|
||||
let $componentController;
|
||||
let $scope;
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('item');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
|
||||
$componentController = _$componentController_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
$scope = $rootScope.$new();
|
||||
controller = $componentController('vnItemDiary', {$scope: $scope});
|
||||
controller.item = {id: 3};
|
||||
}));
|
||||
|
||||
describe('set warehouseFk()', () => {
|
||||
it(`should call _getItemDiary() with 2 and set warehouseFk`, () => {
|
||||
spyOn(controller, '_getItemDiary');
|
||||
controller.warehouseFk = 2;
|
||||
|
||||
expect(controller._getItemDiary).toHaveBeenCalledWith(2);
|
||||
expect(controller.warehouseFk).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('_getItemDiary()', () => {
|
||||
it(`should make a request to get the diary hwen is called with a number`, () => {
|
||||
$httpBackend.whenGET('/item/api/Items/getDiary?params={"itemFk":3,"warehouseFk":2}').respond({data: 'item'});
|
||||
$httpBackend.expectGET('/item/api/Items/getDiary?params={"itemFk":3,"warehouseFk":2}');
|
||||
controller._getItemDiary(2);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
vn-item-diary {
|
||||
& vn-horizontal {
|
||||
justify-content: center;
|
||||
}
|
||||
& vn-autocomplete > div{
|
||||
width: 400px;
|
||||
}
|
||||
}
|
|
@ -29,10 +29,16 @@ Value: Valor
|
|||
Priority: Prioridad
|
||||
Item tax: Tasas del artículo
|
||||
Country: País
|
||||
Select warehouse: Selecione almacén
|
||||
Class: Clase
|
||||
Item niches: Nichos del artículo
|
||||
Item diary: Registro de compra-venta
|
||||
Diary: Registro
|
||||
Warehouse: Almacén
|
||||
Code: Código
|
||||
State: Estado
|
||||
In: Entrada
|
||||
Out: Salida
|
||||
Botanical: Botánico
|
||||
Species: Especie
|
||||
Add tag: Añadir etiqueta
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getDiary', {
|
||||
description: 'Returns the ',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'params',
|
||||
type: 'object',
|
||||
description: 'itemFk, warehouseFk'
|
||||
}],
|
||||
returns: {
|
||||
arg: 'diary',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getDiary`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getDiary = async params => {
|
||||
let [diary] = await Self.rawSql(`CALL vn.itemDiary(?, ?)`, [params.itemFk, params.warehouseFk]);
|
||||
return diary;
|
||||
};
|
||||
};
|
|
@ -4,6 +4,7 @@ module.exports = Self => {
|
|||
require('../methods/item/filter')(Self);
|
||||
require('../methods/item/clone')(Self);
|
||||
require('../methods/item/updateTaxes')(Self);
|
||||
require('../methods/item/getDiary')(Self);
|
||||
|
||||
Self.validatesPresenceOf('name', {message: 'Cannot be blank'});
|
||||
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});
|
||||
|
|
Loading…
Reference in New Issue