This commit is contained in:
Joan 2018-12-13 08:54:22 +01:00
commit 7fea1fe2ac
88 changed files with 654 additions and 327 deletions

View File

@ -27,45 +27,28 @@
{
"url": "/:id",
"state": "zone.card",
"component": "vn-zone-card",
"abstract": true,
"component": "vn-zone-card"
"description": "Detail"
},
{
"url" : "/summary",
"state": "zone.card.summary",
"component": "vn-zone-summary",
"description": "Summary",
"url": "/location",
"state": "zone.card.location",
"component": "vn-zone-location",
"description": "Location",
"params": {
"zone": "$ctrl.zone"
}
},
{
"url": "/basic-data",
"state": "zone.card.basicData",
"component": "vn-zone-basic-data",
"description": "Basic data",
"url": "/edit",
"state": "zone.card.edit",
"component": "vn-zone-edit",
"description": "Edit zone",
"params": {
"zone": "$ctrl.zone"
},
"menu": {
"icon": "settings"
}
},
{
"url": "/delivery-day",
"state": "zone.card.deliveryDay",
"component": "vn-zone-delivery-day",
"description": "Delivery days",
"params": {
"zone": "$ctrl.zone"
},
"menu": {
"icon": "today"
}
}
],
"menu": [
{"state": "zone.card.basicData", "icon": "settings"},
{"state": "zone.card.deliveryDay", "icon": "today"}
]
"menu": []
}

View File

