Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 3682-item_fixed-price

This commit is contained in:
Alex Moreno 2022-03-23 12:25:01 +01:00
commit 193f97aa41
13 changed files with 180 additions and 103 deletions

View File

@ -40,7 +40,8 @@ module.exports = Self => {
IFNULL(sc.workerSubstitute, c.salesPersonFk) AS salesPersonFk,
c.id AS clientFk,
c.name AS clientName,
s.lastUpdate AS dated,
TIME(v.stamp) AS hour,
DATE(v.stamp) AS dated,
wtc.workerFk
FROM hedera.userSession s
JOIN hedera.visitUser v ON v.id = s.userVisitFk

View File

@ -2,7 +2,8 @@
vn-id="model"
url="SalesMonitors/clientsFilter"
limit="6"
order="dated DESC"
filter="$ctrl.filter"
order="dated DESC, hour DESC"
auto-load="true">
</vn-crud-model>
<vn-horizontal class="header">
@ -15,87 +16,85 @@
vn-tooltip="Minimize/Maximize"
ng-click="$ctrl.main.toggle()">
</vn-icon>
<vn-icon
icon="refresh"
vn-tooltip="Refresh"
ng-click="model.refresh()">
</vn-icon>
</vn-none>
</vn-horizontal>
<vn-card vn-id="card">
<vn-table model="model" class="scrollable sm">
<vn-thead>
<vn-tr>
<vn-th field="dated">Hour</vn-th>
<vn-th field="salesPersonFk" class="expendable">Salesperson</vn-th>
<vn-th field="clientFk">Client</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="visit in model.data">
<vn-td shrink-date>
<span class="chip">
{{::visit.dated | date: 'HH:mm'}}
</span>
</vn-td>
<vn-td class="shrink expendable">
<span
title="{{::visit.salesPerson}}"
vn-click-stop="workerDescriptor.show($event, visit.salesPersonFk)"
class="link">
{{::visit.salesPerson | dashIfEmpty}}
</span>
</vn-td>
<vn-td>
<span
title="{{::visit.clientName}}"
vn-click-stop="clientDescriptor.show($event, visit.clientFk)"
class="link">
{{::visit.clientName}}
</span>
</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
<vn-pagination
model="model"
class="vn-pt-xs"
scroll-selector="vn-monitor-sales-clients vn-table"
scroll-offset="100">
</vn-pagination>
<smart-table
model="model"
options="$ctrl.smartTableOptions"
expr-builder="$ctrl.exprBuilder(param, value)"
class="scrollable sm">
<slot-actions>
<vn-horizontal>
<vn-date-picker
class="vn-pa-xs"
label="From"
ng-model="$ctrl.dateFrom"
on-change="$ctrl.addFilterDate()">
</vn-date-picker>
<vn-date-picker
class="vn-pa-xs"
label="To"
ng-model="$ctrl.dateTo"
on-change="$ctrl.addFilterDate()">
</vn-date-picker>
</vn-horizontal>
</slot-actions>
<slot-table>
<table>
<thead>
<tr>
<th field="dated">
<span translate>Date</span>
</th>
<th field="hour">
<span translate>Hour</span>
</th>
<th field="salesPersonFk" class="expendable">
<span translate>Salesperson</span>
</th>
<th field="clientFk">
<span translate>Client</span>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="visit in model.data">
<td shrink-date>
<span class="chip">
{{::visit.dated | date:'dd/MM/yy'}}
</span>
</td>
<td shrink-date>
<span class="chip">
{{::visit.hour | date: 'HH:mm'}}
</span>
</td>
<td class="shrink expendable">
<span
title="{{::visit.salesPerson}}"
vn-click-stop="workerDescriptor.show($event, visit.salesPersonFk)"
class="link">
{{::visit.salesPerson | dashIfEmpty}}
</span>
</td>
<td>
<span
title="{{::visit.clientName}}"
vn-click-stop="clientDescriptor.show($event, visit.clientFk)"
class="link">
{{::visit.clientName}}
</span>
</td>
</tr>
</tbody>
<table>
<slot-table>
</smart-table>
</vn-card>
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
<vn-client-descriptor-popover
vn-id="clientDescriptor">
</vn-client-descriptor-popover>
<vn-contextmenu vn-id="contextmenu" targets="['vn-monitor-sales-clients vn-table']" model="model"
expr-builder="$ctrl.exprBuilder(param, value)">
<slot-menu>
<vn-item translate
ng-if="contextmenu.isFilterAllowed()"
ng-click="contextmenu.filterBySelection()">
Filter by selection
</vn-item>
<vn-item translate
ng-if="contextmenu.isFilterAllowed()"
ng-click="contextmenu.excludeSelection()">
Exclude selection
</vn-item>
<vn-item translate
ng-if="contextmenu.isFilterAllowed()"
ng-click="contextmenu.removeFilter()">
Remove filter
</vn-item>
<vn-item translate
ng-click="contextmenu.removeAllFilters()">
Remove all filters
</vn-item>
<vn-item translate
ng-if="contextmenu.isActionAllowed()"
ng-click="contextmenu.copyValue()">
Copy value
</vn-item>
</slot-menu>
</vn-contextmenu>
</vn-client-descriptor-popover>

View File

@ -2,26 +2,89 @@ import ngModule from '../../module';
import Section from 'salix/components/section';
export default class Controller extends Section {
constructor($element, $) {
super($element, $);
const date = new Date();
this.dateFrom = date;
this.dateTo = date;
this.filter = {
where: {
'v.stamp': {
between: this.dateRange()
}
}
};
this.smartTableOptions = {
activeButtons: {
search: true
},
columns: [
{
field: 'clientFk',
autocomplete: {
url: 'Clients',
showField: 'name',
valueField: 'id'
}
},
{
field: 'salesPersonFk',
autocomplete: {
url: 'Workers/activeWithInheritedRole',
where: `{role: 'salesPerson'}`,
searchFunction: '{firstName: $search}',
showField: 'nickname',
valueField: 'id',
}
},
{
field: 'dated',
searchable: false
},
{
field: 'hour',
searchable: false
}
]
};
}
exprBuilder(param, value) {
switch (param) {
case 'dated':
return {'s.lastUpdate': {
between: this.dateRange(value)}
};
case 'clientFk':
return {[`c.id`]: value};
case 'salesPersonFk':
return {[`c.${param}`]: value};
}
}
dateRange(value) {
const minHour = new Date(value);
dateRange() {
let from = this.dateFrom;
let to = this.dateTo;
if (!from)
from = new Date();
if (!to)
to = new Date();
const minHour = new Date(from);
minHour.setHours(0, 0, 0, 0);
const maxHour = new Date(value);
const maxHour = new Date(to);
maxHour.setHours(23, 59, 59, 59);
return [minHour, maxHour];
}
addFilterDate() {
this.$.model.filter = {
where: {
'v.stamp': {
between: this.dateRange()
}
}
};
this.$.model.refresh();
}
}
ngModule.vnComponent('vnMonitorSalesClients', {

View File

@ -21,7 +21,7 @@
<vn-list>
<vn-item
ng-if="!$ctrl.hasDocuwareFile"
ng-click="$ctrl.showPdfDeliveryNote()"
ng-click="$ctrl.showPdfDeliveryNote('deliveryNote')"
translate>
as PDF
</vn-item>
@ -44,7 +44,6 @@
vn-click-stop="sendDeliveryNoteMenu.show($event, 'left')"
translate>
Send Delivery Note...
<vn-menu vn-id="sendDeliveryNoteMenu">
<vn-list>
<vn-item
@ -60,6 +59,11 @@
</vn-list>
</vn-menu>
</vn-item>
<vn-item
ng-click="$ctrl.showPdfDeliveryNote('proforma')"
translate>
Show Proforma
</vn-item>
<vn-item
ng-click="deleteConfirmation.show()"
ng-show="$ctrl.isEditable"

View File

@ -116,10 +116,11 @@ class Controller extends Section {
});
}
showPdfDeliveryNote() {
showPdfDeliveryNote(type) {
this.vnReport.show('delivery-note', {
recipientId: this.ticket.client.id,
ticketId: this.id,
type: type
});
}

View File

@ -122,14 +122,15 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
describe('showPdfDeliveryNote()', () => {
it('should open a new window showing a delivery note PDF document', () => {
jest.spyOn(window, 'open').mockReturnThis();
const type = 'deliveryNote';
const expectedParams = {
ticketId: ticket.id,
recipientId: ticket.client.id
recipientId: ticket.client.id,
type: type
};
const serializedParams = $httpParamSerializer(expectedParams);
const expectedPath = `api/report/delivery-note?${serializedParams}`;
controller.showPdfDeliveryNote();
controller.showPdfDeliveryNote(type);
expect(window.open).toHaveBeenCalledWith(expectedPath);
});

View File

@ -5,4 +5,5 @@ as CSV: como CSV
Send PDF: Enviar PDF
Send CSV: Enviar CSV
Send CSV Delivery Note: Enviar albarán en CSV
Send PDF Delivery Note: Enviar albarán en PDF
Send PDF Delivery Note: Enviar albarán en PDF
Show Proforma: Ver proforma

View File

@ -15,7 +15,7 @@
<div class="columns">
<div class="size50">
<div class="size75 vn-mt-ml">
<h1 class="title uppercase">{{$t('title')}}</h1>
<h1 class="title uppercase">{{$t(type)}}</h1>
<table class="row-oriented ticket-info">
<tbody>
<tr>
@ -23,7 +23,7 @@
<th>{{client.id}}</th>
</tr>
<tr>
<td class="font gray uppercase">{{$t('ticketId')}}</td>
<td class="font gray uppercase">{{$t(type)}}</td>
<th>{{ticket.id}}</th>
</tr>
<tr>
@ -281,7 +281,7 @@
<!-- Footer block -->
<report-footer id="pageFooter"
v-bind:company-code="ticket.companyCode"
v-bind:left-text="$t('ticket', [ticket.id])"
v-bind:left-text="footerType"
v-bind:center-text="client.socialName"
v-bind="$props">
</report-footer>

View File

@ -44,6 +44,10 @@ module.exports = {
});
return total;
},
footerType() {
const translatedType = this.$t(this.type);
return `${translatedType} ${this.ticketId}`;
}
},
methods: {
@ -119,6 +123,10 @@ module.exports = {
ticketId: {
type: [Number, String],
required: true
},
type: {
type: String,
required: true
}
}
};

View File

@ -1,6 +1,6 @@
reportName: delivery-note
title: Delivery note
ticketId: Delivery note
deliveryNote: Delivery note
proforma: Proforma
clientId: Client
deliveryAddress: Delivery address
fiscalData: Fiscal data
@ -17,7 +17,6 @@ total: Total
subtotal: Subtotal
vatType: VAT Type
digitalSignature: Digital signature
ticket: Delivery note {0}
plantPassport: Plant passport
packages: Packages
services:

View File

@ -1,6 +1,6 @@
reportName: albaran
title: Albarán
ticketId: Albarán
deliveryNote: Albarán
proforma: Proforma
clientId: Cliente
deliveryAddress: Dirección de entrega
fiscalData: Datos fiscales

View File

@ -1,6 +1,6 @@
reportName: bon-de-livraison
title: Bon de livraison
ticketId: BL
deliveryNote: Bon de livraison
proforma: Proforma
clientId: Client
deliveryAddress: Adresse de livraison
fiscalData: Coordonnées

View File

@ -1,6 +1,6 @@
reportName: nota-de-entrega
title: Nota de Entrega
ticketId: Nota de Entrega
deliveryNote: Nota de Entrega
proforma: Proforma
clientId: Cliente
deliveryAddress: Morada de Entrega
fiscalData: Dados Fiscais