merge
This commit is contained in:
commit
588308cf1e
|
@ -24,7 +24,8 @@ node {
|
||||||
checkout scm
|
checkout scm
|
||||||
}
|
}
|
||||||
stage ('Install Node dependencies') {
|
stage ('Install Node dependencies') {
|
||||||
sh "npm install"
|
sh "npm install --only=prod"
|
||||||
|
sh "npm install --only=dev"
|
||||||
sh "gulp install"
|
sh "gulp install"
|
||||||
}
|
}
|
||||||
stage ('Build project') {
|
stage ('Build project') {
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
"url": "/index?q",
|
"url": "/index?q",
|
||||||
"state": "claim.index",
|
"state": "claim.index",
|
||||||
"component": "vn-claim-index",
|
"component": "vn-claim-index",
|
||||||
"description": "Listado"
|
"description": "Listado",
|
||||||
|
"acl": ["salesAssistant"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/:id",
|
"url": "/:id",
|
||||||
|
@ -53,7 +54,19 @@
|
||||||
"claim": "$ctrl.claim"
|
"claim": "$ctrl.claim"
|
||||||
},
|
},
|
||||||
"menu": {
|
"menu": {
|
||||||
"icon": "settings"
|
"icon": "icon-details"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/development",
|
||||||
|
"state": "claim.card.development",
|
||||||
|
"component": "vn-claim-development",
|
||||||
|
"description": "Development",
|
||||||
|
"params": {
|
||||||
|
"claim": "$ctrl.claim"
|
||||||
|
},
|
||||||
|
"menu": {
|
||||||
|
"icon": "icon-traceability"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -65,7 +78,7 @@
|
||||||
"claim": "$ctrl.claim"
|
"claim": "$ctrl.claim"
|
||||||
},
|
},
|
||||||
"menu": {
|
"menu": {
|
||||||
"icon": "settings"
|
"icon": "icon-actions"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
<vn-crud-model
|
||||||
|
vn-id="model"
|
||||||
|
url="claim/api/ClaimEnds"
|
||||||
|
filter="$ctrl.filter"
|
||||||
|
data="$ctrl.salesClaimed" on-data-change="$ctrl.onDataChange()">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-vertical>
|
||||||
|
<vn-card pad-large>
|
||||||
|
<vn-vertical>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-title vn-two>Action</vn-title>
|
||||||
|
<div class="totalBox">
|
||||||
|
<vn-label-value label="Total claimed"
|
||||||
|
value="{{$ctrl.claimedTotal | currency:'€':2}}">
|
||||||
|
</vn-label-value>
|
||||||
|
</div>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-table model="model">
|
||||||
|
<vn-thead>
|
||||||
|
<vn-tr>
|
||||||
|
<vn-th number>Id</vn-th>
|
||||||
|
<vn-th>Destination</vn-th>
|
||||||
|
<vn-th number>Landed</vn-th>
|
||||||
|
<vn-th number>Quantity</vn-th>
|
||||||
|
<vn-th number>Description</vn-th>
|
||||||
|
<vn-th number>Price</vn-th>
|
||||||
|
<vn-th number>Disc.</vn-th>
|
||||||
|
<vn-th number>Total</vn-th>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-thead>
|
||||||
|
<vn-tbody>
|
||||||
|
<vn-tr ng-repeat="saleClaimed in $ctrl.salesClaimed" vn-repeat-last on-last="$ctrl.focusLastInput()">
|
||||||
|
<vn-td number>{{saleClaimed.sale.id}}</vn-td>
|
||||||
|
<vn-td>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
id="claimDestinationFk"
|
||||||
|
field="saleClaimed.claimDestinationFk"
|
||||||
|
url="/claim/api/ClaimDestinations"
|
||||||
|
select-fields="['id','description']"
|
||||||
|
value-field="id"
|
||||||
|
show-field="description"
|
||||||
|
on-change="$ctrl.setClaimDestination(saleClaimed.id, value)">
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.sale.quantity}}</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.sale.concept}}</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.sale.price | currency:'€':2}}</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.sale.discount}} %</vn-td>
|
||||||
|
<vn-td number>
|
||||||
|
{{(saleClaimed.sale.quantity * saleClaimed.sale.price) -
|
||||||
|
((saleClaimed.sale.discount *
|
||||||
|
(saleClaimed.sale.quantity * saleClaimed.sale.price))/100) | currency:'€':2
|
||||||
|
}}
|
||||||
|
</vn-td>
|
||||||
|
<vn-td number>
|
||||||
|
<vn-icon-button
|
||||||
|
medium-grey
|
||||||
|
margin-medium-v
|
||||||
|
vn-tooltip="Remove tag"
|
||||||
|
icon="remove_circle_outline"
|
||||||
|
ng-click="$ctrl.deleteClaimedSale(saleClaimed.id)"
|
||||||
|
tabindex="-1">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-td>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-tbody>
|
||||||
|
<vn-empty-rows ng-if="model.data.length === 0" translate>
|
||||||
|
No results
|
||||||
|
</vn-empty-rows>
|
||||||
|
</vn-table>
|
||||||
|
</vn-vertical>
|
||||||
|
</vn-card>
|
||||||
|
<!-- WIP
|
||||||
|
<a ng-click="$ctrl.openAddSalesDialog()" vn-tooltip="New item" vn-bind="+" fixed-bottom-right>
|
||||||
|
<vn-float-button icon="add"></vn-float-button>
|
||||||
|
</a>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Add Lines Dialog -->
|
||||||
|
<vn-dialog
|
||||||
|
vn-id="addSales">
|
||||||
|
<tpl-body>
|
||||||
|
<h3 translate>Claimable sales from ticket</h3><h3> {{$ctrl.claim.ticketFk}}</h3>
|
||||||
|
<vn-table>
|
||||||
|
<vn-thead>
|
||||||
|
<vn-tr>
|
||||||
|
<vn-th number>Id</vn-th>
|
||||||
|
<vn-th number>Landed</vn-th>
|
||||||
|
<vn-th number>Quantity</vn-th>
|
||||||
|
<vn-th number>Description</vn-th>
|
||||||
|
<vn-th number>Price</vn-th>
|
||||||
|
<vn-th number>Disc.</vn-th>
|
||||||
|
<vn-th number>Total</vn-th>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-thead>
|
||||||
|
<vn-tbody>
|
||||||
|
<vn-tr ng-repeat="sale in $ctrl.salesToClaim" class="clickable" ng-click="$ctrl.addClaimedSale(sale.saleFk)">
|
||||||
|
<vn-td number>{{sale.saleFk}}</vn-td>
|
||||||
|
<vn-td number>{{sale.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
|
||||||
|
<vn-td number>{{sale.quantity}}</vn-td>
|
||||||
|
<vn-td number>{{sale.concept}}</vn-td>
|
||||||
|
<vn-td number>{{sale.price | currency:'€':2}}</vn-td>
|
||||||
|
<vn-td number>{{sale.discount}} %</vn-td>
|
||||||
|
<vn-td number>
|
||||||
|
{{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency:'€':2}}
|
||||||
|
</vn-td>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-tbody>
|
||||||
|
<vn-empty-rows ng-if="model.data.length === 0" translate>
|
||||||
|
No results
|
||||||
|
</vn-empty-rows>
|
||||||
|
</vn-table>
|
||||||
|
</tpl-body>
|
||||||
|
</vn-dialog>
|
|
@ -0,0 +1,93 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
constructor($state, $scope, $http, $translate, vnApp) {
|
||||||
|
this.$state = $state;
|
||||||
|
this.$ = $scope;
|
||||||
|
this.$http = $http;
|
||||||
|
this.$translate = $translate;
|
||||||
|
this.vnApp = vnApp;
|
||||||
|
this.filter = {
|
||||||
|
where: {claimFk: $state.params.id},
|
||||||
|
include: [
|
||||||
|
{relation: 'sale',
|
||||||
|
scope: {
|
||||||
|
fields: ['concept', 'ticketFk', 'price', 'quantity', 'discount'],
|
||||||
|
include: {
|
||||||
|
relation: 'ticket'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{relation: 'claimBeggining'}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
openAddSalesDialog() {
|
||||||
|
this.getClaimedSales();
|
||||||
|
this.$.addSales.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
getClaimedSales() {
|
||||||
|
let json = encodeURIComponent(JSON.stringify(this.claim.id));
|
||||||
|
|
||||||
|
let query = `/claim/api/ClaimBeginnings/${json}`;
|
||||||
|
this.$http.get(query).then(res => {
|
||||||
|
if (res.data) {
|
||||||
|
this.claimedSales = res.data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addClaimedSale(saleFk) {
|
||||||
|
let saleToAdd = {saleFk: saleFk, claimFk: this.claim.id, workerFk: this.claim.workerFk, claimDestinationFk: 1};
|
||||||
|
let query = `claim/api/ClaimEnds/`;
|
||||||
|
this.$http.post(query, saleToAdd).then(() => {
|
||||||
|
this.$.model.refresh();
|
||||||
|
this.$.addSales.hide();
|
||||||
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteClaimedSale(id) {
|
||||||
|
let json = encodeURIComponent(JSON.stringify(id));
|
||||||
|
let query = `claim/api/ClaimEnds/${json}`;
|
||||||
|
this.$http.delete(query).then(() => {
|
||||||
|
this.$.model.refresh();
|
||||||
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
focusLastInput() {
|
||||||
|
let inputs = document.querySelectorAll("#claimDestinationFk");
|
||||||
|
inputs[inputs.length - 1].querySelector("input").focus();
|
||||||
|
this.calculateTotals();
|
||||||
|
}
|
||||||
|
|
||||||
|
setClaimDestination(id, claimDestinationFk) {
|
||||||
|
let params = {id: id, claimDestinationFk: claimDestinationFk};
|
||||||
|
let query = `claim/api/ClaimEnds/`;
|
||||||
|
this.$http.patch(query, params).then(() => {
|
||||||
|
this.$.model.refresh();
|
||||||
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateTotals() {
|
||||||
|
this.claimedTotal = 0;
|
||||||
|
this.salesClaimed.forEach(sale => {
|
||||||
|
this.claimedTotal += (sale.sale.quantity * sale.sale.price) - ((sale.sale.discount * (sale.sale.quantity * sale.sale.price)) / 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp'];
|
||||||
|
|
||||||
|
ngModule.component('vnClaimAction', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
claim: '<'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,94 @@
|
||||||
|
import './index.js';
|
||||||
|
|
||||||
|
describe('claim', () => {
|
||||||
|
describe('Component vnClaimDetail', () => {
|
||||||
|
let $componentController;
|
||||||
|
let controller;
|
||||||
|
let $httpBackend;
|
||||||
|
let $state;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
angular.mock.module('claim');
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_, $rootScope) => {
|
||||||
|
$componentController = _$componentController_;
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
||||||
|
$httpBackend.when('GET', 'claim/api/Claims/ClaimBeginnings').respond({});
|
||||||
|
$state = _$state_;
|
||||||
|
$state.params.id = 1;
|
||||||
|
|
||||||
|
controller = $componentController('vnClaimDetail', {$state: $state});
|
||||||
|
controller.claim = {ticketFk: 1};
|
||||||
|
controller.$.model = {refresh: () => {}};
|
||||||
|
controller.$.addSales = {
|
||||||
|
hide: () => {},
|
||||||
|
show: () => {}
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('openAddSalesDialog()', () => {
|
||||||
|
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
||||||
|
controller.$ = {addSales: {show: () => {}}};
|
||||||
|
spyOn(controller, 'getClaimableFromTicket');
|
||||||
|
spyOn(controller.$.addSales, 'show');
|
||||||
|
controller.openAddSalesDialog();
|
||||||
|
|
||||||
|
expect(controller.getClaimableFromTicket).toHaveBeenCalledWith();
|
||||||
|
expect(controller.$.addSales.show).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getClaimableFromTicket()', () => {
|
||||||
|
it('should make a query and set salesToClaim', () => {
|
||||||
|
$httpBackend.expectGET(`/api/Sales/getClaimableFromTicket?ticketFk=1`).respond(200, 1);
|
||||||
|
controller.getClaimableFromTicket();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.salesToClaim).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addClaimedSale(saleFk)', () => {
|
||||||
|
it('should make a post and call refresh, hide and showSuccess', () => {
|
||||||
|
spyOn(controller.$.model, 'refresh');
|
||||||
|
spyOn(controller.$.addSales, 'hide');
|
||||||
|
spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
$httpBackend.expectPOST(`claim/api/ClaimBeginnings/`).respond({});
|
||||||
|
controller.addClaimedSale(1);
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
||||||
|
expect(controller.$.addSales.hide).toHaveBeenCalledWith();
|
||||||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('deleteClaimedSale(id)', () => {
|
||||||
|
it('should make a delete and call refresh and showSuccess', () => {
|
||||||
|
spyOn(controller.$.model, 'refresh');
|
||||||
|
spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
$httpBackend.expectDELETE(`claim/api/ClaimBeginnings/1`).respond({});
|
||||||
|
controller.deleteClaimedSale(1);
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
||||||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('setClaimedQuantity(id, claimedQuantity)', () => {
|
||||||
|
it('should make a patch and call refresh and showSuccess', () => {
|
||||||
|
spyOn(controller.$.model, 'refresh');
|
||||||
|
spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
$httpBackend.expectPATCH(`claim/api/ClaimBeginnings/`).respond({});
|
||||||
|
controller.setClaimedQuantity(1, 1);
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
||||||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
Destination: Destino
|
||||||
|
Action: Actuaciones
|
||||||
|
Total claimed: Total Reclamado
|
|
@ -0,0 +1,16 @@
|
||||||
|
vn-claim-action {
|
||||||
|
vn-dialog[vn-id=addSales] {
|
||||||
|
tpl-body {
|
||||||
|
width: 950px;
|
||||||
|
div {
|
||||||
|
div.buttons {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
vn-table{
|
||||||
|
min-width: 950px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ class Controller {
|
||||||
constructor($http, $state) {
|
constructor($http, $state) {
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
this.order = {};
|
|
||||||
this.filter = {
|
this.filter = {
|
||||||
include: [
|
include: [
|
||||||
{relation: 'worker', scope: {fields: ['name', 'firstName']}},
|
{relation: 'worker', scope: {fields: ['name', 'firstName']}},
|
||||||
|
|
|
@ -2,12 +2,22 @@
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="claim/api/ClaimBeginnings"
|
url="claim/api/ClaimBeginnings"
|
||||||
filter="$ctrl.filter"
|
filter="$ctrl.filter"
|
||||||
data="$ctrl.salesClaimed" on-data-change="$ctrl.onDataChange()">
|
data="$ctrl.salesClaimed">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-title>Detail</vn-title>
|
<vn-horizontal>
|
||||||
|
<vn-title vn-two>Detail</vn-title>
|
||||||
|
<div class="totalBox">
|
||||||
|
<vn-label-value label="Total"
|
||||||
|
value="{{$ctrl.paidTotal | currency:'€':2}}">
|
||||||
|
</vn-label-value>
|
||||||
|
<vn-label-value label="Total claimed"
|
||||||
|
value="{{$ctrl.claimedTotal | currency:'€':2}}">
|
||||||
|
</vn-label-value>
|
||||||
|
</div>
|
||||||
|
</vn-horizontal>
|
||||||
<vn-table model="model">
|
<vn-table model="model">
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
|
@ -22,12 +32,13 @@
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="saleClaimed in $ctrl.salesClaimed" vn-repeat-last on-last="$ctrl.focusLastInput()">
|
<vn-tr ng-repeat="saleClaimed in $ctrl.salesClaimed" vn-repeat-last on-last="$ctrl.calculateTotals()">
|
||||||
<vn-td number>{{saleClaimed.sale.id}}</vn-td>
|
<vn-td number>{{saleClaimed.sale.id}}</vn-td>
|
||||||
<vn-td number>{{saleClaimed.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
|
<vn-td number>{{saleClaimed.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
|
||||||
<vn-td number>{{saleClaimed.sale.quantity}}</vn-td>
|
<vn-td number>{{saleClaimed.sale.quantity}}</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
|
vn-focus
|
||||||
id="claimedQuantity"
|
id="claimedQuantity"
|
||||||
model="saleClaimed.quantity"
|
model="saleClaimed.quantity"
|
||||||
on-change="$ctrl.setClaimedQuantity(saleClaimed.id, saleClaimed.quantity)"
|
on-change="$ctrl.setClaimedQuantity(saleClaimed.id, saleClaimed.quantity)"
|
||||||
|
@ -59,16 +70,11 @@
|
||||||
No results
|
No results
|
||||||
</vn-empty-rows>
|
</vn-empty-rows>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
<vn-one pad-medium-top>
|
|
||||||
<vn-icon-button
|
|
||||||
vn-bind="+"
|
|
||||||
vn-tooltip="Add tag"
|
|
||||||
icon="add_circle"
|
|
||||||
ng-click="$ctrl.openAddSalesDialog()">
|
|
||||||
</vn-icon-button>
|
|
||||||
</vn-one>
|
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
<a ng-click="$ctrl.openAddSalesDialog()" vn-tooltip="New item" vn-bind="+" fixed-bottom-right>
|
||||||
|
<vn-float-button icon="add"></vn-float-button>
|
||||||
|
</a>
|
||||||
|
|
||||||
<!-- Add Lines Dialog -->
|
<!-- Add Lines Dialog -->
|
||||||
<vn-dialog
|
<vn-dialog
|
||||||
|
|
|
@ -58,11 +58,6 @@ class Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
focusLastInput() {
|
|
||||||
let inputs = document.querySelectorAll("#claimedQuantity");
|
|
||||||
inputs[inputs.length - 1].querySelector("input").select();
|
|
||||||
}
|
|
||||||
|
|
||||||
setClaimedQuantity(id, claimedQuantity) {
|
setClaimedQuantity(id, claimedQuantity) {
|
||||||
let params = {id: id, quantity: claimedQuantity};
|
let params = {id: id, quantity: claimedQuantity};
|
||||||
let query = `claim/api/ClaimBeginnings/`;
|
let query = `claim/api/ClaimBeginnings/`;
|
||||||
|
@ -71,6 +66,17 @@ class Controller {
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calculateTotals() {
|
||||||
|
this.paidTotal = 0;
|
||||||
|
this.salesClaimed.forEach(sale => {
|
||||||
|
this.paidTotal += (sale.sale.quantity * sale.sale.price) - ((sale.sale.discount * (sale.sale.quantity * sale.sale.price)) / 100);
|
||||||
|
});
|
||||||
|
this.claimedTotal = 0;
|
||||||
|
this.salesClaimed.forEach(sale => {
|
||||||
|
this.claimedTotal += (sale.quantity * sale.sale.price) - ((sale.sale.discount * (sale.quantity * sale.sale.price)) / 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp'];
|
Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp'];
|
||||||
|
|
|
@ -90,5 +90,15 @@ describe('claim', () => {
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('calculateTotals()', () => {
|
||||||
|
it('should set paidTotal and claimedTotal to 0 if salesClaimed has no data', () => {
|
||||||
|
controller.salesClaimed = [];
|
||||||
|
controller.calculateTotals();
|
||||||
|
|
||||||
|
expect(controller.paidTotal).toEqual(0);
|
||||||
|
expect(controller.claimedTotal).toEqual(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
<vn-crud-model
|
||||||
|
vn-id="model"
|
||||||
|
url="claim/api/ClaimDevelopments"
|
||||||
|
fields="['id', 'claimFk', 'claimReasonFk', 'claimResultFk', 'claimResponsibleFk', 'workerFk', 'claimRedeliveryFk']"
|
||||||
|
link="{claimFk: $ctrl.$state.params.id}"
|
||||||
|
filter="$ctrl.filter"
|
||||||
|
data="claimDevelopments">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-crud-model
|
||||||
|
url="claim/api/ClaimReasons"
|
||||||
|
data="claimReasons"
|
||||||
|
order="description">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-crud-model
|
||||||
|
url="claim/api/ClaimResults"
|
||||||
|
data="claimResults"
|
||||||
|
order="description">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-crud-model
|
||||||
|
url="claim/api/ClaimResponsibles"
|
||||||
|
data="claimResponsibles"
|
||||||
|
order="description">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-crud-model
|
||||||
|
url="/client/api/Clients/activeSalesPerson"
|
||||||
|
data="activeSalesPersons"
|
||||||
|
order="firstName">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-crud-model
|
||||||
|
url="claim/api/ClaimRedeliveries"
|
||||||
|
data="claimRedeliveries"
|
||||||
|
order="description">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-watcher
|
||||||
|
vn-id="watcher"
|
||||||
|
data="claimDevelopments"
|
||||||
|
form="form">
|
||||||
|
</vn-watcher>
|
||||||
|
<vn-vertical>
|
||||||
|
<vn-card pad-large>
|
||||||
|
<vn-vertical>
|
||||||
|
<form name="form" ng-submit="$ctrl.onSubmit()">
|
||||||
|
<vn-title vn-two>Development</vn-title>
|
||||||
|
<vn-horizontal ng-repeat="claimDevelopment in claimDevelopments">
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
vn-focus
|
||||||
|
label="Reason"
|
||||||
|
id="claimReason"
|
||||||
|
field="claimDevelopment.claimReasonFk"
|
||||||
|
data="claimReasons"
|
||||||
|
select-fields="['id','description']"
|
||||||
|
show-field="description"
|
||||||
|
vn-acl="salesAssistant">
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Result"
|
||||||
|
id="claimResult"
|
||||||
|
field="claimDevelopment.claimResultFk"
|
||||||
|
data="claimResults"
|
||||||
|
select-fields="['id','description']"
|
||||||
|
show-field="description"
|
||||||
|
vn-acl="salesAssistant">
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Responsible"
|
||||||
|
id="Responsible"
|
||||||
|
field="claimDevelopment.claimResponsibleFk"
|
||||||
|
data="claimResponsibles"
|
||||||
|
select-fields="['id','description']"
|
||||||
|
show-field="description"
|
||||||
|
vn-acl="salesAssistant">
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Worker"
|
||||||
|
field="claimDevelopment.workerFk"
|
||||||
|
data="activeSalesPersons"
|
||||||
|
show-field="firstName"
|
||||||
|
vn-acl="salesAssistant">
|
||||||
|
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Redelivery"
|
||||||
|
id="redelivery"
|
||||||
|
field="claimDevelopment.claimRedeliveryFk"
|
||||||
|
data="claimRedeliveries"
|
||||||
|
select-fields="['id','description']"
|
||||||
|
show-field="description"
|
||||||
|
vn-acl="salesAssistant">
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-icon-button
|
||||||
|
medium-grey
|
||||||
|
margin-medium-v
|
||||||
|
vn-tooltip="Remove tag"
|
||||||
|
icon="remove_circle_outline"
|
||||||
|
ng-click="model.remove($index)"
|
||||||
|
tabindex="-1"
|
||||||
|
vn-acl="salesAssistant">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-horizontal>
|
||||||
|
</form>
|
||||||
|
<vn-one pad-medium-top>
|
||||||
|
<vn-icon-button
|
||||||
|
vn-bind="+"
|
||||||
|
vn-tooltip="Add tag"
|
||||||
|
icon="add_circle"
|
||||||
|
ng-click="model.insert()"
|
||||||
|
vn-acl="salesAssistant">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-one>
|
||||||
|
</vn-vertical>
|
||||||
|
</vn-card>
|
||||||
|
<vn-button-bar>
|
||||||
|
<vn-submit
|
||||||
|
label="Save"
|
||||||
|
ng-click="$ctrl.onSubmit()"
|
||||||
|
vn-acl="salesAssistant">
|
||||||
|
</vn-submit>
|
||||||
|
</vn-button-bar>
|
||||||
|
</vn-vertical>
|
|
@ -0,0 +1,30 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
constructor($state, $scope, $http, $translate, vnApp) {
|
||||||
|
this.$state = $state;
|
||||||
|
this.$ = $scope;
|
||||||
|
this.$http = $http;
|
||||||
|
this.$translate = $translate;
|
||||||
|
this.vnApp = vnApp;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
this.$.watcher.check();
|
||||||
|
this.$.model.save().then(() => {
|
||||||
|
this.$.watcher.notifySaved();
|
||||||
|
this.$.model.refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp'];
|
||||||
|
|
||||||
|
ngModule.component('vnClaimDevelopment', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
claim: '<'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,7 @@
|
||||||
|
Destination: Destino
|
||||||
|
Development: Trazabilidad
|
||||||
|
Reason: Motivo
|
||||||
|
Result: Consecuencia
|
||||||
|
Responsible: Responsable
|
||||||
|
Worker: Trabajador
|
||||||
|
Redelivery: Devolución
|
|
@ -1,8 +1,11 @@
|
||||||
export * from './module';
|
export * from './module';
|
||||||
|
|
||||||
import './index/';
|
import './action';
|
||||||
|
import './basic-data';
|
||||||
import './card';
|
import './card';
|
||||||
import './detail';
|
import './detail';
|
||||||
import './descriptor';
|
import './descriptor';
|
||||||
import './basic-data';
|
import './development';
|
||||||
// import './summary';
|
import './index/';
|
||||||
|
import './search-panel';
|
||||||
|
import './summary';
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="vn-list">
|
<div class="vn-list">
|
||||||
<vn-card pad-medium-h>
|
<vn-card pad-medium-h>
|
||||||
<vn-searchbar
|
<vn-searchbar
|
||||||
panel="vn-ticket-search-panel"
|
panel="vn-claim-search-panel"
|
||||||
model="model"
|
model="model"
|
||||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||||
</vn-searchbar>
|
</vn-searchbar>
|
||||||
|
@ -25,23 +25,21 @@
|
||||||
<vn-th field="clientFk">Client</vn-th>
|
<vn-th field="clientFk">Client</vn-th>
|
||||||
<vn-th field="created">Created</vn-th>
|
<vn-th field="created">Created</vn-th>
|
||||||
<vn-th field="workerFk">Worker</vn-th>
|
<vn-th field="workerFk">Worker</vn-th>
|
||||||
<vn-th field="observation">Observation</vn-th>
|
|
||||||
<vn-th field="claimStateFk">State</vn-th>
|
<vn-th field="claimStateFk">State</vn-th>
|
||||||
<vn-th></vn-th>
|
<vn-th></vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="claim in claims" ui-sref="claim.card.detail({id: claim.id})" class=clickable>
|
<vn-tr ng-repeat="claim in claims" ui-sref="claim.card.summary({id: claim.id})" class=clickable>
|
||||||
<vn-td number>{{::claim.id}}</vn-td>
|
<vn-td number>{{::claim.id}}</vn-td>
|
||||||
<vn-td number><span class="link" ng-click="$ctrl.showDescriptor($event, claim.client.id)">{{::claim.client.id}}</span></vn-td>
|
<vn-td number><span class="link" ng-click="$ctrl.showDescriptor($event, claim.client.id)">{{::claim.client.id}}</span></vn-td>
|
||||||
<vn-td>{{::claim.client.name}}</vn-td>
|
<vn-td>{{::claim.client.name}}</vn-td>
|
||||||
<vn-td>{{::claim.created | date:'dd/MM/yyyy'}}</vn-td>
|
<vn-td>{{::claim.created | date:'dd/MM/yyyy'}}</vn-td>
|
||||||
<vn-td>{{::claim.worker.firstName}} {{::claim.worker.name}}</vn-td>
|
<vn-td>{{::claim.worker.firstName}} {{::claim.worker.name}}</vn-td>
|
||||||
<vn-td>{{::claim.observation}}</vn-td>
|
|
||||||
<vn-td>{{::claim.claimState.description}}</vn-td>
|
<vn-td>{{::claim.claimState.description}}</vn-td>
|
||||||
<vn-td>
|
<vn-td>
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
ng-click="$ctrl.preview($event, ticket)"
|
ng-click="$ctrl.preview($event, claim)"
|
||||||
vn-tooltip="Preview"
|
vn-tooltip="Preview"
|
||||||
icon="desktop_windows">
|
icon="desktop_windows">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
|
@ -56,3 +54,9 @@
|
||||||
</vn-pagination>
|
</vn-pagination>
|
||||||
</div>
|
</div>
|
||||||
<vn-client-descriptor-popover vn-id="descriptor"></vn-client-descriptor-popover>
|
<vn-client-descriptor-popover vn-id="descriptor"></vn-client-descriptor-popover>
|
||||||
|
<vn-dialog class="dialog-summary"
|
||||||
|
vn-id="dialog-summary-claim">
|
||||||
|
<tpl-body>
|
||||||
|
<vn-claim-summary claim="$ctrl.claimSelected"></vn-claim-summary>
|
||||||
|
</tpl-body>
|
||||||
|
</vn-dialog>
|
|
@ -30,6 +30,24 @@ export default class Controller {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exprBuilder(param, value) {
|
||||||
|
switch (param) {
|
||||||
|
case 'search':
|
||||||
|
return /^\d+$/.test(value)
|
||||||
|
? {id: value}
|
||||||
|
: {client: {regexp: value}};
|
||||||
|
case 'client':
|
||||||
|
return {[param]: {regexp: value}};
|
||||||
|
case 'created':
|
||||||
|
return {created: {between: [value, value]}};
|
||||||
|
case 'id':
|
||||||
|
case 'clientFk':
|
||||||
|
case 'workerFk':
|
||||||
|
case 'claimStateFk':
|
||||||
|
return {[param]: value};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
showDescriptor(event, clientFk) {
|
showDescriptor(event, clientFk) {
|
||||||
this.$.descriptor.clientFk = clientFk;
|
this.$.descriptor.clientFk = clientFk;
|
||||||
this.$.descriptor.parent = event.target;
|
this.$.descriptor.parent = event.target;
|
||||||
|
@ -38,6 +56,13 @@ export default class Controller {
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
preview(event, claim) {
|
||||||
|
this.claimSelected = claim;
|
||||||
|
this.$.dialogSummaryClaim.show();
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
}
|
||||||
|
|
||||||
onDescriptorLoad() {
|
onDescriptorLoad() {
|
||||||
this.$.popover.relocate();
|
this.$.popover.relocate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
Client Id: Id cliente
|
Client Id: Id cliente
|
||||||
Observation: Observación
|
Observation: Observación
|
||||||
Responsible: Responsable
|
Responsible: Responsable
|
||||||
|
Claim Id: Id reclamación
|
||||||
|
|
||||||
#sections
|
#sections
|
||||||
Claims: Reclamaciones
|
Claims: Reclamaciones
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
<div pad-large style="min-width: 30em">
|
||||||
|
<form ng-submit="$ctrl.onSearch()">
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Client"
|
||||||
|
model="filter.client"
|
||||||
|
vn-focus>
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Claim Id"
|
||||||
|
model="filter.id">
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Client Id"
|
||||||
|
model="filter.clientFk">
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="State"
|
||||||
|
field="filter.claimStateFk"
|
||||||
|
url="/claim/api/ClaimStates"
|
||||||
|
show-field="description"
|
||||||
|
value-field="id">
|
||||||
|
<tpl-item>{{description}}</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Worker"
|
||||||
|
field="filter.workerFk"
|
||||||
|
url="/claim/api/Workers"
|
||||||
|
show-field="firstName"
|
||||||
|
value-field="id">
|
||||||
|
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-date-picker
|
||||||
|
vn-one
|
||||||
|
label="Created"
|
||||||
|
model="filter.created">
|
||||||
|
</vn-date-picker>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal margin-large-top>
|
||||||
|
<vn-submit label="Search"></vn-submit>
|
||||||
|
</vn-horizontal>
|
||||||
|
</form>
|
||||||
|
</div>
|
|
@ -0,0 +1,7 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import SearchPanel from 'core/src/components/searchbar/search-panel';
|
||||||
|
|
||||||
|
ngModule.component('vnClaimSearchPanel', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: SearchPanel
|
||||||
|
});
|
|
@ -0,0 +1,7 @@
|
||||||
|
Ticket id: Id ticket
|
||||||
|
Client id: Id cliente
|
||||||
|
Nickname: Alias
|
||||||
|
From: Desde
|
||||||
|
To: Hasta
|
||||||
|
Agency: Agencia
|
||||||
|
Warehouse: Almacén
|
|
@ -0,0 +1,152 @@
|
||||||
|
<vn-vertical vn-one>
|
||||||
|
<vn-card class="summary" pad-medium>
|
||||||
|
<vn-vertical margin-medium>
|
||||||
|
<vn-auto>
|
||||||
|
<h5 text-center pad-small-v class="title">{{$ctrl.summary.claim.id}} - {{$ctrl.summary.claim.client.name}}</h5>
|
||||||
|
</vn-auto>
|
||||||
|
|
||||||
|
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-one>
|
||||||
|
<vn-label-value label="Created"
|
||||||
|
value="{{$ctrl.summary.claim.created | dateTime: 'dd/MM/yyyy'}}">
|
||||||
|
</vn-label-value>
|
||||||
|
<vn-label-value label="State"
|
||||||
|
value="{{::$ctrl.summary.claim.claimState.description}}">
|
||||||
|
</vn-label-value>
|
||||||
|
<vn-label-value label="Salesperson"
|
||||||
|
value="{{$ctrl.summary.claim.client.salesPerson.firstName}} {{$ctrl.summary.claim.client.salesPerson.name}}">
|
||||||
|
</vn-label-value>
|
||||||
|
<vn-label-value label="Attended by"
|
||||||
|
value="{{$ctrl.summary.claim.worker.firstName}} {{$ctrl.summary.claim.worker.name}}">
|
||||||
|
</vn-label-value>
|
||||||
|
</vn-one>
|
||||||
|
<vn-one>
|
||||||
|
<vn-textarea
|
||||||
|
vn-three
|
||||||
|
disabled="true"
|
||||||
|
label="Observation"
|
||||||
|
model="$ctrl.summary.claim.observation">
|
||||||
|
</vn-textarea>
|
||||||
|
</vn-one>
|
||||||
|
<vn-one>
|
||||||
|
<vn-input-range
|
||||||
|
vn-one
|
||||||
|
disabled="true"
|
||||||
|
label="Responsability"
|
||||||
|
value="$ctrl.summary.claim.responsibility"
|
||||||
|
max="4"
|
||||||
|
min="0"
|
||||||
|
step="1">
|
||||||
|
</vn-input-range>
|
||||||
|
</vn-one>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-one margin-medium>
|
||||||
|
<h5 translate>Detail</h5>
|
||||||
|
<vn-table model="model">
|
||||||
|
<vn-thead>
|
||||||
|
<vn-tr>
|
||||||
|
<vn-th number>Id</vn-th>
|
||||||
|
<vn-th number>Landed</vn-th>
|
||||||
|
<vn-th number>Quantity</vn-th>
|
||||||
|
<vn-th number>Claimed</vn-th>
|
||||||
|
<vn-th number>Description</vn-th>
|
||||||
|
<vn-th number>Price</vn-th>
|
||||||
|
<vn-th number>Disc.</vn-th>
|
||||||
|
<vn-th number>Total</vn-th>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-thead>
|
||||||
|
<vn-tbody>
|
||||||
|
<vn-tr ng-repeat="saleClaimed in $ctrl.summary.salesClaimed">
|
||||||
|
<vn-td number>{{saleClaimed.sale.id}}</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.sale.quantity}}</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.quantity}}</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.sale.concept}}</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.sale.price | currency:'€':2}}</vn-td>
|
||||||
|
<vn-td number>{{saleClaimed.sale.discount}} %</vn-td>
|
||||||
|
<vn-td number>
|
||||||
|
{{(saleClaimed.sale.quantity * saleClaimed.sale.price) -
|
||||||
|
((saleClaimed.sale.discount *
|
||||||
|
(saleClaimed.sale.quantity * saleClaimed.sale.price))/100) | currency:'€':2
|
||||||
|
}}
|
||||||
|
</vn-td>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-tbody>
|
||||||
|
<vn-empty-rows ng-if="model.data.length === 0" translate>
|
||||||
|
No results
|
||||||
|
</vn-empty-rows>
|
||||||
|
</vn-table>
|
||||||
|
</vn-one>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-one margin-medium>
|
||||||
|
<h5 translate>Development</h5>
|
||||||
|
<vn-table model="model">
|
||||||
|
<vn-thead>
|
||||||
|
<vn-tr>
|
||||||
|
<vn-th number>Reason</vn-th>
|
||||||
|
<vn-th number>Result</vn-th>
|
||||||
|
<vn-th number>Responsible</vn-th>
|
||||||
|
<vn-th number>Worker</vn-th>
|
||||||
|
<vn-th number>Redelivery</vn-th>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-thead>
|
||||||
|
<vn-tbody>
|
||||||
|
<vn-tr ng-repeat="development in $ctrl.summary.developments">
|
||||||
|
<vn-td number>{{development.claimReason.description}}</vn-td>
|
||||||
|
<vn-td number>{{development.claimResult.description}}</vn-td>
|
||||||
|
<vn-td number>{{development.claimResponsible.description}}</vn-td>
|
||||||
|
<vn-td number>{{development.worker.firstName}}</vn-td>
|
||||||
|
<vn-td number>{{development.claimRedelivery.description}}</vn-td>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-tbody>
|
||||||
|
<vn-empty-rows ng-if="model.data.length === 0" translate>
|
||||||
|
No results
|
||||||
|
</vn-empty-rows>
|
||||||
|
</vn-table>
|
||||||
|
</vn-one>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-one margin-medium>
|
||||||
|
<h5 translate>Action</h5>
|
||||||
|
<vn-table model="model">
|
||||||
|
<vn-thead>
|
||||||
|
<vn-tr>
|
||||||
|
<vn-th number>Id</vn-th>
|
||||||
|
<vn-th number>Destination</vn-th>
|
||||||
|
<vn-th number>Landed</vn-th>
|
||||||
|
<vn-th number>Quantity</vn-th>
|
||||||
|
<vn-th number>Description</vn-th>
|
||||||
|
<vn-th number>Price</vn-th>
|
||||||
|
<vn-th number>Disc.</vn-th>
|
||||||
|
<vn-th number>Total</vn-th>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-thead>
|
||||||
|
<vn-tbody>
|
||||||
|
<vn-tr ng-repeat="action in $ctrl.summary.actions">
|
||||||
|
<vn-td number>{{action.sale.id}}</vn-td>
|
||||||
|
<vn-td number>{{action.claimBeggining.description}}</vn-td>
|
||||||
|
<vn-td number>{{action.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
|
||||||
|
<vn-td number>{{action.sale.quantity}}</vn-td>
|
||||||
|
<vn-td number>{{action.sale.concept}}</vn-td>
|
||||||
|
<vn-td number>{{action.sale.price}}</vn-td>
|
||||||
|
<vn-td number>{{action.sale.discount}} %</vn-td>
|
||||||
|
<vn-td number>
|
||||||
|
{{(action.sale.quantity * action.sale.price) -
|
||||||
|
((action.sale.discount *
|
||||||
|
(action.sale.quantity * action.sale.price))/100) | currency:'€':2
|
||||||
|
}}
|
||||||
|
</vn-td>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-tbody>
|
||||||
|
<vn-empty-rows ng-if="model.data.length === 0" translate>
|
||||||
|
No results
|
||||||
|
</vn-empty-rows>
|
||||||
|
</vn-table>
|
||||||
|
</vn-one>
|
||||||
|
</vn-horizontal>
|
||||||
|
</vn-vertical>
|
||||||
|
</vn-card>
|
||||||
|
</vn-vertical>
|
|
@ -0,0 +1,28 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
constructor($http) {
|
||||||
|
this.$http = $http;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSummary() {
|
||||||
|
this.$http.get(`/claim/api/Claims/${this.claim.id}/getSummary`).then(response => {
|
||||||
|
this.summary = response.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$onChanges() {
|
||||||
|
if (this.claim && this.claim.id)
|
||||||
|
this.getSummary();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller.$inject = ['$http'];
|
||||||
|
|
||||||
|
ngModule.component('vnClaimSummary', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
claim: '<'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,41 @@
|
||||||
|
import './index.js';
|
||||||
|
|
||||||
|
describe('Claim', () => {
|
||||||
|
describe('Component summary', () => {
|
||||||
|
let $componentController;
|
||||||
|
let controller;
|
||||||
|
let $httpBackend;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
angular.mock.module('claim');
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => {
|
||||||
|
$componentController = _$componentController_;
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
||||||
|
controller = $componentController('vnClaimSummary');
|
||||||
|
controller.claim = {id: 1};
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('getSummary()', () => {
|
||||||
|
it("should perform a query to set summary", () => {
|
||||||
|
$httpBackend.when('GET', `/claim/api/Claims/1/getSummary`).respond(200, 24);
|
||||||
|
$httpBackend.expect('GET', `/claim/api/Claims/1/getSummary`);
|
||||||
|
controller.getSummary();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.summary).toEqual(24);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('$onChanges()', () => {
|
||||||
|
it("should call getSummary when item.id is defined", () => {
|
||||||
|
spyOn(controller, 'getSummary');
|
||||||
|
controller.$onChanges();
|
||||||
|
|
||||||
|
expect(controller.getSummary).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -53,6 +53,10 @@ export default class inputRange extends Input {
|
||||||
set model(value) {
|
set model(value) {
|
||||||
this._model = value;
|
this._model = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set disabled(value) {
|
||||||
|
this.input.disabled = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inputRange.$inject = ['$element', '$scope'];
|
inputRange.$inject = ['$element', '$scope'];
|
||||||
|
|
|
@ -14,7 +14,7 @@ import './style.scss';
|
||||||
class Pagination extends Component {
|
class Pagination extends Component {
|
||||||
constructor($element, $scope) {
|
constructor($element, $scope) {
|
||||||
super($element, $scope);
|
super($element, $scope);
|
||||||
this.scrollOffset = 150;
|
this.scrollOffset = 300;
|
||||||
this.scrollHandler = e => this.onScroll(e);
|
this.scrollHandler = e => this.onScroll(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@ export default class CrudModel extends ModelProxy {
|
||||||
this.autoLoad = true;
|
this.autoLoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the model is loading.
|
||||||
|
*/
|
||||||
get isLoading() {
|
get isLoading() {
|
||||||
return this.canceler != null;
|
return this.canceler != null;
|
||||||
}
|
}
|
||||||
|
@ -19,23 +22,76 @@ export default class CrudModel extends ModelProxy {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh(usFilter) {
|
buildFilter() {
|
||||||
if (!this.url) return;
|
let order = this.order;
|
||||||
|
|
||||||
|
if (typeof order === 'string')
|
||||||
|
order = this.order.split(/\s*,\s*/);
|
||||||
|
|
||||||
let myFilter = {
|
let myFilter = {
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
where: mergeWhere(this.link, this.where),
|
where: mergeWhere(this.link, this.where),
|
||||||
include: this.include,
|
include: this.include,
|
||||||
order: this.order,
|
order: order,
|
||||||
limit: this.limit
|
limit: this.limit
|
||||||
};
|
};
|
||||||
|
|
||||||
let filter = this.filter;
|
let filter = this.filter;
|
||||||
filter = mergeFilters(myFilter, filter);
|
filter = mergeFilters(myFilter, filter);
|
||||||
filter = mergeFilters(usFilter, filter);
|
filter = mergeFilters(this.userFilter, filter);
|
||||||
return this.sendRequest(filter);
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh the model data.
|
||||||
|
*
|
||||||
|
* @return {Promise} The request promise
|
||||||
|
*/
|
||||||
|
refresh() {
|
||||||
|
if (!this.url) return;
|
||||||
|
return this.sendRequest(this.buildFilter());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a new filter to the model.
|
||||||
|
*
|
||||||
|
* @param {Object} userFilter The Loopback filter
|
||||||
|
* @param {Object} userParams Custom parameters
|
||||||
|
* @return {Promise} The request promise
|
||||||
|
*/
|
||||||
|
applyFilter(userFilter, userParams) {
|
||||||
|
this.userFilter = userFilter;
|
||||||
|
this.userParams = userParams;
|
||||||
|
return this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a filter to the model.
|
||||||
|
*
|
||||||
|
* @param {Object} userFilter The Loopback filter
|
||||||
|
* @param {Object} userParams Custom parameters
|
||||||
|
* @return {Promise} The request promise
|
||||||
|
*/
|
||||||
|
addFilter(userFilter, userParams) {
|
||||||
|
this.userFilter = mergeFilters(userFilter, this.userFilter);
|
||||||
|
Object.assign(this.userParams, userParams);
|
||||||
|
return this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the currently applied user filters.
|
||||||
|
*
|
||||||
|
* @return {Promise} The request promise
|
||||||
|
*/
|
||||||
|
removeFilter() {
|
||||||
|
this.userFilter = null;
|
||||||
|
this.userParams = null;
|
||||||
|
return this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels the current request, if any.
|
||||||
|
*/
|
||||||
cancelRequest() {
|
cancelRequest() {
|
||||||
if (this.canceler) {
|
if (this.canceler) {
|
||||||
this.canceler.resolve();
|
this.canceler.resolve();
|
||||||
|
@ -43,55 +99,21 @@ export default class CrudModel extends ModelProxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendRequest(filter, append) {
|
/**
|
||||||
this.cancelRequest();
|
* When limit is enabled, loads the next set of rows.
|
||||||
this.canceler = this.$q.defer();
|
*/
|
||||||
|
|
||||||
let options = {
|
|
||||||
timeout: this.canceler.promise,
|
|
||||||
params: {filter: filter}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.userParams instanceof Object)
|
|
||||||
Object.assign(options.params, this.userParams);
|
|
||||||
|
|
||||||
return this.$http.get(this.url, options).then(
|
|
||||||
json => this.onRemoteDone(json, filter, append),
|
|
||||||
json => this.onRemoteError(json)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
onRemoteDone(json, filter, append) {
|
|
||||||
let data = json.data;
|
|
||||||
|
|
||||||
if (append)
|
|
||||||
this.orgData = this.orgData.concat(data);
|
|
||||||
else
|
|
||||||
this.orgData = data;
|
|
||||||
|
|
||||||
this.currentFilter = filter;
|
|
||||||
this.moreRows = filter.limit && data.length == filter.limit;
|
|
||||||
this.onRequestEnd();
|
|
||||||
this.dataChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
onRemoteError(err) {
|
|
||||||
this.onRequestEnd();
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
onRequestEnd() {
|
|
||||||
this.canceler = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
loadMore() {
|
loadMore() {
|
||||||
if (this.moreRows) {
|
if (!this.moreRows) return;
|
||||||
let filter = Object.assign({}, this.currentFilter);
|
let filter = Object.assign({}, this.currentFilter);
|
||||||
filter.skip = (filter.skip || 0) + filter.limit;
|
filter.skip = this.orgData ? this.orgData.length : 0;
|
||||||
this.sendRequest(filter, true);
|
this.sendRequest(filter, true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object with the unsaved changes made to the model.
|
||||||
|
*
|
||||||
|
* @return {Object} The current changes
|
||||||
|
*/
|
||||||
getChanges() {
|
getChanges() {
|
||||||
let create = [];
|
let create = [];
|
||||||
let update = [];
|
let update = [];
|
||||||
|
@ -124,6 +146,11 @@ export default class CrudModel extends ModelProxy {
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves current changes on the server.
|
||||||
|
*
|
||||||
|
* @return {Promise} The save request promise
|
||||||
|
*/
|
||||||
save() {
|
save() {
|
||||||
let changes = this.getChanges();
|
let changes = this.getChanges();
|
||||||
|
|
||||||
|
@ -134,6 +161,60 @@ export default class CrudModel extends ModelProxy {
|
||||||
return this.$http.post(url, changes)
|
return this.$http.post(url, changes)
|
||||||
.then(() => this.resetChanges());
|
.then(() => this.resetChanges());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildParams() {
|
||||||
|
let params = {};
|
||||||
|
|
||||||
|
if (this.params instanceof Object)
|
||||||
|
Object.assign(params, this.params);
|
||||||
|
if (this.userParams instanceof Object)
|
||||||
|
Object.assign(params, this.userParams);
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendRequest(filter, append) {
|
||||||
|
this.cancelRequest();
|
||||||
|
this.canceler = this.$q.defer();
|
||||||
|
|
||||||
|
let params = Object.assign(
|
||||||
|
{filter: filter},
|
||||||
|
this.buildParams()
|
||||||
|
);
|
||||||
|
let options = {
|
||||||
|
timeout: this.canceler.promise,
|
||||||
|
params: params
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.$http.get(this.url, options).then(
|
||||||
|
json => this.onRemoteDone(json, filter, append),
|
||||||
|
json => this.onRemoteError(json)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onRemoteDone(json, filter, append) {
|
||||||
|
let data = json.data;
|
||||||
|
|
||||||
|
if (append) {
|
||||||
|
this.orgData = this.orgData.concat(data);
|
||||||
|
} else {
|
||||||
|
this.orgData = data;
|
||||||
|
this.currentFilter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.moreRows = filter.limit && data.length == filter.limit;
|
||||||
|
this.onRequestEnd();
|
||||||
|
this.dataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
onRemoteError(err) {
|
||||||
|
this.onRequestEnd();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
onRequestEnd() {
|
||||||
|
this.canceler = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CrudModel.$inject = ['$http', '$q'];
|
CrudModel.$inject = ['$http', '$q'];
|
||||||
|
|
||||||
|
@ -152,6 +233,8 @@ ngModule.component('vnCrudModel', {
|
||||||
order: '@?',
|
order: '@?',
|
||||||
limit: '<?',
|
limit: '<?',
|
||||||
filter: '<?',
|
filter: '<?',
|
||||||
|
params: '<?',
|
||||||
|
userFilter: '<?',
|
||||||
userParams: '<?',
|
userParams: '<?',
|
||||||
primaryKey: '@?',
|
primaryKey: '@?',
|
||||||
autoLoad: '<?'
|
autoLoad: '<?'
|
||||||
|
|
|
@ -87,23 +87,47 @@ export default class Controller extends Component {
|
||||||
this.onSearch({filter: this.filter});
|
this.onSearch({filter: this.filter});
|
||||||
|
|
||||||
if (this.model) {
|
if (this.model) {
|
||||||
if (!this.exprBuilder)
|
|
||||||
throw new Error('exprBuilder property should be defined when model is assigned');
|
|
||||||
|
|
||||||
let and = [];
|
let and = [];
|
||||||
|
let userParams = {};
|
||||||
|
let hasParams = false;
|
||||||
|
|
||||||
for (let param in this.filter) {
|
for (let param in this.filter) {
|
||||||
let value = this.filter[param];
|
let value = this.filter[param];
|
||||||
if (value == null) continue;
|
if (value == null) continue;
|
||||||
|
|
||||||
let expr = this.exprBuilder({param, value});
|
let expr = this.exprBuilder({param, value});
|
||||||
if (expr) and.push(expr);
|
if (expr)
|
||||||
|
and.push(expr);
|
||||||
|
|
||||||
|
if (this.paramBuilder) {
|
||||||
|
let expr = this.paramBuilder({param, value});
|
||||||
|
if (expr) {
|
||||||
|
Object.assign(userParams, expr);
|
||||||
|
hasParams = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let lbFilter = and.length > 0 ? {where: {and}} : null;
|
let where;
|
||||||
this.model.refresh(lbFilter);
|
|
||||||
|
if (and.length == 1)
|
||||||
|
where = and[0];
|
||||||
|
else if (and.length > 1)
|
||||||
|
where = {and};
|
||||||
|
else
|
||||||
|
where = null;
|
||||||
|
|
||||||
|
this.model.applyFilter(
|
||||||
|
and.length > 0 ? {where: where} : null,
|
||||||
|
hasParams ? userParams : null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exprBuilder(param, value) {
|
||||||
|
return {[param]: value};
|
||||||
|
}
|
||||||
|
|
||||||
pushFilterToState(filter) {
|
pushFilterToState(filter) {
|
||||||
let state = window.location.hash.split('?')[0];
|
let state = window.location.hash.split('?')[0];
|
||||||
let keys = Object.keys(filter);
|
let keys = Object.keys(filter);
|
||||||
|
@ -214,7 +238,8 @@ ngModule.component('vnSearchbar', {
|
||||||
onSearch: '&',
|
onSearch: '&',
|
||||||
panel: '@',
|
panel: '@',
|
||||||
model: '<?',
|
model: '<?',
|
||||||
exprBuilder: '&?'
|
exprBuilder: '&?',
|
||||||
|
paramBuilder: '&?'
|
||||||
},
|
},
|
||||||
controller: Controller
|
controller: Controller
|
||||||
});
|
});
|
||||||
|
|
|
@ -79,6 +79,7 @@ export default class Textfield extends Input {
|
||||||
this.input.tabindex = value;
|
this.input.tabindex = value;
|
||||||
}
|
}
|
||||||
clear() {
|
clear() {
|
||||||
|
this.saveOldValue();
|
||||||
this.value = null;
|
this.value = null;
|
||||||
this.input.focus();
|
this.input.focus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,11 +102,13 @@ describe('Component vnTextfield', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('clear()', () => {
|
describe('clear()', () => {
|
||||||
it(`should set value property to null and call focus`, () => {
|
it(`should set value property to null, call focus and saveOldValue`, () => {
|
||||||
spyOn(controller.input, 'focus');
|
spyOn(controller.input, 'focus');
|
||||||
|
spyOn(controller, 'saveOldValue');
|
||||||
controller.clear();
|
controller.clear();
|
||||||
|
|
||||||
expect(controller.value).toEqual(null);
|
expect(controller.value).toEqual(null);
|
||||||
|
expect(controller.saveOldValue).toHaveBeenCalledWith();
|
||||||
expect(controller.input.focus).toHaveBeenCalledWith();
|
expect(controller.input.focus).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,17 +37,27 @@
|
||||||
<vn-tr ng-class="{'warning': $ctrl.isToday(sale.date)}"
|
<vn-tr ng-class="{'warning': $ctrl.isToday(sale.date)}"
|
||||||
ng-repeat="sale in sales" vn-repeat-last on-last="$ctrl.scrollToActive()">
|
ng-repeat="sale in sales" vn-repeat-last on-last="$ctrl.scrollToActive()">
|
||||||
<vn-td>{{::sale.date | date:'dd/MM/yyyy HH:mm' }}</vn-td>
|
<vn-td>{{::sale.date | date:'dd/MM/yyyy HH:mm' }}</vn-td>
|
||||||
<vn-td ng-class="{'link pointer': sale.isTicket}"
|
<vn-td number>
|
||||||
ng-click="$ctrl.showDescriptor($event, sale)" number>
|
<span ng-class="{'link pointer': sale.isTicket}"
|
||||||
{{::sale.origin | dashIfEmpty}}</vn-td>
|
ng-click="$ctrl.showDescriptor($event, sale)">
|
||||||
|
{{::sale.origin | dashIfEmpty}}
|
||||||
|
</span>
|
||||||
|
</vn-td>
|
||||||
<vn-td>{{::sale.stateName | dashIfEmpty}}</vn-td>
|
<vn-td>{{::sale.stateName | dashIfEmpty}}</vn-td>
|
||||||
<vn-td>{{::sale.reference | dashIfEmpty}}</vn-td>
|
<vn-td>{{::sale.reference | dashIfEmpty}}</vn-td>
|
||||||
<vn-td ng-class="{'link pointer': sale.isTicket}"
|
<vn-td>
|
||||||
|
<span ng-class="{'link pointer': sale.isTicket}"
|
||||||
ng-click="$ctrl.showClientDescriptor($event, sale)">
|
ng-click="$ctrl.showClientDescriptor($event, sale)">
|
||||||
{{sale.name | dashIfEmpty}}</vn-td>
|
{{sale.name | dashIfEmpty}}
|
||||||
|
</span>
|
||||||
|
</vn-td>
|
||||||
<vn-td number>{{::sale.in | dashIfEmpty}}</vn-td>
|
<vn-td number>{{::sale.in | dashIfEmpty}}</vn-td>
|
||||||
<vn-td number>{{::sale.out | dashIfEmpty}}</vn-td>
|
<vn-td number>{{::sale.out | dashIfEmpty}}</vn-td>
|
||||||
<vn-td number><span class="balance">{{::sale.balance | dashIfEmpty}}</span></vn-td>
|
<vn-td number>
|
||||||
|
<span class="balance">
|
||||||
|
{{::sale.balance | dashIfEmpty}}
|
||||||
|
</span>
|
||||||
|
</vn-td>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
<vn-empty-rows ng-if="model.data.length === 0" translate>
|
<vn-empty-rows ng-if="model.data.length === 0" translate>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="/item/api/Items/filter"
|
url="/item/api/Items/filter"
|
||||||
limit="8"
|
limit="8"
|
||||||
order="isActive ASC, name"
|
order="isActive DESC, name"
|
||||||
data="items"
|
data="items"
|
||||||
auto-load="false">
|
auto-load="false">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
|
@ -12,7 +12,8 @@
|
||||||
<vn-searchbar
|
<vn-searchbar
|
||||||
panel="vn-item-search-panel"
|
panel="vn-item-search-panel"
|
||||||
model="model"
|
model="model"
|
||||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||||
|
param-builder="$ctrl.paramBuilder(param, value)">
|
||||||
</vn-searchbar>
|
</vn-searchbar>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-card margin-medium-v>
|
<vn-card margin-medium-v>
|
||||||
|
|
|
@ -22,9 +22,13 @@ class Controller {
|
||||||
case 'id':
|
case 'id':
|
||||||
case 'typeFk':
|
case 'typeFk':
|
||||||
return {[param]: value};
|
return {[param]: value};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
paramBuilder(param, value) {
|
||||||
|
switch (param) {
|
||||||
case 'tags':
|
case 'tags':
|
||||||
this.$.model.userParams = {tags: value};
|
return {[param]: value};
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,11 @@
|
||||||
zoom-image="//verdnatura.es/vn-image-data/catalog/1600x900/{{::row.item.image}}"
|
zoom-image="//verdnatura.es/vn-image-data/catalog/1600x900/{{::row.item.image}}"
|
||||||
on-error-src/>
|
on-error-src/>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td ng-click="$ctrl.showDescriptor($event, row.itemFk)"
|
<vn-td>
|
||||||
|
<span ng-click="$ctrl.showDescriptor($event, row.itemFk)"
|
||||||
pointer number class="link">
|
pointer number class="link">
|
||||||
{{("000000"+row.itemFk).slice(-6)}}
|
{{("000000"+row.itemFk).slice(-6)}}
|
||||||
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td><vn-fetched-tags concept="row.item.name" tags="row.item.tags"/></vn-td>
|
<vn-td><vn-fetched-tags concept="row.item.name" tags="row.item.tags"/></vn-td>
|
||||||
<vn-td>{{row.warehouse.name}}</vn-td>
|
<vn-td>{{row.warehouse.name}}</vn-td>
|
||||||
|
|
|
@ -32,9 +32,12 @@
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="row in rows">
|
<vn-tr ng-repeat="row in rows">
|
||||||
<vn-td number pointer class="link"
|
<vn-td number>
|
||||||
ng-click="$ctrl.showDescriptor($event, row.itemFk)">
|
<span
|
||||||
|
ng-click="$ctrl.showDescriptor($event, row.itemFk)"
|
||||||
|
pointer class="link">
|
||||||
{{::row.itemFk}}
|
{{::row.itemFk}}
|
||||||
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td><vn-fetched-tags concept="row.item.name" tags="row.item.tags"/></vn-td>
|
<vn-td><vn-fetched-tags concept="row.item.name" tags="row.item.tags"/></vn-td>
|
||||||
<vn-td number>{{::row.quantity}}</vn-td>
|
<vn-td number>{{::row.quantity}}</vn-td>
|
||||||
|
|
|
@ -42,9 +42,13 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="{{
|
<td rowspan="{{
|
||||||
::sale.components.length + 1
|
::sale.components.length + 1
|
||||||
}}" number pointer
|
}}" number>
|
||||||
|
<span pointer
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
||||||
class="link">{{("000000"+sale.itemFk).slice(-6)}}</td>
|
class="link">
|
||||||
|
{{("000000"+sale.itemFk).slice(-6)}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
<td rowspan="{{
|
<td rowspan="{{
|
||||||
::sale.components.length + 1
|
::sale.components.length + 1
|
||||||
}}"><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></td>
|
}}"><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></td>
|
||||||
|
|
|
@ -25,17 +25,19 @@
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="expedition in expeditions">
|
<vn-tr ng-repeat="expedition in expeditions">
|
||||||
<vn-td pad-medium-h style="color:#FFA410;">
|
<vn-td pad-medium-h style="width:30px;color:#FFA410;">
|
||||||
<i
|
<i
|
||||||
pointer
|
pointer
|
||||||
class="material-icons"
|
class="material-icons"
|
||||||
vn-tooltip="Delete expedition"
|
vn-tooltip="Delete expedition"
|
||||||
ng-click="$ctrl.deleteExpedition(expedition)">delete</i>
|
ng-click="$ctrl.deleteExpedition(expedition)">delete</i>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number
|
<vn-td number>
|
||||||
|
<span
|
||||||
ng-class="{'link pointer':expedition.itemFk}"
|
ng-class="{'link pointer':expedition.itemFk}"
|
||||||
ng-click="$ctrl.showDescriptor($event, expedition.itemFk)">
|
ng-click="$ctrl.showDescriptor($event, expedition.itemFk)">
|
||||||
{{expedition.itemFk}}
|
{{expedition.itemFk}}
|
||||||
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td>{{::expedition.namePackage}}</vn-td>
|
<vn-td>{{::expedition.namePackage}}</vn-td>
|
||||||
<vn-td>{{::expedition.nameBox}}</vn-td>
|
<vn-td>{{::expedition.nameBox}}</vn-td>
|
||||||
|
|
|
@ -27,10 +27,12 @@
|
||||||
disabled="true">
|
disabled="true">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number pointer
|
<vn-td number>
|
||||||
|
<span
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
||||||
class="link">
|
class="link" pointer>
|
||||||
{{("000000"+sale.itemFk).slice(-6)}}
|
{{("000000"+sale.itemFk).slice(-6)}}
|
||||||
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
||||||
<vn-td number>{{::sale.quantity}}</vn-td>
|
<vn-td number>{{::sale.quantity}}</vn-td>
|
||||||
|
|
|
@ -33,10 +33,12 @@
|
||||||
ng-if="sale.quantity != sale.originalQuantity"
|
ng-if="sale.quantity != sale.originalQuantity"
|
||||||
vn-tooltip="The quantity do not match"></vn-icon>
|
vn-tooltip="The quantity do not match"></vn-icon>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number pointer
|
<vn-td number>
|
||||||
|
<span
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
||||||
class="link">
|
class="link" pointer>
|
||||||
{{("000000"+sale.itemFk).slice(-6)}}
|
{{("000000"+sale.itemFk).slice(-6)}}
|
||||||
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
||||||
<vn-td>{{::sale.quantity}}</vn-td>
|
<vn-td>{{::sale.quantity}}</vn-td>
|
||||||
|
|
|
@ -84,9 +84,12 @@
|
||||||
zoom-image="//verdnatura.es/vn-image-data/catalog/1600x900/{{::sale.image}}"
|
zoom-image="//verdnatura.es/vn-image-data/catalog/1600x900/{{::sale.image}}"
|
||||||
on-error-src/>
|
on-error-src/>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
<vn-td number>
|
||||||
pointer number class="link">
|
<span
|
||||||
|
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
||||||
|
pointer class="link">
|
||||||
{{("000000"+sale.itemFk).slice(-6)}}
|
{{("000000"+sale.itemFk).slice(-6)}}
|
||||||
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
||||||
<vn-td ng-if="!$ctrl.isEditable" number>{{sale.quantity}}</vn-td>
|
<vn-td ng-if="!$ctrl.isEditable" number>{{sale.quantity}}</vn-td>
|
||||||
|
|
|
@ -141,6 +141,7 @@ class Controller {
|
||||||
let query = `/ticket/api/Sales/removes`;
|
let query = `/ticket/api/Sales/removes`;
|
||||||
this.$http.post(query, params).then(() => {
|
this.$http.post(query, params).then(() => {
|
||||||
this.removeInstances(sales);
|
this.removeInstances(sales);
|
||||||
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,16 +67,20 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="sale in $ctrl.summary.sales track by sale.id">
|
<tr ng-repeat="sale in $ctrl.summary.sales track by sale.id">
|
||||||
<td>
|
<td>
|
||||||
<!-- <i pointer
|
<vn-icon
|
||||||
class="material-icons"
|
ng-show="sale.visible || sale.available"
|
||||||
vn-tooltip="delete expedition"
|
orange
|
||||||
ng-click="$ctrl.deleteExpedition(expedition)">warning</i> -->
|
icon="warning"
|
||||||
<vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon>
|
vn-tooltip="Visible: {{::sale.visible || 0}} <br> {{::$ctrl.translate.instant('Available')}} {{::sale.available || 0}}">
|
||||||
|
</vn-icon>
|
||||||
|
<vn-icon ng-show="sale.reserved" icon="icon-reserva"></vn-icon>
|
||||||
</td>
|
</td>
|
||||||
<td number pointer
|
<td number>
|
||||||
|
<span
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
||||||
class="link">
|
class="link" pointer>
|
||||||
{{("000000"+sale.itemFk).slice(-6)}}
|
{{("000000"+sale.itemFk).slice(-6)}}
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></td>
|
<td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></td>
|
||||||
<td number>{{::sale.quantity}}</td>
|
<td number>{{::sale.quantity}}</td>
|
||||||
|
|
|
@ -32,10 +32,12 @@
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="sale in sales">
|
<vn-tr ng-repeat="sale in sales">
|
||||||
<vn-td number pointer
|
<vn-td number>
|
||||||
|
<span
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
||||||
class="link">
|
class="link" pointer>
|
||||||
{{("000000"+sale.itemFk).slice(-6)}}
|
{{("000000"+sale.itemFk).slice(-6)}}
|
||||||
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
||||||
<vn-td number>{{::sale.quantity}}</vn-td>
|
<vn-td number>{{::sale.quantity}}</vn-td>
|
||||||
|
|
|
@ -357,6 +357,6 @@ export default {
|
||||||
},
|
},
|
||||||
claimDetails: {
|
claimDetails: {
|
||||||
detailsButton: `vn-menu-item a[ui-sref="claim.card.detail"]`,
|
detailsButton: `vn-menu-item a[ui-sref="claim.card.detail"]`,
|
||||||
addItemButton: `vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-one > vn-icon-button > vn-icon > i`
|
addItemButton: `vn-claim-detail a vn-float-button`
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,18 +22,17 @@ describe('Claim', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// descomentar este test despues de completar la tarea #629 claim index buscador avanzado
|
it('should search for the claim with id 1', () => {
|
||||||
// it('should search for the claim with id 1', () => {
|
return nightmare
|
||||||
// return nightmare
|
.wait(selectors.claimsIndex.searchResult)
|
||||||
// .wait(selectors.claimsIndex.searchResult)
|
.type(selectors.claimsIndex.searchClaimInput, '1')
|
||||||
// .type(selectors.claimsIndex.searchClaimInput, '1')
|
.click(selectors.claimsIndex.searchButton)
|
||||||
// .click(selectors.claimsIndex.searchButton)
|
.waitForNumberOfElements(selectors.claimsIndex.searchResult, 1)
|
||||||
// .waitForNumberOfElements(selectors.claimsIndex.searchResult, 1)
|
.countElement(selectors.claimsIndex.searchResult)
|
||||||
// .countElement(selectors.claimsIndex.searchResult)
|
.then(result => {
|
||||||
// .then(result => {
|
expect(result).toEqual(1);
|
||||||
// expect(result).toEqual(1);
|
});
|
||||||
// });
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
it(`should click on the search result to access to the ticket Basic Data`, () => {
|
it(`should click on the search result to access to the ticket Basic Data`, () => {
|
||||||
return nightmare
|
return nightmare
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
import selectors from '../../helpers/selectors.js';
|
||||||
import createNightmare from '../../helpers/helpers';
|
import createNightmare from '../../helpers/helpers';
|
||||||
|
|
||||||
describe('Client', () => {
|
describe('Client Edit fiscalData path', () => {
|
||||||
describe('Edit fiscalData path', () => {
|
|
||||||
const nightmare = createNightmare();
|
const nightmare = createNightmare();
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
@ -335,4 +334,3 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
import selectors from '../../helpers/selectors.js';
|
||||||
import createNightmare from '../../helpers/helpers';
|
import createNightmare from '../../helpers/helpers';
|
||||||
|
|
||||||
describe('Client', () => {
|
describe('Client add address notes path', () => {
|
||||||
describe('Add address notes path', () => {
|
|
||||||
const nightmare = createNightmare();
|
const nightmare = createNightmare();
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
@ -95,5 +94,3 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
import selectors from '../../helpers/selectors.js';
|
||||||
import createNightmare from '../../helpers/helpers';
|
import createNightmare from '../../helpers/helpers';
|
||||||
|
|
||||||
describe('Client', () => {
|
describe('Client lock verified data path', () => {
|
||||||
describe('lock verified data path', () => {
|
|
||||||
const nightmare = createNightmare();
|
const nightmare = createNightmare();
|
||||||
|
|
||||||
describe('as salesPerson', () => {
|
describe('as salesPerson', () => {
|
||||||
|
@ -472,4 +471,3 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
|
@ -53,9 +53,9 @@ describe('Ticket', () => {
|
||||||
.then(value => {
|
.then(value => {
|
||||||
expect(value).toContain('Yellow');
|
expect(value).toContain('Yellow');
|
||||||
expect(value).toContain('5');
|
expect(value).toContain('5');
|
||||||
expect(value).toContain('€23.50');
|
expect(value).toContain('€9.60');
|
||||||
expect(value).toContain('0 %');
|
expect(value).toContain('0 %');
|
||||||
expect(value).toContain('€117.50');
|
expect(value).toContain('€48.00');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,9 +65,9 @@ describe('Ticket', () => {
|
||||||
.getInnerText(selectors.ticketSales.secondSaleText)
|
.getInnerText(selectors.ticketSales.secondSaleText)
|
||||||
.then(value => {
|
.then(value => {
|
||||||
expect(value).toContain('Red');
|
expect(value).toContain('Red');
|
||||||
expect(value).toContain('€4.50');
|
expect(value).toContain('€4.21');
|
||||||
expect(value).toContain('0 %');
|
expect(value).toContain('0 %');
|
||||||
expect(value).toContain('€45.00');
|
expect(value).toContain('€42.10');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,7 +53,7 @@ describe('Ticket', () => {
|
||||||
.wait(500)
|
.wait(500)
|
||||||
.waitToClick(selectors.ticketBasicData.addressSelect)
|
.waitToClick(selectors.ticketBasicData.addressSelect)
|
||||||
.waitToClick(selectors.ticketBasicData.addressSelectSecondOption)
|
.waitToClick(selectors.ticketBasicData.addressSelectSecondOption)
|
||||||
.waitForTextInInput(selectors.ticketBasicData.addressSelect, 'Charles')
|
.waitForTextInInput(selectors.ticketBasicData.addressSelect, 'address 28')
|
||||||
.click(selectors.ticketBasicData.nextStepButton)
|
.click(selectors.ticketBasicData.nextStepButton)
|
||||||
.waitForURL('data/step-two')
|
.waitForURL('data/step-two')
|
||||||
.url()
|
.url()
|
||||||
|
|
|
@ -71,9 +71,6 @@ gulp.task('services-only', async () => {
|
||||||
* Runs the e2e tests, restoring the fixtures first.
|
* Runs the e2e tests, restoring the fixtures first.
|
||||||
*/
|
*/
|
||||||
gulp.task('e2e', ['docker'], async () => {
|
gulp.task('e2e', ['docker'], async () => {
|
||||||
if (argv.show || argv.s)
|
|
||||||
process.env.E2E_SHOW = true;
|
|
||||||
|
|
||||||
await runSequenceP('e2e-only');
|
await runSequenceP('e2e-only');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -86,6 +83,10 @@ gulp.task('smokes', ['docker'], async () => {
|
||||||
*/
|
*/
|
||||||
gulp.task('e2e-only', () => {
|
gulp.task('e2e-only', () => {
|
||||||
const jasmine = require('gulp-jasmine');
|
const jasmine = require('gulp-jasmine');
|
||||||
|
|
||||||
|
if (argv.show || argv.s)
|
||||||
|
process.env.E2E_SHOW = true;
|
||||||
|
|
||||||
return gulp.src('./e2e_tests.js')
|
return gulp.src('./e2e_tests.js')
|
||||||
.pipe(jasmine({reporter: 'none'}));
|
.pipe(jasmine({reporter: 'none'}));
|
||||||
});
|
});
|
||||||
|
|
|
@ -1383,7 +1383,7 @@
|
||||||
"bluebird": {
|
"bluebird": {
|
||||||
"version": "3.5.1",
|
"version": "3.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
|
||||||
"integrity": "sha1-2VUfnemPH82h5oPRfukaBgLuLrk=",
|
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"bn.js": {
|
"bn.js": {
|
||||||
|
@ -10852,7 +10852,7 @@
|
||||||
"jasmine-spec-reporter": {
|
"jasmine-spec-reporter": {
|
||||||
"version": "4.2.1",
|
"version": "4.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz",
|
||||||
"integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=",
|
"integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"colors": "1.1.2"
|
"colors": "1.1.2"
|
||||||
|
@ -10998,7 +10998,7 @@
|
||||||
"karma": {
|
"karma": {
|
||||||
"version": "1.7.1",
|
"version": "1.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz",
|
||||||
"integrity": "sha1-hcwI6eCiLXzpzKN8ShvoJPaisa4=",
|
"integrity": "sha512-k5pBjHDhmkdaUccnC7gE3mBzZjcxyxYsYVaqiL2G5AqlfLyBO5nw2VdNK+O16cveEPd/gIOWULH7gkiYYwVNHg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"bluebird": "3.5.1",
|
"bluebird": "3.5.1",
|
||||||
|
@ -11050,7 +11050,7 @@
|
||||||
"karma-chrome-launcher": {
|
"karma-chrome-launcher": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz",
|
||||||
"integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=",
|
"integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"fs-access": "1.0.1",
|
"fs-access": "1.0.1",
|
||||||
|
@ -21351,7 +21351,7 @@
|
||||||
"useragent": {
|
"useragent": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz",
|
||||||
"integrity": "sha1-IX+UOtVAyyEoZYqyP8lg9qiMmXI=",
|
"integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"lru-cache": "4.1.1",
|
"lru-cache": "4.1.1",
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('getSummary', {
|
||||||
|
description: 'Updates the item taxes',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The item id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/getSummary`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getSummary = async id => {
|
||||||
|
let promises = [];
|
||||||
|
let summary = {};
|
||||||
|
|
||||||
|
// Claim
|
||||||
|
|
||||||
|
let filter = {
|
||||||
|
where: {id: id},
|
||||||
|
include: [
|
||||||
|
{relation: 'worker', scope: {fields: ['name', 'firstName']}},
|
||||||
|
{relation: 'claimState', scope: {fields: ['id', 'description']}},
|
||||||
|
{
|
||||||
|
relation: 'client',
|
||||||
|
scope: {
|
||||||
|
fields: ['salesPersonFk', 'name'],
|
||||||
|
include: {
|
||||||
|
relation: 'salesPerson',
|
||||||
|
fields: ['firstName', 'name']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
promises.push(Self.app.models.Claim.find(filter));
|
||||||
|
|
||||||
|
// Claim detail
|
||||||
|
filter = {
|
||||||
|
where: {claimFk: id},
|
||||||
|
include: [
|
||||||
|
{relation: 'sale',
|
||||||
|
scope: {
|
||||||
|
fields: ['concept', 'ticketFk', 'price', 'quantity', 'discount'],
|
||||||
|
include: {
|
||||||
|
relation: 'ticket'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
promises.push(Self.app.models.ClaimBeginning.find(filter));
|
||||||
|
|
||||||
|
// Claim developments
|
||||||
|
filter = {
|
||||||
|
where: {claimFk: id},
|
||||||
|
include: [
|
||||||
|
{relation: 'claimResponsible'},
|
||||||
|
{relation: 'worker'},
|
||||||
|
{relation: 'claimDestination'},
|
||||||
|
{relation: 'claimReason'},
|
||||||
|
{relation: 'claimResult'},
|
||||||
|
{relation: 'claimRedelivery'}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
promises.push(Self.app.models.ClaimDevelopment.find(filter));
|
||||||
|
|
||||||
|
// Claim action
|
||||||
|
filter = {
|
||||||
|
where: {claimFk: id},
|
||||||
|
include: [
|
||||||
|
{relation: 'sale',
|
||||||
|
scope: {
|
||||||
|
fields: ['concept', 'price', 'quantity', 'discount', 'ticketFk', 'itemFk'],
|
||||||
|
include: [
|
||||||
|
{relation: 'ticket'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{relation: 'claimBeggining'}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
promises.push(Self.app.models.ClaimEnd.find(filter));
|
||||||
|
|
||||||
|
let res = await Promise.all(promises);
|
||||||
|
|
||||||
|
[summary.claim] = res[0];
|
||||||
|
summary.salesClaimed = res[1];
|
||||||
|
summary.developments = res[2];
|
||||||
|
summary.actions = res[3];
|
||||||
|
|
||||||
|
return summary;
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,13 @@
|
||||||
|
const app = require(`${servicesDir}/claim/server/server`);
|
||||||
|
|
||||||
|
describe('claim getSummary()', () => {
|
||||||
|
it('should return summary with claim, salesClaimed, developments and actions defined ', async() => {
|
||||||
|
let result = await app.models.Claim.getSummary(1);
|
||||||
|
let keys = Object.keys(result);
|
||||||
|
|
||||||
|
expect(keys).toContain('claim');
|
||||||
|
expect(keys).toContain('salesClaimed');
|
||||||
|
expect(keys).toContain('developments');
|
||||||
|
expect(keys).toContain('actions');
|
||||||
|
});
|
||||||
|
});
|
|
@ -34,6 +34,11 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "ClaimDestination",
|
"model": "ClaimDestination",
|
||||||
"foreignKey": "claimDestinationFk"
|
"foreignKey": "claimDestinationFk"
|
||||||
|
},
|
||||||
|
"claimBeggining": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "ClaimDestination",
|
||||||
|
"foreignKey": "claimDestinationFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
require('../methods/claim/getSummary')(Self);
|
||||||
|
};
|
|
@ -0,0 +1,17 @@
|
||||||
|
USE `vn`;
|
||||||
|
CREATE
|
||||||
|
OR REPLACE ALGORITHM = UNDEFINED
|
||||||
|
DEFINER = `root`@`%`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `itemType` AS
|
||||||
|
SELECT
|
||||||
|
`t`.`tipo_id` AS `id`,
|
||||||
|
`t`.`Id_Tipo` AS `code`,
|
||||||
|
`t`.`Tipo` AS `name`,
|
||||||
|
`t`.`reino_id` AS `categoryFk`,
|
||||||
|
`t`.`life` AS `life`,
|
||||||
|
`t`.`Id_Trabajador` AS `workerFk`,
|
||||||
|
`t`.`warehouseFk` AS `warehouseFk`,
|
||||||
|
`t`.`isPackaging` AS `isPackaging`
|
||||||
|
FROM
|
||||||
|
`vn2008`.`Tipos` `t`;
|
|
@ -1,19 +0,0 @@
|
||||||
USE `vn`;
|
|
||||||
|
|
||||||
ALTER TABLE `vn2008`.`escritos`
|
|
||||||
ADD COLUMN `hasCompany` VARCHAR(45) NOT NULL DEFAULT 0 AFTER `visible`;
|
|
||||||
|
|
||||||
|
|
||||||
CREATE
|
|
||||||
OR REPLACE ALGORITHM = UNDEFINED
|
|
||||||
DEFINER = `root`@`%`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `sample` AS
|
|
||||||
SELECT
|
|
||||||
`e`.`id` AS `id`,
|
|
||||||
`e`.`abrev` AS `code`,
|
|
||||||
`e`.`descripcion` AS `description`,
|
|
||||||
`e`.`visible` AS `isVisible`,
|
|
||||||
`e`.`hasCompany` AS `hasCompany`
|
|
||||||
FROM
|
|
||||||
`vn2008`.`escritos` `e`;
|
|
|
@ -1,13 +0,0 @@
|
||||||
USE `vn2008`;
|
|
||||||
|
|
||||||
ALTER TABLE `vn2008`.`reinos`
|
|
||||||
ADD COLUMN `icon` VARCHAR(45) NULL AFTER `mercancia`;
|
|
||||||
|
|
||||||
INSERT INTO `vn2008`.`reinos` (`reino`, `display`, `icon`) VALUES
|
|
||||||
('Handmade', '1', 'icon-handmade'),
|
|
||||||
('Artificial', '1', 'icon-artificial'),
|
|
||||||
('Green', '1', 'icon-greenery'),
|
|
||||||
('Accessories', '1', 'icon-accessory');
|
|
||||||
|
|
||||||
UPDATE `vn2008`.`reinos` SET `icon`='icon-plant' WHERE `id`=1;
|
|
||||||
UPDATE `vn2008`.`reinos` SET `icon`='icon-flower' WHERE `id`=2;
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,6 @@
|
||||||
|
ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1;
|
||||||
|
ALTER TABLE `vn2008`.`Consignatarios` AUTO_INCREMENT = 1;
|
||||||
|
|
||||||
INSERT INTO `util`.`config` ( `dbVersion`, `hasTriggersDisabled`, `environment`)
|
INSERT INTO `util`.`config` ( `dbVersion`, `hasTriggersDisabled`, `environment`)
|
||||||
VALUES ('1.0.0', '0', 'development');
|
VALUES ('1.0.0', '0', 'development');
|
||||||
|
|
||||||
|
@ -343,7 +346,7 @@ INSERT INTO `vn`.`invoiceOut`(`id`, `ref`, `serial`, `amount`, `issued`,`clientF
|
||||||
(13, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL +2 MONTH), DATE_ADD(CURDATE(), INTERVAL +2 MONTH), 101, 'address 21', 121, NULL, 0),
|
(13, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL +2 MONTH), DATE_ADD(CURDATE(), INTERVAL +2 MONTH), 101, 'address 21', 121, NULL, 0),
|
||||||
(14, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL +3 MONTH), DATE_ADD(CURDATE(), INTERVAL +3 MONTH), 101, 'address 21', 121, NULL, 0),
|
(14, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL +3 MONTH), DATE_ADD(CURDATE(), INTERVAL +3 MONTH), 101, 'address 21', 121, NULL, 0),
|
||||||
(15, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL +4 MONTH), DATE_ADD(CURDATE(), INTERVAL +4 MONTH), 101, 'address 21', 121, NULL, 0),
|
(15, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL +4 MONTH), DATE_ADD(CURDATE(), INTERVAL +4 MONTH), 101, 'address 21', 121, NULL, 0),
|
||||||
(16, 3, 3, 4, CURDATE() , CURDATE() , 101, 'address 21', 121, NULL, 0),
|
(16, 1, 1, 1, CURDATE() , CURDATE() , 101, 'address 21', 121, NULL, 0),
|
||||||
(17, 4, 4, 4, CURDATE() , CURDATE() , 106, 'address 26', 126, NULL, 0),
|
(17, 4, 4, 4, CURDATE() , CURDATE() , 106, 'address 26', 126, NULL, 0),
|
||||||
(18, 4, 4, 4, CURDATE() , CURDATE() , 107, 'address 27', 127, NULL, 0),
|
(18, 4, 4, 4, CURDATE() , CURDATE() , 107, 'address 27', 127, NULL, 0),
|
||||||
(19, 5, 5, 4, CURDATE() , CURDATE() , 108, 'address 28', 128, NULL, 0),
|
(19, 5, 5, 4, CURDATE() , CURDATE() , 108, 'address 28', 128, NULL, 0),
|
||||||
|
@ -426,11 +429,15 @@ INSERT INTO `vn`.`mandate`(`id`, `clientFk`, `companyFk`, `code`, `created`, `ma
|
||||||
VALUES
|
VALUES
|
||||||
(1, 102, 442, '1-1', CURDATE(), 2);
|
(1, 102, 442, '1-1', CURDATE(), 2);
|
||||||
|
|
||||||
INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`)
|
INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'Plant' , 1, 'B92A26'),
|
(1, 'Plant' , 1, 'B92A26', 'icon-plant'),
|
||||||
(2, 'Flower' , 2, 'dcf711'),
|
(2, 'Flower' , 2, 'dcf711', 'icon-flower'),
|
||||||
(3, 'Logistic', 0, 'b9f711');
|
(3, 'Logistic' , 0, 'b9f711', NULL),
|
||||||
|
(4, 'Handmade' , 1, NULL, 'icon-handmade'),
|
||||||
|
(5, 'Artificial' , 1, NULL, 'icon-artificial'),
|
||||||
|
(6, 'Green' , 1, NULL, 'icon-greenery'),
|
||||||
|
(7, 'Accessories', 1, NULL, 'icon-accessory');
|
||||||
|
|
||||||
INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`,`workerFk`, `isPackaging`)
|
INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`,`workerFk`, `isPackaging`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -510,14 +517,18 @@ INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`,
|
||||||
|
|
||||||
INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`)
|
INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
( 1, 1, 1 , 'Gem of Time', 5 , 23.5, 0, 0, 0, CURDATE()),
|
( 1, 1, 1 , 'Gem of Time', 5 , 9.60, 0, 0, 0, CURDATE()),
|
||||||
( 2, 2, 1 , 'Gem of Mind', 10 , 4.5 , 0, 0, 0, CURDATE()),
|
( 2, 2, 1 , 'Gem of Mind', 10 , 4.21, 0, 0, 0, CURDATE()),
|
||||||
( 3, 1, 1 , 'Gem of Time', 2 , 23.5, 0, 0, 0, CURDATE()),
|
( 3, 1, 1 , 'Gem of Time', 2 , 9.60, 0, 0, 0, CURDATE()),
|
||||||
( 4, 4, 1 , 'Mark I' , 20 , 9 , 0, 0, 0, CURDATE()),
|
( 4, 4, 1 , 'Mark I' , 20 , 7.06, 0, 0, 0, CURDATE()),
|
||||||
( 5, 1, 2 , 'Gem of Time', 10 , 23.5, 0, 0, 0, CURDATE()),
|
( 5, 1, 2 , 'Gem of Time', 10 , 9.60, 0, 0, 0, CURDATE()),
|
||||||
( 6, 1, 3 , 'Gem of Time', 15 , 23.5, 0, 0, 0, CURDATE()),
|
( 6, 1, 3 , 'Gem of Time', 15 , 9.60, 0, 0, 0, CURDATE()),
|
||||||
( 7, 2, 11, 'Gem of Mind', 15 , 4.5 , 0, 0, 0, CURDATE()),
|
( 7, 2, 11, 'Gem of Mind', 15 , 4.21, 0, 0, 0, CURDATE()),
|
||||||
( 8, 4, 11, 'Mark I' , 10 , 9 , 0, 0, 0, CURDATE());
|
( 8, 4, 11, 'Mark I' , 10 , 7.06, 0, 0, 0, CURDATE()),
|
||||||
|
( 9, 1, 16, 'Gem of Time', 5 , 9.60, 0, 0, 0, CURDATE()),
|
||||||
|
( 10, 2, 16, 'Gem of Mind', 10 , 4.21, 0, 0, 0, CURDATE()),
|
||||||
|
( 11, 1, 16, 'Gem of Time', 2 , 9.60, 0, 0, 0, CURDATE()),
|
||||||
|
( 12, 4, 16, 'Mark I' , 20 , 7.06, 0, 0, 0, CURDATE());
|
||||||
|
|
||||||
INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`)
|
INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -567,12 +578,32 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
|
||||||
( 8, 10, 1),
|
( 8, 10, 1),
|
||||||
( 8, 39, 5),
|
( 8, 39, 5),
|
||||||
( 8, 15, 5),
|
( 8, 15, 5),
|
||||||
( 8, 37, 2);
|
( 8, 37, 2),
|
||||||
|
( 9, 10, 1),
|
||||||
|
( 9, 14, 2.5),
|
||||||
|
( 9, 15, 3),
|
||||||
|
( 9, 17, 4.5),
|
||||||
|
( 9, 21, 5),
|
||||||
|
( 9, 23, 6.5),
|
||||||
|
( 9, 28, 1),
|
||||||
|
( 10, 28, 1),
|
||||||
|
( 11, 10, 1),
|
||||||
|
( 11, 14, 2.5),
|
||||||
|
( 11, 15, 3),
|
||||||
|
( 11, 17, 4.5),
|
||||||
|
( 11, 21, 5),
|
||||||
|
( 11, 23, 6.5),
|
||||||
|
( 11, 28, 1),
|
||||||
|
( 12, 28, 1),
|
||||||
|
( 12, 10, 1),
|
||||||
|
( 10, 17, 3.5),
|
||||||
|
( 12, 39, 5),
|
||||||
|
( 12, 37, 2);
|
||||||
|
|
||||||
INSERT INTO `vn`.`saleTracking`(`saleFk`, `isChecked`, `created`, `originalQuantity`, `workerFk`, `actionFk`, `id`, `stateFk`)
|
INSERT INTO `vn`.`saleTracking`(`saleFk`, `isChecked`, `created`, `originalQuantity`, `workerFk`, `actionFk`, `id`, `stateFk`)
|
||||||
VALUES
|
VALUES
|
||||||
( 1, 0, CURDATE(), 5, 40, 3, 1, 14),
|
( 1, 0, CURDATE(), 5, 40, 3, 1, 14),
|
||||||
( 1, 1, CURDATE(), 5, 40, 3, 2, 14),
|
( 1, 1, CURDATE(), 5, 40, 3, 2, 8),
|
||||||
( 2, 1, CURDATE(), 10, 40, 4, 3, 8),
|
( 2, 1, CURDATE(), 10, 40, 4, 3, 8),
|
||||||
( 3, 1, CURDATE(), 2, 40, 4, 4, 8);
|
( 3, 1, CURDATE(), 2, 40, 4, 4, 8);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
"The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero",
|
"The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero",
|
||||||
"The grade must be an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero",
|
"The grade must be an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero",
|
||||||
"Sample type cannot be blank": "Sample type cannot be blank",
|
"Sample type cannot be blank": "Sample type cannot be blank",
|
||||||
"The new quantity should be smaller than the old one": "La nueva cantidad debe ser menor que la anterior",
|
|
||||||
"The package cannot be blank": "The package cannot be blank",
|
"The package cannot be blank": "The package cannot be blank",
|
||||||
"The warehouse can't be repeated": "The warehouse can't be repeated"
|
"The warehouse can't be repeated": "The warehouse can't be repeated",
|
||||||
|
"The sales of that ticket can't be modified": "The sales of that ticket can't be modified",
|
||||||
|
"The new quantity should be smaller than the old one": "The new quantity should be smaller than the old one"
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ describe('client getDebt()', () => {
|
||||||
it('should return the client debt', async() => {
|
it('should return the client debt', async() => {
|
||||||
let result = await app.models.Client.getDebt(101);
|
let result = await app.models.Client.getDebt(101);
|
||||||
|
|
||||||
expect(result.debt).toEqual(1389.9);
|
expect(result.debt).toEqual(1342.66);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe('client getMana()', () => {
|
||||||
it('should call the getMana method', async() => {
|
it('should call the getMana method', async() => {
|
||||||
let result = await app.models.Client.getMana(101);
|
let result = await app.models.Client.getMana(101);
|
||||||
|
|
||||||
expect(result.mana).toEqual(260);
|
expect(result.mana).toEqual(400);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,13 @@ describe('client summary()', () => {
|
||||||
it('should return a summary object containing mana', async() => {
|
it('should return a summary object containing mana', async() => {
|
||||||
let result = await app.models.Client.summary(101);
|
let result = await app.models.Client.summary(101);
|
||||||
|
|
||||||
expect(result.mana.mana).toEqual(260);
|
expect(result.mana.mana).toEqual(400);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a summary object containing debt', async() => {
|
it('should return a summary object containing debt', async() => {
|
||||||
let result = await app.models.Client.summary(101);
|
let result = await app.models.Client.summary(101);
|
||||||
|
|
||||||
expect(result.debt.debt).toEqual(1389.9);
|
expect(result.debt.debt).toEqual(1342.66);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a summary object containing averageInvoiced', async() => {
|
it('should return a summary object containing averageInvoiced', async() => {
|
||||||
|
|
|
@ -2,14 +2,14 @@ const app = require(`${servicesDir}/item/server/server`);
|
||||||
|
|
||||||
describe('item updateTaxes()', () => {
|
describe('item updateTaxes()', () => {
|
||||||
afterAll(async() => {
|
afterAll(async() => {
|
||||||
let taxesInFixtures = [{id: 509368, taxClassFk: 1}];
|
let taxesInFixtures = [{id: 3, taxClassFk: 1}];
|
||||||
|
|
||||||
await app.models.Item.updateTaxes(taxesInFixtures);
|
await app.models.Item.updateTaxes(taxesInFixtures);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the taxClassFk is blank', async() => {
|
it('should throw an error if the taxClassFk is blank', async() => {
|
||||||
let error;
|
let error;
|
||||||
let taxes = [{id: 509368, taxClassFk: undefined}];
|
let taxes = [{id: 3, taxClassFk: undefined}];
|
||||||
|
|
||||||
await app.models.Item.updateTaxes(taxes)
|
await app.models.Item.updateTaxes(taxes)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
@ -21,11 +21,11 @@ describe('item updateTaxes()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the tax of a given country of an item', async() => {
|
it('should update the tax of a given country of an item', async() => {
|
||||||
let taxCountry = await app.models.ItemTaxCountry.findById(509368);
|
let taxCountry = await app.models.ItemTaxCountry.findById(3);
|
||||||
|
|
||||||
expect(taxCountry.taxClassFk).toEqual(1);
|
expect(taxCountry.taxClassFk).toEqual(1);
|
||||||
|
|
||||||
let taxes = [{id: 509368, taxClassFk: 2}];
|
let taxes = [{id: 3, taxClassFk: 2}];
|
||||||
|
|
||||||
let result = await app.models.Item.updateTaxes(taxes);
|
let result = await app.models.Item.updateTaxes(taxes);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ describe('item updateTaxes()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should confirm the tax class was updated', async() => {
|
it('should confirm the tax class was updated', async() => {
|
||||||
let taxCountry = await app.models.ItemTaxCountry.findById(509368);
|
let taxCountry = await app.models.ItemTaxCountry.findById(3);
|
||||||
|
|
||||||
expect(taxCountry.taxClassFk).toEqual(2);
|
expect(taxCountry.taxClassFk).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,8 +10,8 @@ describe('sale priceDifference()', () => {
|
||||||
};
|
};
|
||||||
let result = await app.models.Sale.priceDifference(1, data);
|
let result = await app.models.Sale.priceDifference(1, data);
|
||||||
|
|
||||||
expect(result.totalUnitPrice).toEqual(60.5);
|
expect(result.totalUnitPrice).toEqual(30.469999999999995);
|
||||||
expect(result.totalNewPrice).toEqual(26.12);
|
expect(result.totalNewPrice).toEqual(26.12);
|
||||||
expect(result.totalDifference).toEqual(202.80);
|
expect(result.totalDifference).toEqual(63.8);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe('ticket getSalesPersonMana()', () => {
|
||||||
it('should get the mana of a salesperson of a given ticket', async() => {
|
it('should get the mana of a salesperson of a given ticket', async() => {
|
||||||
let mana = await app.models.Ticket.getSalesPersonMana(1);
|
let mana = await app.models.Ticket.getSalesPersonMana(1);
|
||||||
|
|
||||||
expect(mana).toEqual(330);
|
expect(mana).toEqual(470);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return 0 if the given ticket does not exists', async() => {
|
it('should return 0 if the given ticket does not exists', async() => {
|
||||||
|
|
|
@ -4,6 +4,6 @@ describe('ticket getTaxes()', () => {
|
||||||
it('should return the tax of a given ticket', async() => {
|
it('should return the tax of a given ticket', async() => {
|
||||||
let result = await app.models.Ticket.getTaxes(1);
|
let result = await app.models.Ticket.getTaxes(1);
|
||||||
|
|
||||||
expect(result[0].tax).toEqual(20.95);
|
expect(result[0].tax).toEqual(10.93);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe('ticket getTotal()', () => {
|
||||||
it('should return the total of a ticket', async() => {
|
it('should return the total of a ticket', async() => {
|
||||||
let result = await app.models.Ticket.getTotal(1);
|
let result = await app.models.Ticket.getTotal(1);
|
||||||
|
|
||||||
expect(result).toEqual(448.25);
|
expect(result).toEqual(291.08);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should return zero if the ticket doesn't have lines`, async() => {
|
it(`should return zero if the ticket doesn't have lines`, async() => {
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe('ticket getVAT()', () => {
|
||||||
it('should call the getVAT method and return the response', async() => {
|
it('should call the getVAT method and return the response', async() => {
|
||||||
await app.models.Ticket.getVAT(1)
|
await app.models.Ticket.getVAT(1)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
expect(response).toEqual(58.75);
|
expect(response).toEqual(40.58);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('ticket new()', () => {
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
clientFk: 101,
|
clientFk: 101,
|
||||||
companyFk: 442,
|
companyFk: 442,
|
||||||
addressFk: 25516,
|
addressFk: 1,
|
||||||
agencyModeFk: 1,
|
agencyModeFk: 1,
|
||||||
userId: 9
|
userId: 9
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,13 +17,13 @@ describe('ticket summary()', () => {
|
||||||
it('should return a summary object containing subTotal for 1 ticket', async() => {
|
it('should return a summary object containing subTotal for 1 ticket', async() => {
|
||||||
let result = await app.models.Ticket.summary(1);
|
let result = await app.models.Ticket.summary(1);
|
||||||
|
|
||||||
expect(result.subTotal).toEqual(389.5);
|
expect(result.subTotal).toEqual(250.5);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a summary object containing VAT for 1 ticket', async() => {
|
it('should return a summary object containing VAT for 1 ticket', async() => {
|
||||||
let result = await app.models.Ticket.summary(1);
|
let result = await app.models.Ticket.summary(1);
|
||||||
|
|
||||||
expect(result.VAT).toEqual(58.75);
|
expect(result.VAT).toEqual(40.58);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a summary object containing total for 1 ticket', async() => {
|
it('should return a summary object containing total for 1 ticket', async() => {
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe('workerMana getCurrentWorkerMana()', () => {
|
||||||
it('should get the mana of the logged worker', async() => {
|
it('should get the mana of the logged worker', async() => {
|
||||||
let mana = await app.models.WorkerMana.getCurrentWorkerMana({req: {accessToken: {userId: 18}}});
|
let mana = await app.models.WorkerMana.getCurrentWorkerMana({req: {accessToken: {userId: 18}}});
|
||||||
|
|
||||||
expect(mana).toEqual(330);
|
expect(mana).toEqual(470);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return 0 if the user doesnt uses mana', async() => {
|
it('should return 0 if the user doesnt uses mana', async() => {
|
||||||
|
|
|
@ -2,8 +2,9 @@ const app = require(`${servicesDir}/client/server/server`);
|
||||||
|
|
||||||
describe('loopback model address', () => {
|
describe('loopback model address', () => {
|
||||||
let createdAddressId;
|
let createdAddressId;
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async() => {
|
||||||
let address = await app.models.Address.findById(25516);
|
let address = await app.models.Address.findById(1);
|
||||||
let client = await app.models.Client.findById(101);
|
let client = await app.models.Client.findById(101);
|
||||||
|
|
||||||
await address.updateAttribute('isDefaultAddress', true);
|
await address.updateAttribute('isDefaultAddress', true);
|
||||||
|
@ -13,9 +14,9 @@ describe('loopback model address', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('observe()', () => {
|
describe('observe()', () => {
|
||||||
it('should throw an error if the default consignee is unchecked', async() => {
|
it('should throw an error when deactivating a consignee if its the default address', async() => {
|
||||||
let error;
|
let error;
|
||||||
let address = await app.models.Address.findById(25516);
|
let address = await app.models.Address.findById(1);
|
||||||
|
|
||||||
await address.updateAttribute('isActive', false)
|
await address.updateAttribute('isActive', false)
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
@ -28,7 +29,7 @@ describe('loopback model address', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set isDefaultAddress to false of all the addresses for a given client', async() => {
|
it('should set isDefaultAddress to false of all the addresses for a given client', async() => {
|
||||||
let previousDefaultAddress = await app.models.Address.findById(25516);
|
let previousDefaultAddress = await app.models.Address.findById(1);
|
||||||
|
|
||||||
expect(previousDefaultAddress.isDefaultAddress).toBeTruthy();
|
expect(previousDefaultAddress.isDefaultAddress).toBeTruthy();
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ describe('loopback model address', () => {
|
||||||
|
|
||||||
expect(defaultAddress.isDefaultAddress).toBeTruthy();
|
expect(defaultAddress.isDefaultAddress).toBeTruthy();
|
||||||
|
|
||||||
let noLongerDefaultAddress = await app.models.Address.findById(25516);
|
let noLongerDefaultAddress = await app.models.Address.findById(1);
|
||||||
|
|
||||||
expect(noLongerDefaultAddress.isDefaultAddress).toBeFalsy();
|
expect(noLongerDefaultAddress.isDefaultAddress).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,6 +45,8 @@ VnMySQL.prototype.toColumnValue = function(prop, val) {
|
||||||
if (val == null || !prop || prop.type !== Date)
|
if (val == null || !prop || prop.type !== Date)
|
||||||
return MySQL.prototype.toColumnValue.call(this, prop, val);
|
return MySQL.prototype.toColumnValue.call(this, prop, val);
|
||||||
|
|
||||||
|
val = new Date(val);
|
||||||
|
|
||||||
return val.getFullYear() + '-' +
|
return val.getFullYear() + '-' +
|
||||||
fillZeros(val.getMonth() + 1) + '-' +
|
fillZeros(val.getMonth() + 1) + '-' +
|
||||||
fillZeros(val.getDate()) + ' ' +
|
fillZeros(val.getDate()) + ' ' +
|
||||||
|
@ -96,7 +98,7 @@ VnMySQL.prototype._makeWhere = function(model, where) {
|
||||||
}
|
}
|
||||||
stmt.merge({
|
stmt.merge({
|
||||||
sql: branches.join(' ' + key.toUpperCase() + ' '),
|
sql: branches.join(' ' + key.toUpperCase() + ' '),
|
||||||
params: branchParams,
|
params: branchParams
|
||||||
});
|
});
|
||||||
whereStmts.push(stmt);
|
whereStmts.push(stmt);
|
||||||
continue;
|
continue;
|
||||||
|
@ -154,17 +156,15 @@ VnMySQL.prototype._makeWhere = function(model, where) {
|
||||||
columnValue = self.toColumnValue(p, expression);
|
columnValue = self.toColumnValue(p, expression);
|
||||||
if (columnValue === null) {
|
if (columnValue === null) {
|
||||||
stmt.merge(columnName + ' IS NULL');
|
stmt.merge(columnName + ' IS NULL');
|
||||||
} else {
|
} else if (columnValue instanceof ParameterizedSQL) {
|
||||||
if (columnValue instanceof ParameterizedSQL) {
|
|
||||||
stmt.merge(columnName + '=').merge(columnValue);
|
stmt.merge(columnName + '=').merge(columnValue);
|
||||||
} else {
|
} else {
|
||||||
stmt.merge({
|
stmt.merge({
|
||||||
sql: columnName + '=?',
|
sql: columnName + '=?',
|
||||||
params: [columnValue],
|
params: [columnValue]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
whereStmts.push(stmt);
|
whereStmts.push(stmt);
|
||||||
}
|
}
|
||||||
var params = [];
|
var params = [];
|
||||||
|
@ -175,7 +175,7 @@ VnMySQL.prototype._makeWhere = function(model, where) {
|
||||||
}
|
}
|
||||||
var whereStmt = new ParameterizedSQL({
|
var whereStmt = new ParameterizedSQL({
|
||||||
sql: sqls.join(' AND '),
|
sql: sqls.join(' AND '),
|
||||||
params: params,
|
params: params
|
||||||
});
|
});
|
||||||
return whereStmt;
|
return whereStmt;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const app = require(`${servicesDir}/order/server/server`);
|
const app = require(`${servicesDir}/order/server/server`);
|
||||||
|
|
||||||
describe('order getTaxes()', () => {
|
xdescribe('order getTaxes()', () => {
|
||||||
it('should call the getTaxes method and return undefined if its called with a string', async() => {
|
it('should call the getTaxes method and return undefined if its called with a string', async() => {
|
||||||
let result = await app.models.Order.getTaxes('pepinillos');
|
let result = await app.models.Order.getTaxes('pepinillos');
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const app = require(`${servicesDir}/order/server/server`);
|
const app = require(`${servicesDir}/order/server/server`);
|
||||||
|
|
||||||
describe('order getTotal()', () => {
|
xdescribe('order getTotal()', () => {
|
||||||
it('should return the total', async() => {
|
it('should return the total', async() => {
|
||||||
let result = await app.models.Order.getTotal(1);
|
let result = await app.models.Order.getTotal(1);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('order new()', () => {
|
||||||
|
|
||||||
it('should throw an error if the client isnt frozen and isnt active', async() => {
|
it('should throw an error if the client isnt frozen and isnt active', async() => {
|
||||||
let error;
|
let error;
|
||||||
let params = {addressFk: 25521};
|
let params = {addressFk: 6};
|
||||||
|
|
||||||
await app.models.Order.new(params)
|
await app.models.Order.new(params)
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
@ -28,7 +28,7 @@ describe('order new()', () => {
|
||||||
|
|
||||||
it('should throw an error if the client isnt frozen and is active but doesnt have data checked', async() => {
|
it('should throw an error if the client isnt frozen and is active but doesnt have data checked', async() => {
|
||||||
let error;
|
let error;
|
||||||
let params = {addressFk: 25522};
|
let params = {addressFk: 7};
|
||||||
|
|
||||||
await app.models.Order.new(params)
|
await app.models.Order.new(params)
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
|
Loading…
Reference in New Issue