@ -1,4 +1,4 @@
import ngModule from '../../module';
import ngModule from '../module';
class Controller {
constructor($scope) {
@ -18,9 +18,6 @@ Controller.$inject = ['$scope'];
ngModule.component('vnZoneCalendar', {
template: require('./index.html'),
controller: Controller,
require: {
catalog: '^vnZoneDeliveryDay'
},
bindings: {
zone: '<'
}

View File

@ -0,0 +1,11 @@
<vn-main-block>
<vn-vertical margin-medium>
<vn-zone-descriptor zone="$ctrl.zone"></vn-zone-descriptor>
<vn-horizontal>
<vn-one ui-view></vn-one>
<vn-auto class="right-block">
<vn-zone-calendar zone="$ctrl.zone"></vn-zone-calendar>
</vn-auto>
</vn-horizontal>
</vn-vertical>
</vn-main-block>

View File

@ -1,4 +1,4 @@
import ngModule from '../../module';
import ngModule from '../module';
class Controller {
constructor($http, $stateParams) {

View File

@ -1,4 +1,4 @@
import ngModule from '../../module';
import ngModule from '../module';
export default class Controller {
constructor($scope, $state) {

View File

@ -1,5 +1,5 @@
import './index';
import {watcher} from '../../../../helpers/watcherHelper';
import {watcher} from '../../../helpers/watcherHelper';
describe('Agency', () => {
describe('Component vnZoneCreate', () => {

View File

@ -0,0 +1,54 @@
<vn-card margin-medium-v class="vn-descriptor">
<vn-horizontal class="header">
<a translate-attr="{title: 'Return to module index'}" ui-sref="zone.index">
<vn-icon icon="chevron_left"></vn-icon>
</a>
<vn-icon icon="my_location"></vn-icon>
<vn-icon-menu
vn-id="more-button"
icon="more_vert"
show-filter="false"
value-field="callback"
translate-fields="['name']"
data="$ctrl.moreOptions"
on-change="$ctrl.onMoreChange(value)">
</vn-icon-menu>
</vn-horizontal>
<vn-horizontal pad-medium>
<vn-one>
<vn-label-value label="Id"
value="{{::$ctrl.zone.id}}">
</vn-label-value>
<vn-label-value label="Name"
value="{{::$ctrl.zone.name}}">
</vn-label-value>
<vn-label-value label="Warehouse"
value="{{::$ctrl.zone.warehouse.name}}">
</vn-label-value>
<vn-label-value label="Agency"
value="{{::$ctrl.zone.agencyMode.name}}">
</vn-label-value>
</vn-one>
<vn-one>
<vn-label-value label="Estimated hour (ETD)"
value="{{::$ctrl.zone.hour | date: 'HH:mm'}}">
</vn-label-value>
<vn-label-value label="Traveling days"
value="{{::$ctrl.zone.travelingDays}}">
</vn-label-value>
<vn-label-value label="Price"
value="{{::$ctrl.zone.price | currency: '€': 2}}">
</vn-label-value>
<vn-label-value label="Bonus"
value="{{::$ctrl.zone.price | currency: '€': 2}}">
</vn-label-value>
</vn-one>
</vn-horizontal>
</vn-card>
<vn-confirm
vn-id="delete-zone"
on-response="$ctrl.returnDialog(response)"
question="Delete zone"
message="Are you sure you want to delete this zone?">
</vn-confirm>

View File

@ -0,0 +1,43 @@
import ngModule from '../module';
class Controller {
constructor($scope, $state, $http) {
this.$scope = $scope;
this.$state = $state;
this.$http = $http;
this.moreOptions = [
{callback: this.editZone, name: 'Settings'},
{callback: this.deleteZone, name: 'Delete'}
];
}
onMoreChange(callback) {
callback.call(this);
}
deleteZone() {
this.$scope.deleteZone.show();
}
editZone() {
this.$state.go('zone.card.edit', {zone: this.zone});
}
returnDialog(response) {
if (response === 'ACCEPT') {
this.$http.delete(`/agency/api/Zones/${this.zone.id}`).then(() => {
this.$state.go('zone.index');
});
}
}
}
Controller.$inject = ['$scope', '$state', '$http'];
ngModule.component('vnZoneDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
zone: '<'
}
});

View File

@ -7,7 +7,7 @@
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()">
<vn-card pad-large>
<vn-title>Basic data</vn-title>
<vn-title>Edit zone</vn-title>
<vn-horizontal>
<vn-textfield vn-two vn-focus
label="Name"
@ -63,5 +63,6 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button ui-sref="zone.card.location" label="Cancel"></vn-button>
</vn-button-bar>
</form>

View File

@ -1,21 +1,22 @@
import ngModule from '../../module';
import ngModule from '../module';
class Controller {
constructor($scope) {
constructor($scope, $state) {
this.$scope = $scope;
this.$state = $state;
}
onSubmit() {
this.$scope.watcher.submit().then(() => {
this.$state.go('zone.card.location');
this.card.reload();
});
}
}
Controller.$inject = ['$scope'];
Controller.$inject = ['$scope', '$state'];
ngModule.component('vnZoneBasicData', {
ngModule.component('vnZoneEdit', {
template: require('./index.html'),
controller: Controller,
bindings: {

View File

@ -1,12 +1,12 @@
export * from './module';
// import components
import './zone/card';
import './zone/descriptor';
import './zone/search-panel';
import './zone/index';
import './zone/create';
import './zone/summary';
import './zone/basic-data';
import './zone/delivery-day';
import './zone/calendar';
import './index/index';
import './summary';
import './card';
import './descriptor';
import './search-panel';
import './create';
import './edit';
import './location';
import './calendar';

View File

@ -31,7 +31,7 @@
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="zone in zones" ui-sref="zone.card.basicData({id: zone.id})" class=clickable>
<vn-tr ng-repeat="zone in zones" ui-sref="zone.card.location({id: zone.id})" class=clickable>
<vn-td number>{{::zone.id}}</vn-td>
<vn-td>{{::zone.name}}</vn-td>
<vn-td>{{::zone.agencyMode.name}}</vn-td>
@ -58,13 +58,6 @@
</vn-pagination>
</div>
<vn-dialog class="dialog-summary"
vn-id="dialog">
<tpl-body>
<vn-zone-summary vn-id="summary"></vn-zone-summary>
</tpl-body>
</vn-dialog>
<a ui-sref="zone.create" vn-tooltip="New zone" vn-bind="+" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>
</a>

View File

@ -1,4 +1,4 @@
import ngModule from '../../module';
import ngModule from '../module';
export default class Controller {
constructor($scope) {

View File

@ -4,10 +4,15 @@ Warehouse: Almacén
Hour: Hora (ETD)
Price: Precio
Create: Crear
Delete: Eliminar
Settings: Ajustes
Delivery days: Días de envío
Enter a new search: Introduce una nueva búsqueda
Delete zone: Eliminar zona
Are you sure you want to delete this zone?: ¿Estás seguro de querer eliminar esta zona?
Zones: Zonas
List: Listado
Summary: Vista previa
New zone: Nueva zona
Basic data: Datos básicos
Delivery days: Días de envío
Edit zone: Editar zona

View File

@ -0,0 +1,7 @@
import ngModule from '../module';
import SearchPanel from 'core/src/components/searchbar/search-panel';
ngModule.component('vnLocationSearchPanel', {
template: require('./index.html'),
controller: SearchPanel
});

View File

@ -0,0 +1,18 @@
<vn-crud-model
vn-id="model"
url="/agency/api/ZoneGeos"
data="geos">
</vn-crud-model>
<vn-vertical vn-one>
<vn-card pad-large>
<vn-title>Delivery days</vn-title>
<vn-searchbar
panel="vn-calendar-search-panel"
model="model"
expr-builder="$ctrl.exprBuilder(param, value)"
vn-focus>
</vn-searchbar>
<vn-treeview model="model"></vn-treeview>
</vn-card>
</vn-vertical>

View File

@ -1,7 +1,6 @@
import ngModule from '../../module';
import ngModule from '../module';
class Controller {
constructor($scope) {
this.$scope = $scope;
}
@ -9,7 +8,7 @@ class Controller {
Controller.$inject = ['$scope'];
ngModule.component('vnZoneDeliveryDay', {
ngModule.component('vnZoneLocation', {
template: require('./index.html'),
controller: Controller,
bindings: {

View File

@ -0,0 +1,40 @@
<div pad-large style="min-width: 30em">
<form ng-submit="$ctrl.onSearch()">
<vn-horizontal>
<vn-textfield
vn-one
label="General search"
model="filter.search"
vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Name"
model="filter.name">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
label="Agency"
field="filter.agencyModeFk"
url="/agency/api/AgencyModes"
show-field="name"
value-field="id">
</vn-autocomplete>
<vn-autocomplete
vn-one
label="Warehouse"
field="filter.warehouseFk"
url="/agency/api/Warehouses"
show-field="name"
value-field="id">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal margin-large-top>
<vn-submit label="Search"></vn-submit>
</vn-horizontal>
</form>
</div>

View File

@ -1,4 +1,4 @@
import ngModule from '../../module';
import ngModule from '../module';
import SearchPanel from 'core/src/components/searchbar/search-panel';
ngModule.component('vnZoneSearchPanel', {

View File

@ -1,4 +1,4 @@
import ngModule from '../../module';
import ngModule from '../module';
class Controller {
constructor($http) {

View File

@ -1,11 +0,0 @@
<vn-main-block>
<vn-horizontal>
<vn-auto class="left-block">
<vn-zone-descriptor zone="$ctrl.zone"></vn-zone-descriptor>
<vn-left-menu></vn-left-menu>
</vn-auto>
<vn-one>
<vn-vertical margin-medium ui-view></vn-vertical>
</vn-one>
</vn-horizontal>
</vn-main-block>

View File

@ -1,19 +0,0 @@
<vn-crud-model
vn-id="model"
url="/agency/api/ZoneGeos"
data="geos">
</vn-crud-model>
<vn-horizontal>
<vn-vertical vn-one>
<vn-card pad-large>
<vn-title>Delivery days</vn-title>
<vn-treeview model="model"></vn-treeview>
</vn-card>
</vn-vertical>
<vn-auto class="right-block">
<vn-zone-calendar zone="$ctrl.zone"></vn-zone-calendar>
</vn-auto>
</vn-horizontal>

View File

@ -1,34 +0,0 @@
<vn-card margin-medium-v class="vn-descriptor">
<vn-horizontal class="header">
<a translate-attr="{title: 'Return to module index'}" ui-sref="zone.index">
<vn-icon icon="chevron_left"></vn-icon>
</a>
<vn-icon icon="my_location"></vn-icon>
<a translate-attr="{title: 'Preview'}" ui-sref="zone.card.summary">
<vn-icon icon="desktop_windows"></vn-icon>
</a>
</vn-horizontal>
<div pad-medium>
<vn-label-value label="Id"
value="{{$ctrl.zone.id}}">
</vn-label-value>
<vn-label-value label="Name"
value="{{$ctrl.zone.name}}">
</vn-label-value>
<vn-label-value label="Warehouse"
value="{{$ctrl.zone.warehouse.name}}">
</vn-label-value>
<vn-label-value label="Agency"
value="{{$ctrl.zone.agencyMode.name}}">
</vn-label-value>
<vn-label-value label="Estimated hour (ETD)"
value="{{$ctrl.zone.hour | date: 'HH:mm'}}">
</vn-label-value>
<vn-label-value label="Price"
value="{{$ctrl.zone.price | currency: '€': 2}}">
</vn-label-value>
<vn-label-value label="Bonus"
value="{{$ctrl.zone.price | currency: '€': 2}}">
</vn-label-value>
</div>
</vn-card>

View File

@ -1,8 +0,0 @@
import ngModule from '../../module';
ngModule.component('vnZoneDescriptor', {
template: require('./index.html'),
bindings: {
zone: '<'
}
});

View File

@ -1,42 +0,0 @@
import './index.js';
describe('Agency', () => {
describe('Component summary', () => {
let $componentController;
let controller;
let $httpBackend;
beforeEach(() => {
angular.mock.module('agency');
});
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
controller = $componentController('vnZoneSummary');
controller.zone = {id: 1};
}));
describe('getSummary()', () => {
it("should perform a query to set summary", () => {
let data = {name: 'Zone One', price: 0};
$httpBackend.when('GET', `/agency/api/Zones/1`).respond(200, data);
$httpBackend.expect('GET', `/agency/api/Zones/1`);
controller.getSummary();
$httpBackend.flush();
expect(controller.summary).toEqual(data);
});
});
describe('setter zone()', () => {
it("should call getSummary and define summary property", () => {
spyOn(controller, 'getSummary');
controller.zone = {id: 1};
expect(controller.getSummary).toHaveBeenCalledWith();
});
});
});
});

View File

@ -1,2 +0,0 @@
Niche: Nichos
Barcode: Códigos de barras

View File

@ -79,7 +79,7 @@
medium-grey
margin-medium-v
vn-tooltip="Remove line"
icon="remove_circle_outline"
icon="delete"
ng-click="$ctrl.deleteClaimedSale(saleClaimed.id)"
tabindex="-1">
</vn-icon-button>
@ -147,6 +147,7 @@
<vn-crud-model
vn-id="lastTicketsModel"
url="/claim/api/Tickets"
limit="20"
data="lastTickets" auto-load="false">
</vn-crud-model>
<!-- Transfer Popover -->

View File

@ -19,14 +19,16 @@
</vn-label-value>
<vn-label-value label="Created"
value="{{$ctrl.claim.created | dateTime: 'dd/MM/yyyy'}}">
</vn-label-value>
</vn-label-value>
<vn-label-value label="Salesperson"
value="{{$ctrl.claim.client.salesPerson.firstName}} {{$ctrl.claim.client.salesPerson.name}}">
</vn-label-value>
<vn-label-value label="Attended by"
value="{{$ctrl.claim.worker.firstName}} {{$ctrl.claim.worker.name}}">
</vn-label-value>
<vn-label-value label="Ticket" ui-sref="ticket.card.summary({id: $ctrl.claim.ticketFk})" class="link"
value="{{$ctrl.claim.ticketFk}}">
</vn-label-value>
</vn-auto>
</vn-vertical>
<vn-horizontal pad-small class="quicklinks">

View File

@ -65,7 +65,7 @@
medium-grey
margin-medium-v
vn-tooltip="Remove sale"
icon="remove_circle_outline"
icon="delete"
ng-click="$ctrl.deleteClaimedSale($index)"
tabindex="-1">
</vn-icon-button>

View File

@ -21,12 +21,6 @@
data="claimResponsibles"
order="description">
</vn-crud-model>
<vn-crud-model
url="/client/api/Clients/activeWorkersWithRole"
where="{role: 'salesPerson'}"
data="activeSalesPersons"
order="firstName">
</vn-crud-model>
<vn-crud-model
url="claim/api/ClaimRedeliveries"
data="claimRedeliveries"
@ -78,8 +72,11 @@
vn-one
label="Worker"
field="claimDevelopment.workerFk"
data="activeSalesPersons"
url="/client/api/Clients/activeWorkersWithRole"
search-function="{firstName: $search}"
where="{role: 'employee'}"
show-field="firstName"
value-field="id"
vn-acl="salesAssistant">
<tpl-item>{{firstName}} {{name}}</tpl-item>
</vn-autocomplete>
@ -97,7 +94,7 @@
medium-grey
margin-medium-v
vn-tooltip="Remove sale"
icon="remove_circle_outline"
icon="delete"
ng-click="model.remove($index)"
tabindex="-1"
vn-acl="salesAssistant">

View File

@ -31,7 +31,10 @@
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="claim in claims" ui-sref="claim.card.summary({id: claim.id})" class=clickable>
<a
ng-repeat="claim in claims"
class="{{::$ctrl.compareDate(ticket.shipped)}} clickable vn-tr"
ui-sref="claim.card.summary({id: claim.id})">
<vn-td number>{{::claim.id}}</vn-td>
<vn-td>
<span class="link" ng-click="$ctrl.showDescriptor($event, claim.client.id)">
@ -48,9 +51,12 @@
icon="desktop_windows">
</vn-icon-button>
</vn-td>
</vn-tr>
</a>
</vn-tbody>
<vn-empty-rows ng-if="!model.data || model.data.length === 0" translate>
<vn-empty-rows ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
<vn-empty-rows ng-if="model.data === null" translate>
Enter a new search
</vn-empty-rows>
</vn-table>

View File

@ -39,11 +39,12 @@
</vn-autocomplete>
<vn-autocomplete
vn-one
label="Worker"
field="filter.workerFk"
url="/claim/api/Workers"
show-field="firstName"
value-field="id">
url="/client/api/Clients/activeWorkersWithRole"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Worker">
<tpl-item>{{firstName}} {{name}}</tpl-item>
</vn-autocomplete>
</vn-horizontal>

View File

@ -40,7 +40,7 @@
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one margin-medium>
<vn-one margin-medium-v>
<h5 translate>Detail</h5>
<vn-table model="model">
<vn-thead>
@ -85,7 +85,7 @@
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one margin-medium>
<vn-one margin-medium-v>
<h5 translate>Development</h5>
<vn-table model="model">
<vn-thead>
@ -113,7 +113,7 @@
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one margin-medium>
<vn-one margin-medium-v>
<h5 translate>Action</h5>
<vn-table model="model">
<vn-thead>

View File

@ -84,7 +84,7 @@
medium-grey
margin-medium-v
vn-tooltip="Remove note"
icon="remove_circle_outline"
icon="delete"
ng-click="$ctrl.removeObservation($index)"
tabindex="-1">
</vn-icon-button>

View File

@ -32,7 +32,7 @@
medium-grey
margin-medium-v
vn-tooltip="Remove contact"
icon="remove_circle_outline"
icon="delete"
ng-click="model.remove($index)">
</vn-icon>
</vn-none>

View File

@ -100,7 +100,8 @@
<vn-check
vn-one
label="Is equalizated"
field="$ctrl.client.isEqualizated">
field="$ctrl.client.isEqualizated"
info="In order to invoice, this field is not consulted, but the consignee's ET. When modifying this field if the invoice by address option is not checked, the change will be automatically propagated to all addresses, otherwise the user will be asked if he wants to propagate it or not.">
</vn-check>
<vn-check
vn-one

View File

@ -15,9 +15,8 @@ export default class Controller {
}
copyData() {
if (this.client) {
if (this.client)
this.isEqualizated = this.client.isEqualizated;
}
}
buyerHaspermissions() {
@ -26,8 +25,10 @@ export default class Controller {
}
submit() {
if (this.isEqualizated != this.client.isEqualizated)
if (this.isEqualizated != this.client.isEqualizated) {
this.oldHasToInvoiceByAddress = this.client.hasToInvoiceByAddress;
this.client.hasToInvoiceByAddress = false;
}
return this.$.watcher.submit().then(
() => this.checkEtChanges());
@ -37,17 +38,20 @@ export default class Controller {
let equals = this.isEqualizated == this.client.isEqualizated;
this.isEqualizated = this.client.isEqualizated;
if (!equals)
if (!equals && !this.oldHasToInvoiceByAddress)
this.$.propagateIsEqualizated.show();
else if (!equals)
this.returnDialogEt('ACCEPT');
delete this.oldHasToInvoiceByAddress;
}
returnDialogEt(response) {
if (response === 'ACCEPT') {
this.$http.patch(`/client/api/Clients/${this.client.id}/addressesPropagateRe`, {isEqualizated: this.client.isEqualizated}).then(
res => {
if (res.data) {
if (res.data)
this.vnApp.showMessage(this.translate.instant('Equivalent tax spreaded'));
}
}
);
}

View File

@ -2,3 +2,4 @@ Yes, notify: Sí, notificar
You changed the equalization tax: Has cambiado el recargo de equivalencia
Do you want to spread the change?: ¿Deseas propagar el cambio a sus consignatarios?
Frozen: Congelado
In order to invoice, this field is not consulted, but the consignee's ET. When modifying this field if the invoice by address option is not checked, the change will be automatically propagated to all addresses, otherwise the user will be asked if he wants to propagate it or not.: Para facturar no se consulta este campo, sino el RE de consignatario. Al modificar este campo si no esta marcada la casilla Facturar por consignatario, se propagará automáticamente el cambio a todos los consignatarios, en caso contrario preguntará al usuario si quiere o no propagar.

View File

@ -23,7 +23,11 @@
client="::client">
</vn-item-client>
<vn-empty-rows class="vn-list-item" style="text-align: center"
ng-if="!model.data || model.data.length === 0" translate>
ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
<vn-empty-rows class="vn-list-item" style="text-align: center"
ng-if="model.data === null" translate>
Enter a new search
</vn-empty-rows>
</vn-card>

View File

@ -48,7 +48,7 @@
<vn-th>Reference</vn-th>
<vn-th>Bank</vn-th>
<vn-th>Debit</vn-th>
<vn-th>Credit</vn-th>
<vn-th>Havings</vn-th>
<vn-th>Balance</vn-th>
<vn-th>Conciliated</vn-th>
</vn-tr>

View File

@ -4,3 +4,4 @@ Bank: Caja
Debit: Debe
Conciliated: Conciliado
New payment: Añadir pago
Havings: Haber

View File

@ -4,6 +4,8 @@ vn-dialog {
}
}
vn-client-summary .bold {
font-family: vn-font-bold;
vn-client-summary {
.bold {
font-family: vn-font-bold;
}
}

View File

@ -13,18 +13,33 @@
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th></vn-th>
<vn-th>State</vn-th>
<vn-th field="id">Id</vn-th>
<vn-th field="amount" number>Amount</vn-th>
<vn-th field="created" default-order="DESC">Payed</vn-th>
<vn-th></vn-th>
<vn-th>Confirm</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="transaction in transactions">
<vn-td style="width: 3em; text-align: center">
<vn-icon
vn-tooltip="{{$ctrl.getFormattedMessage(transaction)}}"
ng-show="::((transaction.errorMessage || transaction.responseMessage) && !transaction.isConfirmed)"
icon="clear">
</vn-icon>
<vn-icon
vn-tooltip="Confirmed"
ng-show="::(transaction.isConfirmed)"
icon="check">
</vn-icon>
</vn-td>
<vn-td>{{::transaction.id}}</vn-td>
<vn-td number>{{::transaction.amount | currency: '€':2}}</vn-td>
<vn-td>{{::transaction.created | dateTime:'dd/MM/yyyy'}}</vn-td>
<vn-td style="width: 3em; text-align: center">
<vn-icon-button
icon="check"
icon="done_all"
vn-acl="administrative"
vn-acl-action="remove"
vn-tooltip="Confirm transaction"
@ -32,17 +47,6 @@
ng-click="$ctrl.confirm(transaction)">
</vn-icon-button>
</vn-td>
<vn-td>{{::transaction.id}}</vn-td>
<vn-td number>{{::transaction.amount | currency: '€':2}}</vn-td>
<vn-td>{{::transaction.created | dateTime:'dd/MM/yyyy'}}</vn-td>
<vn-td style="width: 1px">
<vn-icon orange
vn-tooltip="{{$ctrl.getFormattedMessage(transaction)}}"
ng-show="::(transaction.errorMessage || transaction.responseMessage)"
icon="warning">
</vn-icon>
</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="model.data.length === 0" translate>

View File

@ -1,4 +1,5 @@
import ngModule from '../module';
import './style.scss';
class Controller {
constructor($scope, $http, $stateParams) {

View File

@ -2,3 +2,5 @@ Web Payment: Pago Web
Confirmed: Confirmado
Payed: Pagado
Confirm transaction: Confirmar transacción
Confirm: Confirmar
State: Estado

View File

@ -0,0 +1,10 @@
@import "colors";
vn-client-web-payment {
vn-icon[icon=clear] {
color: $alert01;
}
vn-icon[icon=check] {
color: $main-02;
}
}

View File

@ -2,3 +2,8 @@
<input type="checkbox" class="mdl-checkbox__input"/>
<span class="mdl-checkbox__label" translate>{{::$ctrl.label}}</span>
</label>
<i class="material-icons"
ng-if="$ctrl.hasInfo"
vn-tooltip="{{$ctrl.info}}">
info_outline
</i>

View File

@ -3,11 +3,13 @@ import Input from '../../lib/input';
import './style.scss';
export default class Controller extends Input {
constructor($element, $scope) {
constructor($element, $scope, $attrs) {
super($element, $scope);
componentHandler.upgradeElement(this.element.firstChild);
this.mdlElement = this.element.firstChild.MaterialCheckbox;
this.input.addEventListener('change', () => this.onChange());
this.hasInfo = Boolean($attrs.info);
this.info = $attrs.info || null;
}
set field(value) {
this._field = value;
@ -35,7 +37,7 @@ export default class Controller extends Input {
this.$.$applyAsync();
}
}
Controller.$inject = ['$element', '$scope', '$injector'];
Controller.$inject = ['$element', '$scope', '$attrs'];
ngModule.component('vnCheck', {
template: require('./check.html'),

View File

@ -1,5 +1,16 @@
@import 'colors';
vn-check {
position: relative;
& > .mdl-checkbox {
width: initial;
}
& > i {
padding-left: 5px;
position: absolute;
bottom: 3px;
color: $secondary-font-color;
font-size: 20px !important
}
}

View File

@ -1,3 +1,5 @@
vn-icon-menu{
vn-icon-menu {
vn-drop-down {
font-family: 'vn-font'
}
}

View File

@ -28,7 +28,7 @@
vn-acl="buyer,replenisher"
pointer
vn-tooltip="Remove barcode"
icon="remove_circle_outline"
icon="delete"
ng-click="model.remove($index)">
</vn-icon>
</vn-none>

View File

@ -23,7 +23,11 @@
item="::item">
</vn-item-product>
<vn-empty-rows class="vn-list-item" style="text-align: center"
ng-if="!model.data || model.data.length === 0" translate>
ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
<vn-empty-rows class="vn-list-item" style="text-align: center"
ng-if="model.data === null" translate>
Enter a new search
</vn-empty-rows>
</vn-card>

View File

@ -37,7 +37,7 @@
vn-acl="buyer,replenisher"
pointer
vn-tooltip="Remove niche"
icon="remove_circle_outline"
icon="delete"
ng-click="model.remove($index)">
</vn-icon>
</vn-none>

View File

@ -67,7 +67,7 @@
medium-grey
margin-medium-v
vn-tooltip="Remove tag"
icon="remove_circle_outline"
icon="delete"
ng-click="filter.tags.splice($index, 1)"
tabindex="-1">
</vn-icon-button>

View File

@ -66,7 +66,7 @@
medium-grey
margin-medium-v
vn-tooltip="Remove tag"
icon="remove_circle_outline"
icon="delete"
ng-click="model.remove($index)"
tabindex="-1">
</vn-icon-button>

View File

@ -32,7 +32,7 @@ class Controller {
let json = encodeURIComponent(JSON.stringify(this.filter));
let query = `/order/api/Orders/${this.$state.params.id}?filter=${json}`;
this.$http.get(query).then(res => {
if (res.data) {
if (res.data && res.data.rows) {
if (res.data.rows.length == 0)
delete res.data.rows;
this.order = res.data;

View File

@ -26,11 +26,11 @@ describe('Order', () => {
it(`should make a query, save the data in order and call get order if the response has data`, () => {
spyOn(controller, 'getTotal');
let json = encodeURIComponent(JSON.stringify(controller.filter));
$httpBackend.expectGET(`/order/api/Orders/${controller.$state.params.id}?filter=${json}`).respond({id: 1});
$httpBackend.expectGET(`/order/api/Orders/${controller.$state.params.id}?filter=${json}`).respond({rows: [1, 2, 3]});
controller.getCard();
$httpBackend.flush();
expect(controller.order).toEqual({id: 1});
expect(controller.order).toEqual({rows: [1, 2, 3]});
expect(controller.getTotal).toHaveBeenCalledWith();
});

View File

@ -6,6 +6,24 @@ class Controller {
this.translate = $translate;
}
set order(value) {
this._order = value;
if (value.isConfirmed) {
this._quicklinks = {
btnOne: {
icon: 'icon-ticket',
state: `ticket.index({q: '{"orderFk": ${value.id}}'})`,
tooltip: 'Order ticket list'
}
};
}
}
get order() {
return this._order;
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this._quicklinks);
}

View File

@ -6,3 +6,4 @@ Landed: F. entrega
Items: Articulos
Agency: Agencia
Sales person: Comercial
Order ticket list: Ticket del pedido

View File

@ -56,7 +56,10 @@
</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="!model.data || model.data.length === 0" translate>
<vn-empty-rows ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
<vn-empty-rows ng-if="model.data === null" translate>
Enter a new search
</vn-empty-rows>
</vn-table>

View File

@ -58,7 +58,7 @@
<vn-icon-button
medium-grey
vn-tooltip="Remove item"
icon="remove_circle_outline"
icon="delete"
ng-click="$ctrl.removeRow($index)"
tabindex="-1">
</vn-icon-button>

View File

@ -1,4 +1,4 @@
$main-font-color :#222222;
$main-font-color:#222222;
$secondary-font-color: #9b9b9b;
$main-header: #3d3d3d;
$hover: rgba(0, 0, 0, 0.1);
@ -10,7 +10,11 @@ $main-01-03: rgba($main-01, 0.3);
$main-02: #a3d131;
$main-02-05: rgba($main-02, 0.5);
$main-02-03: rgba($main-02, 0.3);
$main-03: #32b1ce;
$main-03-05: rgba($main-03, 0.5);
$main-03-03: rgba($main-03, 0.3);
$lines: #9b9b9b;
$alert01: #f42121;
$color-green: #a3d131;
$color-orange: #f7931e;

View File

@ -1,8 +1,12 @@
@import "./colors";
.summary{
h5 {
h5:not(.title) {
padding: 7px;
background-color: $main-01-03;
border-bottom: 2px solid $main-01;
font-family: unset !important;
text-transform: uppercase;
}
.title, p.title {
border: none;

View File

@ -13,6 +13,7 @@
<vn-searchbar
panel="vn-ticket-search-panel"
on-search="model.applyFilter(null, $params);"
filter="$ctrl.filter"
vn-focus>
</vn-searchbar>
</vn-three>
@ -86,7 +87,10 @@
</vn-td>
</a>
</vn-tbody>
<vn-empty-rows ng-if="!model.data || model.data.length === 0" translate>
<vn-empty-rows ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
<vn-empty-rows ng-if="model.data === null" translate>
Enter a new search
</vn-empty-rows>
</vn-table>

View File

@ -9,6 +9,17 @@ export default class Controller {
this.moreOptions = [
{callback: this.goToTurns, name: 'Turns', always: true},
];
let today = new Date();
let offset = today.getTimezoneOffset() * 60000;
today.setHours(0, 0, 0, 0);
today.setTime(today.getTime() - offset);
let tomorrow = new Date(today);
tomorrow.setHours(23, 59, 59, 59);
tomorrow.setTime(tomorrow.getTime() - offset);
this.filter = {myTeam: true, from: today, to: tomorrow};
}
goToTurns() {

View File

@ -1,9 +0,0 @@
Model: Modelo
Action: Acción
Changed by: Cambiado por
Before: Antes
After: Despues
History: Historial
insert: Crear
delete: Eliminar
update: Actualizar

View File

@ -38,7 +38,7 @@
pointer
medium-grey
vn-tooltip="Remove note"
icon="remove_circle_outline"
icon="delete"
ng-click="model.remove($index)">
</vn-icon>
</vn-auto>

View File

@ -43,7 +43,7 @@
pointer
medium-grey
vn-tooltip="Remove package"
icon="remove_circle_outline"
icon="delete"
ng-click="model.remove($index)">
</vn-icon>
</vn-one>

View File

@ -78,9 +78,16 @@
field="filter.stateFk"
url="/api/States">
</vn-autocomplete>
<vn-textfield
vn-one
label="Order id"
model="filter.orderFk">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-check
vn-one
label="My tickets"
label="My team"
field="filter.myTeam">
</vn-check>
</vn-horizontal>

View File

@ -8,4 +8,4 @@ Warehouse: Almacén
Sales person: Comercial
Province: Provincia
My team: Mi equipo
My tickets: Mis tickets
Order id: Id pedido

View File

@ -52,55 +52,156 @@
</vn-one>
</vn-horizontal>
<vn-horizontal>
<table class="vn-grid">
<thead>
<tr>
<th></th>
<th number translate>Item</th>
<th translate>Description</th>
<th number translate>Quantity</th>
<th number translate>Price</th>
<th number translate>Discount</th>
<th number translate>Amount</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="sale in $ctrl.summary.sales track by sale.id">
<td>
<a ui-sref="claim.card.basicData({id: sale.claimBeginning.claimFk})">
<vn-one margin-medium-v>
<h5 translate>Sale</h5>
<table class="vn-grid">
<thead>
<tr>
<th></th>
<th number translate>Item</th>
<th translate>Description</th>
<th number translate>Quantity</th>
<th number translate>Price</th>
<th number translate>Discount</th>
<th number translate>Amount</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="sale in $ctrl.summary.sales track by sale.id">
<td>
<a ui-sref="claim.card.basicData({id: sale.claimBeginning.claimFk})">
<vn-icon
ng-show="sale.claimBeginning.claimFk"
orange
icon="icon-claims"
vn-tooltip="{{::$ctrl.$translate.instant('Claim')}}: {{::sale.claimBeginning.claimFk}}">
</vn-icon>
</a>
<vn-icon
ng-show="sale.claimBeginning.claimFk"
ng-show="sale.visible || sale.available"
orange
icon="icon-claims"
vn-tooltip="{{::$ctrl.$translate.instant('Claim')}}: {{::sale.claimBeginning.claimFk}}">
icon="warning"
vn-tooltip="Visible: {{::sale.visible || 0}} <br> {{::$ctrl.translate.instant('Available')}} {{::sale.available || 0}}">
</vn-icon>
</a>
<vn-icon
ng-show="sale.visible || sale.available"
orange
icon="warning"
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 number>
<span
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
class="link" pointer>
{{("000000"+sale.itemFk).slice(-6)}}
</span>
</td>
<td><vn-fetched-tags max-length="6" item="sale.item"/></td>
<td number>{{::sale.quantity}}</td>
<td number>{{::sale.price | currency:'€':2}}</td>
<td number>{{::sale.discount}} %</td>
<td number>{{::sale.quantity * sale.price | currency:'€':2}}</td>
</tr>
<tr ng-if="!$ctrl.summary.sales" class="list list-element">
<td colspan="8" style="text-align: center" translate>No results</td>
</tr>
</tbody>
</table>
<vn-icon ng-show="sale.reserved" icon="icon-reserva"></vn-icon>
</td>
<td number>
<span
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
class="link" pointer>
{{("000000"+sale.itemFk).slice(-6)}}
</span>
</td>
<td><vn-fetched-tags max-length="6" item="sale.item"/></td>
<td number>{{::sale.quantity}}</td>
<td number>{{::sale.price | currency:'€':2}}</td>
<td number>{{::sale.discount}} %</td>
<td number>{{::sale.quantity * sale.price | currency:'€':2}}</td>
</tr>
<tr ng-if="!$ctrl.summary.sales" class="list list-element">
<td colspan="8" style="text-align: center" translate>No results</td>
</tr>
</tbody>
</table>
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one margin-medium-v ng-if="$ctrl.summary.packagings.length != 0">
<h5 translate>Packages</h5>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th number>Created</vn-th>
<vn-th number>Package</vn-th>
<vn-th number>Quantity</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="package in $ctrl.summary.packagings">
<vn-td number>{{package.created | dateTime: 'dd/MM/yyyy'}}</vn-td>
<vn-td number>{{package.packaging.item.name}}</vn-td>
<vn-td number>{{package.quantity}}</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-one margin-medium ng-if="$ctrl.summary.services.length != 0">
<h5 translate>Service</h5>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th number>Id</vn-th>
<vn-th>Description</vn-th>
<vn-th number>Quantity</vn-th>
<vn-th number>Price</vn-th>
<vn-th>Tax class</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="service in $ctrl.summary.services">
<vn-td number>{{::service.id}}</vn-td>
<vn-td>{{::service.description}}</vn-td>
<vn-td number>{{::service.quantity}}</vn-td>
<vn-td number>{{::service.price}}</vn-td>
<vn-td>{{::service.taxClass.description}}</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="$ctrl.summary.services.length === 0" translate>
No results
</vn-empty-rows>
</vn-table>
</vn-one>
</vn-horizontal>
<vn-horizontal ng-if="$ctrl.summary.requests.length != 0">
<vn-one margin-medium-v>
<h5 translate>Purchase request</h5>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th number>Id</vn-th>
<vn-th>Description</vn-th>
<vn-th number>Created</vn-th>
<vn-th>Requester</vn-th>
<vn-th>Atender</vn-th>
<vn-th number>Quantity</vn-th>
<vn-th number>Price</vn-th>
<vn-th number>Sale id</vn-th>
<vn-th number>Ok</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="request in $ctrl.summary.requests">
<vn-td number>{{::request.id}}</vn-td>
<vn-td>{{::request.description}}</vn-td>
<vn-td number>{{::request.created | dateTime: 'dd/MM/yyyy'}}</vn-td>
<vn-td>{{::request.requester.firstName}} {{::request.requester.name}}</vn-td>
<vn-td>{{::request.atender.firstName}} {{::request.atender.name}}</vn-td>
<vn-td number>{{::request.quantity}}</vn-td>
<vn-td number>{{::request.price}}</vn-td>
<vn-td number>
<span
ng-show="::request.saleFk"
ng-click="$ctrl.showDescriptor($event, request.sale)"
pointer class="link">
{{("000000"+request.saleFk).slice(-6)}}
</span>
</vn-td>
<vn-td number>
<vn-check vn-one
field="::request.isOk"
disabled="true">
</vn-check>
</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="$ctrl.summary.requests.length === 0" translate>
No results
</vn-empty-rows>
</vn-table>
</vn-one>
</vn-horizontal>
</vn-vertical>
</vn-card>

View File

@ -230,7 +230,7 @@ export default {
itemTags: {
goToItemIndexButton: 'vn-item-descriptor [ui-sref="item.index"]',
tagsButton: `vn-left-menu a[ui-sref="item.card.tags"]`,
firstRemoveTagButton: `vn-item-tags vn-horizontal:nth-child(2) vn-icon-button[icon="remove_circle_outline"]`,
firstRemoveTagButton: `vn-item-tags vn-horizontal:nth-child(2) vn-icon-button[icon="delete"]`,
firstTagSelect: `vn-item-tags vn-horizontal:nth-child(2) > vn-autocomplete[field="itemTag.tagFk"] input`,
firstTagSelectOptionOne: `vn-item-tags vn-horizontal:nth-child(2) > vn-autocomplete[field="itemTag.tagFk"] vn-drop-down ul > li:nth-child(1)`,
firstValueInput: `vn-item-tags vn-horizontal:nth-child(2) > vn-textfield[label="Value"] input`,
@ -272,7 +272,7 @@ export default {
addBarcodeButton: `vn-icon[icon="add_circle"]`,
thirdCodeInput: `vn-item-barcode vn-horizontal:nth-child(4) > ${components.vnTextfield}`,
submitBarcodesButton: `${components.vnSubmit}`,
firstCodeRemoveButton: `vn-item-barcode vn-horizontal vn-none vn-icon[icon="remove_circle_outline"]`
firstCodeRemoveButton: `vn-item-barcode vn-horizontal vn-none vn-icon[icon="delete"]`
},
itemNiches: {
nicheButton: `vn-left-menu a[ui-sref="item.card.niche"]`,
@ -282,7 +282,7 @@ export default {
firstCodeInput: `vn-horizontal:nth-child(2) > vn-textfield[label="Code"] input`,
secondWarehouseSelect: `vn-horizontal:nth-child(3) > vn-autocomplete[field="niche.warehouseFk"] input`,
secondCodeInput: `vn-horizontal:nth-child(3) > vn-textfield[label="Code"] input`,
secondNicheRemoveButton: `vn-horizontal:nth-child(3) > vn-none > vn-icon[icon="remove_circle_outline"]`,
secondNicheRemoveButton: `vn-horizontal:nth-child(3) > vn-none > vn-icon[icon="delete"]`,
thirdWarehouseSelect: `vn-horizontal:nth-child(4) > vn-autocomplete[field="niche.warehouseFk"] input`,
thirdWarehouseSelectFourthOption: `vn-horizontal:nth-child(4) > vn-autocomplete[field="niche.warehouseFk"] vn-drop-down ul > li:nth-child(4)`,
thirdCodeInput: `vn-horizontal:nth-child(4) > vn-textfield[label="Code"] input`,
@ -343,7 +343,7 @@ export default {
},
ticketNotes: {
notesButton: `vn-left-menu a[ui-sref="ticket.card.observation"]`,
firstNoteRemoveButton: `vn-icon[icon="remove_circle_outline"]`,
firstNoteRemoveButton: `vn-icon[icon="delete"]`,
addNoteButton: `vn-icon[icon="add_circle"]`,
firstNoteSelect: `vn-autocomplete[field="observation.observationTypeFk"] input`,
firstNoteSelectSecondOption: `vn-autocomplete[field="observation.observationTypeFk"] vn-drop-down ul > li:nth-child(2)`,

View File

@ -81,3 +81,4 @@ INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`
INSERT INTO `salix`.`fieldAcl` (`model`, `property`, `actionType`, `role`) VALUES ('TicketWeekly', '*', '*', 'employee');
INSERT INTO `salix`.`fieldAcl` (`model`, `property`, `actionType`, `role`) VALUES ('Receipt', '*', '*', 'administrative');
INSERT INTO salix.fieldAcl (model,property,actionType,`role`) VALUES ('Zone','*','*','agency');

View File

@ -252,7 +252,6 @@ INSERT INTO `vn`.`clientCredit`(`id`, `clientFk`, `workerFk`, `amount`, `created
(10, 101, 9, 100, DATE_ADD(CURDATE(), INTERVAL -10 MONTH)),
(11, 101, 9, 50 , DATE_ADD(CURDATE(), INTERVAL -11 MONTH)),
(12, 102, 9, 800, CURDATE()),
(13, 103, 9, 200, CURDATE()),
(14, 104, 9, 90 , CURDATE()),
(15, 105, 9, 90 , CURDATE());
@ -1014,7 +1013,7 @@ INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `amountUnpaid`, `pay
(1, 'Cobro web', 100.50, 0.00, CURDATE(), 9, 1, 101, CURDATE(), 442, 1),
(2, 'Cobro web', 200.50, 0.00, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 9, 1, 101, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 442, 1),
(3, 'Cobro en efectivo', 300.00, 100.00, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 9, 1, 102, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 442, 0),
(4, 'Cobro en efectivo', 400.00, -50.00, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 9, 1, 103, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 442, 0);
(4, 'Cobro en efectivo', -400.00, -50.00, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 9, 1, 103, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 442, 0);
INSERT INTO `vn2008`.`workerTeam`(`id`, `team`, `user`)
VALUES

View File

@ -37,7 +37,11 @@ module.exports = Self => {
case 'role':
return {'r.name': value};
case 'firstName':
return {or: [{'w.firstName': {like: `%${value}%`}}, {'w.name': {like: `%${value}%`}}]};
return {or: [
{'w.firstName': {like: `%${value}%`}},
{'w.name': {like: `%${value}%`}},
{'u.name': {like: `%${value}%`}}
]};
case 'id':
return {'w.id': value};
}

View File

@ -46,7 +46,10 @@ describe('order new()', () => {
it('should throw an error if the client isnt frozen and is active, has data checked but has a debt', async () => {
let error;
let params = {addressFk: 123};
let params = {
addressFk: 123,
landed: new Date()
};
await app.models.Order.new(params)
.catch(e => {

View File

@ -63,6 +63,10 @@ module.exports = Self => {
arg: 'myTeam',
type: 'Boolean',
description: `Whether to show only tickets for the current logged user team (For now it shows only the current user tickets)`
}, {
arg: 'orderFk',
type: 'Number',
description: `The order id filter`
}
],
returns: {
@ -79,10 +83,16 @@ module.exports = Self => {
let conn = Self.dataSource.connector;
let worker = await Self.app.models.Worker.findOne({
fields: ['id'],
where: {userFk: ctx.req.accessToken.userId}
where: {userFk: ctx.req.accessToken.userId},
include: [
{relation: 'collegues'}
]
});
let teamIds = [];
worker.collegues().forEach(collegue => {
teamIds.push(collegue.collegueFk);
});
let teamIds = [worker && worker.id];
let where = buildFilter(ctx.args, (param, value) => {
switch (param) {
@ -102,6 +112,8 @@ module.exports = Self => {
return {'a.provinceFk': value};
case 'stateFk':
return {'ts.stateFk': value};
case 'orderFk':
return {'ot.orderFk': value};
case 'myTeam':
return {'c.salesPersonFk': {inq: teamIds}};
case 'id':
@ -136,7 +148,8 @@ module.exports = Self => {
w.name AS warehouse,
am.name AS agencyMode,
st.name AS state,
wk.name AS salesPerson
wk.name AS salesPerson,
ot.orderFk AS orderFk
FROM ticket t
LEFT JOIN address a ON a.id = t.addressFk
LEFT JOIN province p ON p.id = a.provinceFk
@ -145,8 +158,11 @@ module.exports = Self => {
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
LEFT JOIN state st ON st.id = ts.stateFk
LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk`);
stmt.merge(conn.makeSuffix(filter));
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
LEFT JOIN orderTicket ot ON ot.ticketFk = t.id`);
stmt.merge(conn.makeWhere(filter.where));
stmt.merge('GROUP BY t.id');
stmt.merge(conn.makePagination(filter));
stmts.push(stmt);
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.ticketGetProblems');

View File

@ -26,6 +26,22 @@ module.exports = Self => {
summaryObj.subTotal = getSubTotal(summaryObj.sales);
summaryObj.VAT = await models.Ticket.getVAT(ticketFk);
summaryObj.total = await models.Ticket.getTotal(ticketFk);
summaryObj.packagings = await models.TicketPackaging.find({
where: {ticketFk: ticketFk},
include: [{relation: 'packaging',
scope: {
fields: ['itemFk', 'name'],
include: {
relation: 'item'
}
}
}]
});
summaryObj.requests = await getRequests(Self, ticketFk);
summaryObj.services = await models.TicketService.find({
where: {ticketFk: ticketFk},
include: [{relation: 'taxClass'}]
});
return summaryObj;
};
@ -98,6 +114,19 @@ module.exports = Self => {
return await Sale.find(filter);
}
async function getRequests(Self, ticketFk) {
let filter = {
where: {
ticketFk: ticketFk
},
include: [
{relation: 'requester'},
{relation: 'atender'}
]
};
return await Self.app.models.TicketRequest.find(filter);
}
function getSubTotal(sales) {
let subTotal = 0.00;

View File

@ -0,0 +1,26 @@
{
"name": "WorkerTeamCollegues",
"base": "VnModel",
"options": {
"mysql": {
"table": "workerTeamCollegues"
}
},
"properties": {
"workerFk": {
"id": true,
"type": "Number"
},
"collegueFk": {
"id": true,
"type": "Number"
}
},
"relations": {
"worker": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
}
}
}

View File

@ -31,6 +31,11 @@
"type": "belongsTo",
"model": "Account",
"foreignKey": "userFk"
},
"collegues": {
"type": "hasMany",
"model": "WorkerTeamCollegues",
"foreignKey": "workerFk"
}
}
}

View File

@ -165,6 +165,9 @@
"WorkerTeam": {
"dataSource": "vn"
},
"WorkerTeamCollegues": {
"dataSource": "vn"
},
"TicketRequest": {
"dataSource": "vn"
},