Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2400-entry_summary_buys
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
46b67308fa
|
@ -0,0 +1,119 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `ticket_close`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `ticket_close`(vTicketFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Realiza el cierre de todos los
|
||||
* tickets de la tabla ticketClosure.
|
||||
*
|
||||
* @param vTicketFk Id del ticket
|
||||
*/
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vClientFk INT;
|
||||
DECLARE vCurTicketFk INT;
|
||||
DECLARE vIsTaxDataChecked BOOL;
|
||||
DECLARE vCompanyFk INT;
|
||||
DECLARE vShipped DATE;
|
||||
DECLARE vNewInvoiceId INT;
|
||||
DECLARE vHasDailyInvoice BOOL;
|
||||
DECLARE vWithPackage BOOL;
|
||||
DECLARE vHasToInvoice BOOL;
|
||||
|
||||
DECLARE cur CURSOR FOR
|
||||
SELECT ticketFk FROM tmp.ticketClosure;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure;
|
||||
CREATE TEMPORARY TABLE tmp.ticketClosure
|
||||
SELECT vTicketFk AS ticketFk;
|
||||
|
||||
INSERT INTO tmp.ticketClosure
|
||||
SELECT id FROM stowaway s
|
||||
WHERE s.shipFk = vTicketFk;
|
||||
OPEN cur;
|
||||
|
||||
proc: LOOP
|
||||
SET vDone = FALSE;
|
||||
|
||||
FETCH cur INTO vCurTicketFk;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
-- ticketClosure start
|
||||
SELECT
|
||||
c.id,
|
||||
c.isTaxDataChecked,
|
||||
t.companyFk,
|
||||
t.shipped,
|
||||
co.hasDailyInvoice,
|
||||
w.isManaged,
|
||||
c.hasToInvoice
|
||||
INTO vClientFk,
|
||||
vIsTaxDataChecked,
|
||||
vCompanyFk,
|
||||
vShipped,
|
||||
vHasDailyInvoice,
|
||||
vWithPackage,
|
||||
vHasToInvoice
|
||||
FROM ticket t
|
||||
JOIN `client` c ON c.id = t.clientFk
|
||||
JOIN province p ON p.id = c.provinceFk
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
JOIN warehouse w ON w.id = t.warehouseFk
|
||||
WHERE t.id = vCurTicketFk;
|
||||
|
||||
INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity)
|
||||
(SELECT vCurTicketFk, p.id, COUNT(*)
|
||||
FROM expedition e
|
||||
JOIN packaging p ON p.itemFk = e.itemFk
|
||||
WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable
|
||||
AND vWithPackage
|
||||
GROUP BY p.itemFk);
|
||||
|
||||
-- No retornables o no catalogados
|
||||
INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed)
|
||||
(SELECT e.itemFk, vCurTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.itemFk, vClientFk), 1
|
||||
FROM expedition e
|
||||
JOIN item i ON i.id = e.itemFk
|
||||
LEFT JOIN packaging p ON p.itemFk = i.id
|
||||
WHERE e.ticketFk = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0
|
||||
AND getSpecialPrice(e.itemFk, vClientFk) > 0
|
||||
GROUP BY e.itemFk);
|
||||
|
||||
CALL vn.zonePromo_Make();
|
||||
|
||||
IF(vHasDailyInvoice) AND vHasToInvoice THEN
|
||||
|
||||
-- Facturacion rapida
|
||||
CALL ticketTrackingAdd(vCurTicketFk, 'DELIVERED', NULL);
|
||||
-- Facturar si está contabilizado
|
||||
IF vIsTaxDataChecked THEN
|
||||
CALL invoiceOut_newFromClient(
|
||||
vClientFk,
|
||||
(SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')),
|
||||
vShipped,
|
||||
vCompanyFk,
|
||||
NULL,
|
||||
vNewInvoiceId);
|
||||
END IF;
|
||||
ELSE
|
||||
CALL ticketTrackingAdd(vCurTicketFk, (SELECT vn.getAlert3State(vCurTicketFk)), NULL);
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
CLOSE cur;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -199,7 +199,7 @@ export default {
|
|||
},
|
||||
dms: {
|
||||
deleteFileButton: 'vn-client-dms-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
|
||||
firstDocWorker: 'vn-client-dms-index vn-td:nth-child(7) > span',
|
||||
firstDocWorker: 'vn-client-dms-index vn-td:nth-child(8) > span',
|
||||
firstDocWorkerDescriptor: '.vn-popover.shown vn-worker-descriptor'
|
||||
},
|
||||
clientContacts: {
|
||||
|
@ -909,5 +909,12 @@ export default {
|
|||
newValueInput: 'vn-textfield[ng-model="$ctrl.editedColumn.newValue"]',
|
||||
latestBuysSectionButton: 'a[ui-sref="entry.latestBuys"]',
|
||||
acceptEditBuysDialog: 'button[response="accept"]'
|
||||
},
|
||||
entryIndex: {
|
||||
createEntryButton: 'vn-entry-index vn-button[icon="add"]',
|
||||
newEntrySupplier: 'vn-entry-create vn-autocomplete[ng-model="$ctrl.entry.supplierFk"]',
|
||||
newEntryTravel: 'vn-entry-create vn-autocomplete[ng-model="$ctrl.entry.travelFk"]',
|
||||
newEntryCompany: 'vn-entry-create vn-autocomplete[ng-model="$ctrl.entry.companyFk"]',
|
||||
saveNewEntry: 'vn-entry-create button[type="submit"]'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Entry create path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('buyer', 'entry');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should click the create entry button to open the form', async() => {
|
||||
await page.waitToClick(selectors.entryIndex.createEntryButton);
|
||||
await page.waitForState('entry.create');
|
||||
});
|
||||
|
||||
it('should fill the form to create a valid entry', async() => {
|
||||
await page.autocompleteSearch(selectors.entryIndex.newEntrySupplier, '2');
|
||||
await page.autocompleteSearch(selectors.entryIndex.newEntryTravel, 'Warehouse Three');
|
||||
await page.autocompleteSearch(selectors.entryIndex.newEntryCompany, 'ORN');
|
||||
await page.waitToClick(selectors.entryIndex.saveNewEntry);
|
||||
});
|
||||
|
||||
it('should be redirected to entry basic data', async() => {
|
||||
await page.waitForState('entry.card.basicData');
|
||||
});
|
||||
});
|
|
@ -106,7 +106,7 @@ module.exports = Self => {
|
|||
let stmt;
|
||||
|
||||
stmt = new ParameterizedSQL(
|
||||
`SELECT cl.id, c.name, cl.clientFk, cl.workerFk, u.nickName, cs.description, cl.created
|
||||
`SELECT cl.id, c.name, cl.clientFk, cl.workerFk, u.name AS userName, cs.description, cl.created
|
||||
FROM claim cl
|
||||
LEFT JOIN client c ON c.id = cl.clientFk
|
||||
LEFT JOIN worker w ON w.id = cl.workerFk
|
||||
|
|
|
@ -12,7 +12,7 @@ class Controller extends ModuleCard {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,20 +32,32 @@
|
|||
value="{{$ctrl.claim.created | date: 'dd/MM/yyyy HH:mm'}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Salesperson"
|
||||
value="{{$ctrl.claim.client.salesPersonUser.nickname}}">
|
||||
label="Salesperson">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.claim.client.salesPersonFk)"
|
||||
class="link">
|
||||
{{$ctrl.claim.client.salesPersonUser.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Attended by"
|
||||
value="{{$ctrl.claim.worker.user.nickname}}">
|
||||
label="Attended by">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.claim.worker.userFk)"
|
||||
class="link">
|
||||
{{$ctrl.claim.worker.user.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Agency"
|
||||
value="{{$ctrl.claim.ticket.agencyMode.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Ticket"
|
||||
value="{{$ctrl.claim.ticketFk}}">
|
||||
label="Ticket">
|
||||
<span
|
||||
ng-click="ticketDescriptor.show($event, $ctrl.claim.ticketFk)"
|
||||
class="link">
|
||||
{{$ctrl.claim.ticketFk}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
</div>
|
||||
<div class="quicklinks">
|
||||
|
@ -78,4 +90,10 @@
|
|||
on-accept="$ctrl.deleteClaim()"
|
||||
question="Delete claim"
|
||||
message="Are you sure you want to delete this claim?">
|
||||
</vn-confirm>
|
||||
</vn-confirm>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<vn-ticket-descriptor-popover
|
||||
vn-id="ticketDescriptor">
|
||||
</vn-ticket-descriptor-popover>
|
|
@ -34,7 +34,7 @@
|
|||
<span
|
||||
vn-click-stop="workerDescriptor.show($event, claim.workerFk)"
|
||||
class="link" >
|
||||
{{::claim.nickName}}
|
||||
{{::claim.userName}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>
|
||||
|
|
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,13 @@
|
|||
<vn-tbody>
|
||||
<vn-tr ng-repeat="credit in credits track by credit.id">
|
||||
<vn-td>{{::credit.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
<vn-td>{{::credit.worker.user.nickname}}</vn-td>
|
||||
<vn-td>
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, credit.worker.userFk)"
|
||||
class="link">
|
||||
{{::credit.worker.user.name}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number>{{::credit.amount | currency:'EUR':2}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
|
@ -39,3 +45,6 @@
|
|||
vn-bind="+"
|
||||
fixed-bottom-right>
|
||||
</vn-float-button>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
|
@ -13,7 +13,7 @@ class Controller extends Section {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,12 @@
|
|||
info="Invoices minus payments plus orders not yet invoiced">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Sales person"
|
||||
value="{{$ctrl.client.salesPerson.user.nickname}}">
|
||||
label="Sales person">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.client.salesPersonFk)"
|
||||
class="link">
|
||||
{{$ctrl.client.salesPerson.user.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
</div>
|
||||
<div class="icons">
|
||||
|
@ -89,4 +93,7 @@
|
|||
<vn-client-sms
|
||||
vn-id="sms"
|
||||
sms="$ctrl.newSMS">
|
||||
</vn-client-sms>
|
||||
</vn-client-sms>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
|
@ -53,6 +53,12 @@
|
|||
{{::document.dms.description}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td shrink>
|
||||
<vn-check
|
||||
ng-model="document.dms.hasFile"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td shrink>
|
||||
<span title="{{'Download file' | translate}}" class="link"
|
||||
ng-click="$ctrl.downloadFile(document.dmsFk)">
|
||||
|
@ -62,7 +68,7 @@
|
|||
<vn-td shrink>
|
||||
<span class="link"
|
||||
ng-click="workerDescriptor.show($event, document.dms.workerFk)">
|
||||
{{::document.dms.worker.user.nickname | dashIfEmpty}}
|
||||
{{::document.dms.worker.user.name | dashIfEmpty}}
|
||||
</span></vn-td>
|
||||
<vn-td>
|
||||
{{::document.dms.created | date:'dd/MM/yyyy HH:mm'}}
|
||||
|
|
|
@ -32,7 +32,7 @@ class Controller extends Section {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<span
|
||||
ng-click="workerDescriptor.show($event, sample.worker.id)"
|
||||
class="link">
|
||||
{{::sample.worker.user.nickname}}
|
||||
{{::sample.worker.user.name}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{::sample.company.code}}</vn-td>
|
||||
|
|
|
@ -18,7 +18,7 @@ class Controller extends Section {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
<vn-label-value label="Email" ellipsize="false"
|
||||
value="{{$ctrl.summary.email}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Sales person"
|
||||
value="{{$ctrl.summary.salesPerson.user.nickname}}">
|
||||
<vn-label-value label="Sales person">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.summary.salesPersonFk)"
|
||||
class="link">
|
||||
{{$ctrl.summary.salesPerson.user.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Channel"
|
||||
value="{{$ctrl.summary.contactChannel.name}}">
|
||||
|
@ -197,4 +201,7 @@
|
|||
</vn-vertical>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
</vn-card>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Entry",
|
||||
"base": "VnModel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model":"EntryLog"
|
||||
},
|
||||
|
@ -62,6 +62,18 @@
|
|||
},
|
||||
"loadPriority": {
|
||||
"type": "number"
|
||||
},
|
||||
"supplierFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"travelFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"companyFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
ngModule.vnComponent('vnEntryBasicData', {
|
||||
template: require('./index.html'),
|
||||
controller: Section,
|
||||
bindings: {
|
||||
entry: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,61 @@
|
|||
<mg-ajax path="Entries" options="vnPost"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.entry"
|
||||
form="form"
|
||||
save="post">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-icon color-marginal
|
||||
icon="info"
|
||||
vn-tooltip="Required fields (*)">
|
||||
</vn-icon>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="$ctrl.entry.supplierFk"
|
||||
url="Suppliers"
|
||||
show-field="nickname"
|
||||
search-function="{or: [{id: $search}, {nickname: {like: '%'+ $search +'%'}}]}"
|
||||
value-field="id"
|
||||
order="nickname"
|
||||
label="Supplier"
|
||||
required="true">
|
||||
<tpl-item>
|
||||
{{::id}} - {{::nickname}}
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="$ctrl.entry.travelFk"
|
||||
url="Travels/filter"
|
||||
search-function="$ctrl.searchFunction($search)"
|
||||
value-field="id"
|
||||
order="id"
|
||||
label="Travel"
|
||||
required="true">
|
||||
<tpl-item>
|
||||
{{::agencyModeName}} - {{::warehouseInName}} ({{::shipped | date: 'dd/MM/yyyy'}}) →
|
||||
{{::warehouseOutName}} ({{::landed | date: 'dd/MM/yyyy'}})
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
url="Companies"
|
||||
label="Company"
|
||||
show-field="code"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.entry.companyFk"
|
||||
required="true">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Create"></vn-submit>
|
||||
<vn-button ui-sref="entry.index" label="Cancel"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -0,0 +1,43 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
|
||||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
this.entry = {
|
||||
companyFk: this.vnConfig.companyFk
|
||||
};
|
||||
|
||||
if (this.$params && this.$params.supplierFk)
|
||||
this.entry.supplierFk = parseInt(this.$params.supplierFk);
|
||||
if (this.$params && this.$params.travelFk)
|
||||
this.entry.travelFk = parseInt(this.$params.travelFk);
|
||||
if (this.$params && this.$params.companyFk)
|
||||
this.entry.companyFk = parseInt(this.$params.companyFk);
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.submit().then(
|
||||
res => this.$state.go('entry.card.basicData', {id: res.data.id})
|
||||
);
|
||||
}
|
||||
|
||||
searchFunction($search) {
|
||||
return {or: [
|
||||
{'agencyModeName': {like: `%${$search}%`}},
|
||||
{'warehouseInName': {like: `%${$search}%`}},
|
||||
{'warehouseOutName': {like: `%${$search}%`}},
|
||||
{'shipped': new Date($search)},
|
||||
{'landed': new Date($search)}
|
||||
]};
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope'];
|
||||
|
||||
ngModule.vnComponent('vnEntryCreate', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,2 @@
|
|||
New entry: Nueva entrada
|
||||
Required fields (*): Campos requeridos (*)
|
|
@ -0,0 +1,10 @@
|
|||
vn-entry-create {
|
||||
vn-card {
|
||||
position: relative
|
||||
}
|
||||
vn-icon[icon="info"] {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 16px
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ export * from './module';
|
|||
|
||||
import './main';
|
||||
import './index/';
|
||||
import './create';
|
||||
import './latest-buys';
|
||||
import './search-panel';
|
||||
import './latest-buys-search-panel';
|
||||
|
|
|
@ -69,4 +69,16 @@
|
|||
</vn-data-viewer>
|
||||
<vn-travel-descriptor-popover
|
||||
vn-id="travelDescriptor">
|
||||
</vn-travel-descriptor-popover>
|
||||
</vn-travel-descriptor-popover>
|
||||
|
||||
<div fixed-bottom-right>
|
||||
<vn-vertical style="align-items: center;">
|
||||
<a ui-sref="entry.create" vn-bind="+">
|
||||
<vn-button class="round md vn-mb-sm"
|
||||
icon="add"
|
||||
vn-tooltip="New entry"
|
||||
tooltip-position="left">
|
||||
</vn-button>
|
||||
</a>
|
||||
</vn-vertical>
|
||||
</div>
|
|
@ -10,6 +10,7 @@
|
|||
{"state": "entry.latestBuys", "icon": "icon-latestBuys"}
|
||||
],
|
||||
"card": [
|
||||
{"state": "entry.card.basicData", "icon": "settings"},
|
||||
{"state": "entry.card.buy", "icon": "icon-lines"},
|
||||
{"state": "entry.card.log", "icon": "history"}
|
||||
]
|
||||
|
@ -33,6 +34,12 @@
|
|||
"component": "vn-entry-latest-buys",
|
||||
"description": "Latest buys",
|
||||
"acl": ["buyer"]
|
||||
}, {
|
||||
"url": "/create?supplierFk&travelFk&companyFk",
|
||||
"state": "entry.create",
|
||||
"component": "vn-entry-create",
|
||||
"description": "New entry",
|
||||
"acl": ["buyer"]
|
||||
}, {
|
||||
"url": "/:id",
|
||||
"state": "entry.card",
|
||||
|
@ -46,6 +53,14 @@
|
|||
"params": {
|
||||
"entry": "$ctrl.entry"
|
||||
}
|
||||
}, {
|
||||
"url": "/basic-data",
|
||||
"state": "entry.card.basicData",
|
||||
"component": "vn-entry-basic-data",
|
||||
"description": "Basic data",
|
||||
"params": {
|
||||
"entry": "$ctrl.entry"
|
||||
}
|
||||
}, {
|
||||
"url" : "/log",
|
||||
"state": "entry.card.log",
|
||||
|
|
|
@ -37,8 +37,12 @@
|
|||
value="{{$ctrl.invoiceOut.amount | currency: 'EUR': 2}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Client"
|
||||
value="{{$ctrl.invoiceOut.client.name}}">
|
||||
label="Client">
|
||||
<span
|
||||
ng-click="clientDescriptor.show($event, $ctrl.invoiceOut.client.id)"
|
||||
class="link">
|
||||
{{$ctrl.invoiceOut.client.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Company"
|
||||
|
@ -74,4 +78,7 @@
|
|||
vn-id="bookConfirmation"
|
||||
on-accept="$ctrl.bookInvoiceOut()"
|
||||
question="Are you sure you want to book this invoice?">
|
||||
</vn-confirm>
|
||||
</vn-confirm>
|
||||
<vn-client-descriptor-popover
|
||||
vn-id="clientDescriptor">
|
||||
</vn-client-descriptor-popover>
|
|
@ -26,7 +26,9 @@ module.exports = Self => {
|
|||
await fs.mkdir(tempPath, {recursive: true});
|
||||
|
||||
const timer = setInterval(async() => {
|
||||
const image = await Self.findOne({where: {error: null}});
|
||||
const image = await Self.findOne({
|
||||
where: {error: null, url: {neq: null}}
|
||||
});
|
||||
|
||||
// Exit loop
|
||||
if (!image) return clearInterval(timer);
|
||||
|
|
|
@ -113,7 +113,7 @@ module.exports = Self => {
|
|||
i.isActive,
|
||||
t.name type,
|
||||
t.workerFk buyerFk,
|
||||
u.nickname userNickname,
|
||||
u.name userName,
|
||||
intr.description AS intrastat,
|
||||
i.stems,
|
||||
ori.code AS origin,
|
||||
|
|
|
@ -37,7 +37,7 @@ module.exports = Self => {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = Self => {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@
|
|||
"retAccount": {
|
||||
"type": "Number"
|
||||
},
|
||||
"commision": {
|
||||
"commission": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"created": {
|
||||
"type": "Date"
|
||||
},
|
||||
"poscodeFk": {
|
||||
"postcodeFk": {
|
||||
"type": "Number"
|
||||
},
|
||||
"isActive": {
|
||||
|
|
|
@ -44,8 +44,12 @@
|
|||
<slot-body>
|
||||
<div class="attributes">
|
||||
<vn-label-value
|
||||
label="Buyer"
|
||||
value="{{$ctrl.item.itemType.worker.user.nickname}}">
|
||||
label="Buyer">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.item.itemType.worker.userFk)"
|
||||
class="link">
|
||||
{{$ctrl.item.itemType.worker.user.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
ng-repeat="tag in $ctrl.item.tags | limitTo:4"
|
||||
|
@ -96,3 +100,6 @@
|
|||
question="Do you want to clone this item?"
|
||||
message="All it's properties will be copied">
|
||||
</vn-confirm>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
|
@ -70,11 +70,11 @@
|
|||
{{::item.intrastat}}
|
||||
</vn-td>
|
||||
<vn-td shrink>{{::item.origin}}</vn-td>
|
||||
<vn-td shrink title="{{::item.userNickname}}">
|
||||
<vn-td shrink title="{{::item.userName}}">
|
||||
<span
|
||||
class="link"
|
||||
vn-click-stop="workerDescriptor.show($event, item.buyerFk)">
|
||||
{{::item.userNickname}}
|
||||
{{::item.userName}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td shrink>{{::item.density}}</vn-td>
|
||||
|
|
|
@ -36,8 +36,12 @@
|
|||
<vn-label-value label="stems"
|
||||
value="{{$ctrl.summary.item.stems}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Buyer"
|
||||
value="{{$ctrl.summary.item.itemType.worker.user.nickname}}">
|
||||
<vn-label-value label="Buyer">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.summary.item.itemType.worker.userFk)"
|
||||
class="link">
|
||||
{{$ctrl.summary.item.itemType.worker.user.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
<vn-one name="otherData">
|
||||
|
@ -105,4 +109,7 @@
|
|||
</p>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
</vn-card>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
|
@ -37,7 +37,7 @@ class Controller extends ModuleCard {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
ng-model="$ctrl.orderField"
|
||||
selection="$ctrl.orderSelection"
|
||||
translate-fields="['name']"
|
||||
order="name"
|
||||
order="priority DESC"
|
||||
show-field="name"
|
||||
value-field="field"
|
||||
label="Order by"
|
||||
|
|
|
@ -14,10 +14,10 @@ class Controller extends Section {
|
|||
{way: 'DESC', name: 'Descendant'},
|
||||
];
|
||||
this.defaultOrderFields = [
|
||||
{field: 'relevancy DESC, name', name: 'Relevancy'},
|
||||
{field: 'showOrder, price', name: 'Color and price'},
|
||||
{field: 'name', name: 'Name'},
|
||||
{field: 'price', name: 'Price'}
|
||||
{field: 'relevancy DESC, name', name: 'Relevancy', priority: 999},
|
||||
{field: 'showOrder, price', name: 'Color and price', priority: 999},
|
||||
{field: 'name', name: 'Name', priority: 999},
|
||||
{field: 'price', name: 'Price', priority: 999}
|
||||
];
|
||||
this.orderFields = [].concat(this.defaultOrderFields);
|
||||
this._orderWay = this.orderWays[0].way;
|
||||
|
@ -312,9 +312,11 @@ class Controller extends Section {
|
|||
tags.push({
|
||||
name: itemTag.name,
|
||||
field: itemTag.tagFk,
|
||||
isTag: true
|
||||
isTag: true,
|
||||
priority: 1
|
||||
});
|
||||
}
|
||||
} else
|
||||
tags[alreadyAdded].priority += 1;
|
||||
});
|
||||
});
|
||||
let newFilterList = [].concat(this.defaultOrderFields);
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('Order', () => {
|
|||
jest.spyOn(controller, 'buildTagsFilter');
|
||||
jest.spyOn(controller, 'buildOrderFilter');
|
||||
|
||||
const expectedResult = [{field: 'showOrder, price', name: 'Color and price'}];
|
||||
const expectedResult = [{field: 'showOrder, price', name: 'Color and price', priority: 999}];
|
||||
const items = [{id: 1, name: 'My Item', tags: [
|
||||
{tagFk: 4, name: 'Length'},
|
||||
{tagFk: 5, name: 'Color'}
|
||||
|
|
|
@ -15,8 +15,12 @@
|
|||
value="{{$ctrl.$t($ctrl.order.isConfirmed ? 'Confirmed' : 'Not confirmed')}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Sales person"
|
||||
value="{{$ctrl.order.client.salesPerson.user.nickname}}">
|
||||
label="Sales person">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.order.client.salesPersonFk)"
|
||||
class="link">
|
||||
{{$ctrl.order.client.salesPerson.user.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Landed"
|
||||
|
@ -64,4 +68,7 @@
|
|||
on-accept="$ctrl.deleteOrder()"
|
||||
message="You are going to delete this order"
|
||||
question="continue anyway?">
|
||||
</vn-confirm>
|
||||
</vn-confirm>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
|
@ -119,7 +119,7 @@ module.exports = Self => {
|
|||
r.m3,
|
||||
r.description,
|
||||
am.name agencyName,
|
||||
u.nickname AS workerNickname,
|
||||
u.name AS workerUserName,
|
||||
v.numberPlate AS vehiclePlateNumber
|
||||
FROM route r
|
||||
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
|
||||
|
@ -128,7 +128,6 @@ module.exports = Self => {
|
|||
LEFT JOIN account.user u ON u.id = w.userFk`
|
||||
);
|
||||
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
let itemsIndex = stmts.push(stmt) - 1;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ describe('route summary()', () => {
|
|||
const result = await app.models.Route.summary(1);
|
||||
const worker = result.route.worker().user();
|
||||
|
||||
expect(worker.nickname).toEqual('deliveryNick');
|
||||
expect(worker.name).toEqual('delivery');
|
||||
});
|
||||
|
||||
it(`should return a summary object containing data from the tickets`, async() => {
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = Self => {
|
|||
{
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['id', 'nickname']
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<span
|
||||
class="link"
|
||||
vn-click-stop="workerDescriptor.show($event, route.workerFk)">
|
||||
{{::route.workerNickname}}
|
||||
{{::route.workerUserName}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{::route.agencyName | dashIfEmpty}}</vn-td>
|
||||
|
@ -79,10 +79,9 @@
|
|||
tooltip-position="left">
|
||||
</vn-button>
|
||||
|
||||
<a ui-sref="route.create">
|
||||
<a ui-sref="route.create" vn-bind="+">
|
||||
<vn-button class="round md vn-mb-sm"
|
||||
icon="add"
|
||||
vn-bind="+"
|
||||
vn-tooltip="New route"
|
||||
tooltip-position="left">
|
||||
</vn-button>
|
||||
|
|
|
@ -14,8 +14,12 @@
|
|||
<vn-label-value label="Vehicle"
|
||||
value="{{$ctrl.summary.route.vehicle.numberPlate}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Driver"
|
||||
value="{{$ctrl.summary.route.worker.user.nickname}}">
|
||||
<vn-label-value label="Driver">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.summary.route.workerFk)"
|
||||
class="link">
|
||||
{{$ctrl.summary.route.worker.user.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Cost"
|
||||
value="{{$ctrl.summary.route.cost | currency: 'EUR':2}}">
|
||||
|
@ -106,3 +110,6 @@
|
|||
<vn-client-descriptor-popover
|
||||
vn-id="clientDescriptor">
|
||||
</vn-client-descriptor-popover>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
|
|
|
@ -245,7 +245,7 @@ module.exports = Self => {
|
|||
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
|
||||
FROM tmp.filter f
|
||||
LEFT JOIN alertLevel al ON al.alertLevel = f.alertLevel
|
||||
WHERE (f.alertLevelCode = 'FREE' OR f.alertLevel IS NULL)
|
||||
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
|
||||
AND f.shipped >= CURDATE()`);
|
||||
stmts.push('CALL ticketGetProblems()');
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ module.exports = Self => {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class Controller extends ModuleCard {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,8 +90,12 @@
|
|||
value="{{$ctrl.ticket.ticketState.state.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Sales person"
|
||||
value="{{$ctrl.ticket.client.salesPerson.user.nickname}}">
|
||||
label="Sales person">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.ticket.client.salesPersonFk)"
|
||||
class="link">
|
||||
{{$ctrl.ticket.client.salesPerson.user.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Shipped"
|
||||
|
@ -295,4 +299,7 @@
|
|||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Save</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
||||
</vn-dialog>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
|
@ -210,7 +210,7 @@ class Controller extends Descriptor {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,12 @@
|
|||
{{::document.dms.description}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td shrink>
|
||||
<vn-check
|
||||
ng-model="document.dms.hasFile"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td shrink>
|
||||
<span title="{{'Download file' | translate}}" class="link"
|
||||
ng-click="$ctrl.downloadFile(document.dmsFk)">
|
||||
|
@ -60,8 +66,9 @@
|
|||
<vn-td shrink>
|
||||
<span class="link"
|
||||
ng-click="workerDescriptor.show($event, document.dms.workerFk)">
|
||||
{{::document.dms.worker.user.nickname | dashIfEmpty}}
|
||||
</span></vn-td>
|
||||
{{::document.dms.worker.user.name | dashIfEmpty}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>
|
||||
{{::document.dms.created | date:'dd/MM/yyyy HH:mm'}}
|
||||
</vn-td>
|
||||
|
|
|
@ -33,7 +33,7 @@ class Controller extends Section {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -143,10 +143,9 @@
|
|||
vn-tooltip="Payment on account..."
|
||||
tooltip-position="left">
|
||||
</vn-button>
|
||||
<a ui-sref="ticket.create">
|
||||
<a ui-sref="ticket.create" vn-bind="+">
|
||||
<vn-button class="round md vn-mb-sm"
|
||||
icon="add"
|
||||
vn-bind="+"
|
||||
vn-tooltip="New ticket"
|
||||
tooltip-position="left">
|
||||
</vn-button>
|
||||
|
|
|
@ -18,8 +18,12 @@
|
|||
<vn-label-value label="State"
|
||||
value="{{$ctrl.summary.ticketState.state.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Salesperson"
|
||||
value="{{$ctrl.summary.client.salesPerson.user.nickname}}">
|
||||
<vn-label-value label="Salesperson">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.summary.client.salesPersonFk)"
|
||||
class="link">
|
||||
{{$ctrl.summary.client.salesPerson.user.name}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Agency"
|
||||
value="{{$ctrl.summary.agencyMode.name}}">
|
||||
|
@ -239,4 +243,7 @@
|
|||
</vn-item-descriptor-popover>
|
||||
<vn-invoice-out-descriptor-popover
|
||||
vn-id="invoice-out-descriptor">
|
||||
</vn-invoice-out-descriptor-popover>
|
||||
</vn-invoice-out-descriptor-popover>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<span
|
||||
class="link"
|
||||
ng-click="workerDescriptor.show($event, tracking.worker.user.id)">
|
||||
{{::tracking.worker.user.nickname | dashIfEmpty}}
|
||||
{{::tracking.worker.user.name | dashIfEmpty}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{::tracking.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
|
|
|
@ -13,7 +13,7 @@ class Controller extends Section {
|
|||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,8 @@ module.exports = Self => {
|
|||
let stmts = [];
|
||||
let stmt;
|
||||
stmt = new ParameterizedSQL(
|
||||
`SELECT
|
||||
`SELECT * FROM
|
||||
(SELECT
|
||||
t.id,
|
||||
t.shipped,
|
||||
t.landed,
|
||||
|
@ -132,7 +133,7 @@ module.exports = Self => {
|
|||
FROM vn.travel t
|
||||
JOIN vn.agencyMode am ON am.id = t.agencyFk
|
||||
JOIN vn.warehouse win ON win.id = t.warehouseInFk
|
||||
JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk`
|
||||
JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk) AS t`
|
||||
);
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Reference: Referencia
|
||||
Wh. In: Warehouse entrada
|
||||
Wh. Out: Warehouse salida
|
||||
Wh. In: Almacén entrada
|
||||
Wh. Out: Almacén salida
|
||||
Shipped: F. envío
|
||||
Landed: F. entrega
|
||||
Total entries: Entradas totales
|
|
@ -18,6 +18,7 @@
|
|||
<vn-th field="reference" shrink>Reference</vn-th>
|
||||
<vn-th expand>Description</vn-th>
|
||||
<vn-th field="hasFile" shrink>Original</vn-th>
|
||||
<vn-th shrink>File</vn-th>
|
||||
<vn-th field="created">Created</vn-th>
|
||||
<vn-th shrink></vn-th>
|
||||
<vn-th shrink></vn-th>
|
||||
|
@ -36,7 +37,13 @@
|
|||
<span title="{{::document.description}}">
|
||||
{{::document.description}}
|
||||
</span>
|
||||
</vn-td >
|
||||
</vn-td>
|
||||
<vn-td shrink>
|
||||
<vn-check
|
||||
ng-model="document.dms.hasFile"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td shrink>
|
||||
<span title="{{'Download file' | translate}}" class="link"
|
||||
ng-click="$ctrl.downloadFile(document.dmsFk)">
|
||||
|
|
|
@ -4,42 +4,179 @@ const smtp = require('../core/smtp');
|
|||
const config = require('../core/config');
|
||||
|
||||
module.exports = app => {
|
||||
app.get('/api/closure/by-ticket', async function(req, res) {
|
||||
app.get('/api/closure/all', async function(req, res, next) {
|
||||
try {
|
||||
res.status(200).json({
|
||||
message: 'Task executed successfully'
|
||||
});
|
||||
|
||||
await db.rawSql(`DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close`);
|
||||
await db.rawSql(`
|
||||
CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY (
|
||||
SELECT
|
||||
t.id AS ticketFk
|
||||
FROM expedition e
|
||||
JOIN ticket t ON t.id = e.ticketFk
|
||||
JOIN warehouse wh ON wh.id = t.warehouseFk AND wh.hasComission
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.alertLevel = ts.alertLevel
|
||||
WHERE al.code = 'PACKED'
|
||||
AND DATE(t.shipped) BETWEEN DATE_ADD(CURDATE(), INTERVAL -2 DAY) AND CURDATE()
|
||||
AND t.refFk IS NULL
|
||||
GROUP BY e.ticketFk)`);
|
||||
|
||||
await closeAll(req.args);
|
||||
|
||||
await db.rawSql(`
|
||||
UPDATE ticket t
|
||||
JOIN ticketState ts ON t.id = ts.ticketFk
|
||||
JOIN alertLevel al ON al.alertLevel = ts.alertLevel
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
JOIN zone z ON z.id = t.zoneFk
|
||||
SET t.routeFk = NULL
|
||||
WHERE shipped BETWEEN CURDATE() AND util.dayEnd(CURDATE())
|
||||
AND al.code NOT IN('DELIVERED','PACKED')
|
||||
AND t.routeFk
|
||||
AND z.name LIKE '%MADRID%'`);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/closure/all', async function(req, res) {
|
||||
res.status(200).json({
|
||||
message: 'Task executed successfully'
|
||||
});
|
||||
app.get('/api/closure/by-ticket', async function(req, res, next) {
|
||||
try {
|
||||
const reqArgs = req.args;
|
||||
if (!reqArgs.ticketId)
|
||||
throw new Error('The argument ticketId is required');
|
||||
|
||||
res.status(200).json({
|
||||
message: 'Task executed successfully'
|
||||
});
|
||||
|
||||
await db.rawSql(`DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close`);
|
||||
await db.rawSql(`
|
||||
CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY (
|
||||
SELECT
|
||||
t.id AS ticketFk
|
||||
FROM expedition e
|
||||
JOIN ticket t ON t.id = e.ticketFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.alertLevel = ts.alertLevel
|
||||
WHERE al.code = 'PACKED'
|
||||
AND t.id = :ticketId
|
||||
AND t.refFk IS NULL
|
||||
GROUP BY e.ticketFk)`, {
|
||||
ticketId: reqArgs.ticketId
|
||||
});
|
||||
|
||||
await closeAll(reqArgs);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/closure/by-agency', async function(req, res) {
|
||||
try {
|
||||
const reqArgs = req.args;
|
||||
if (!reqArgs.agencyModeId)
|
||||
throw new Error('The argument agencyModeId is required');
|
||||
|
||||
if (!reqArgs.warehouseId)
|
||||
throw new Error('The argument warehouseId is required');
|
||||
|
||||
if (!reqArgs.to)
|
||||
throw new Error('The argument to is required');
|
||||
|
||||
res.status(200).json({
|
||||
message: 'Task executed successfully'
|
||||
});
|
||||
|
||||
await db.rawSql(`DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close`);
|
||||
await db.rawSql(`
|
||||
CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY (
|
||||
SELECT
|
||||
t.id AS ticketFk
|
||||
FROM expedition e
|
||||
JOIN ticket t ON t.id = e.ticketFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.alertLevel = ts.alertLevel
|
||||
WHERE al.code = 'PACKED'
|
||||
AND t.agencyModeFk = :agencyModeId
|
||||
AND t.warehouseFk = :warehouseId
|
||||
AND DATE(t.shipped) BETWEEN DATE_ADD(:to, INTERVAL -2 DAY) AND :to
|
||||
AND t.refFk IS NULL
|
||||
GROUP BY e.ticketFk)`, {
|
||||
agencyModeId: reqArgs.agencyModeId,
|
||||
warehouseId: reqArgs.warehouseId,
|
||||
to: reqArgs.to
|
||||
});
|
||||
|
||||
await closeAll(reqArgs);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/closure/by-route', async function(req, res) {
|
||||
try {
|
||||
const reqArgs = req.args;
|
||||
if (!reqArgs.routeId)
|
||||
throw new Error('The argument routeId is required');
|
||||
|
||||
res.status(200).json({
|
||||
message: 'Task executed successfully'
|
||||
});
|
||||
|
||||
await db.rawSql(`DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close`);
|
||||
await db.rawSql(`
|
||||
CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY (
|
||||
SELECT
|
||||
t.id AS ticketFk
|
||||
FROM expedition e
|
||||
JOIN ticket t ON t.id = e.ticketFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.alertLevel = ts.alertLevel
|
||||
WHERE al.code = 'PACKED'
|
||||
AND t.routeFk = :routeId
|
||||
AND t.refFk IS NULL
|
||||
GROUP BY e.ticketFk)`, {
|
||||
routeId: reqArgs.routeId
|
||||
});
|
||||
|
||||
await closeAll(reqArgs);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
async function closeAll(reqArgs) {
|
||||
const failedtickets = [];
|
||||
const tickets = await db.rawSql(`
|
||||
SELECT
|
||||
t.id,
|
||||
t.clientFk,
|
||||
c.email recipient,
|
||||
c.isToBeMailed,
|
||||
c.salesPersonFk,
|
||||
c.isToBeMailed,
|
||||
c.hasToInvoice,
|
||||
co.hasDailyInvoice,
|
||||
eu.email salesPersonEmail
|
||||
FROM expedition e
|
||||
JOIN ticket t ON t.id = e.ticketFk
|
||||
FROM tmp.ticket_close tt
|
||||
JOIN ticket t ON t.id = tt.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN warehouse wh ON wh.id = t.warehouseFk AND wh.hasComission
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.alertLevel = ts.alertLevel
|
||||
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
||||
WHERE al.code = 'PACKED'
|
||||
AND DATE(t.shipped) BETWEEN DATE_ADD(CURDATE(), INTERVAL -2 DAY) AND CURDATE()
|
||||
AND t.refFk IS NULL
|
||||
GROUP BY e.ticketFk`);
|
||||
JOIN province p ON p.id = c.provinceFk
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk`);
|
||||
|
||||
for (const ticket of tickets) {
|
||||
try {
|
||||
await db.rawSql(`CALL vn.ticket_closeByTicket(:ticketId)`, {
|
||||
await db.rawSql(`CALL vn.ticket_close(:ticketId)`, {
|
||||
ticketId: ticket.id
|
||||
});
|
||||
|
||||
if (!ticket.salesPersonFk || !ticket.isToBeMailed) continue;
|
||||
const hasToInvoice = ticket.hasToInvoice && ticket.hasDailyInvoice;
|
||||
if (!ticket.salesPersonFk || !ticket.isToBeMailed || hasToInvoice) continue;
|
||||
|
||||
if (!ticket.recipient) {
|
||||
const body = `No se ha podido enviar el albarán <strong>${ticket.id}</strong>
|
||||
|
@ -54,7 +191,6 @@ module.exports = app => {
|
|||
continue;
|
||||
}
|
||||
|
||||
const reqArgs = req.args;
|
||||
const args = Object.assign({
|
||||
ticketId: ticket.id,
|
||||
recipientId: ticket.clientFk,
|
||||
|
@ -88,5 +224,7 @@ module.exports = app => {
|
|||
html: body
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await db.rawSql(`DROP TEMPORARY TABLE tmp.ticket_close`);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
subject: Your delivery note
|
||||
title: "Here is your delivery note!"
|
||||
title: Your delivery note
|
||||
dear: Dear client
|
||||
description: The delivery note from the order <strong>{0}</strong> is now available. <br/>
|
||||
You can download it by clicking <a href="https://www.verdnatura.es/#!form=ecomerce/ticket&ticket={0}">this link</a>.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
subject: Aquí tienes tu albarán
|
||||
title: "Aquí tienes tu albarán"
|
||||
subject: Tu albarán
|
||||
title: Tu albarán
|
||||
dear: Estimado cliente
|
||||
description: Ya está disponible el albarán correspondiente al pedido <strong>{0}</strong>. <br/>
|
||||
Puedes verlo haciendo clic <a href="https://www.verdnatura.es/#!form=ecomerce/ticket&ticket={0}">en este enlace</a>.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
subject: Voici votre bon de livraison
|
||||
title: "Voici votre bon de livraison"
|
||||
subject: Votre bon de livraison
|
||||
title: Votre bon de livraison
|
||||
dear: Cher client,
|
||||
description: Le bon de livraison correspondant à la commande <strong>{0}</strong> est maintenant disponible.<br/>
|
||||
Vous pouvez le voir en cliquant <a href="https://www.verdnatura.es/#!form=ecomerce/ticket&ticket={0}" target="_blank">sur ce lien</a>.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
subject: Vossa Nota de Entrega
|
||||
title: "Esta é vossa nota de entrega!"
|
||||
subject: Vossa nota de entrega
|
||||
title: Vossa nota de entrega
|
||||
dear: Estimado cliente
|
||||
description: Já está disponível sua nota de entrega correspondente a encomenda numero <strong>{0}</strong>. <br/>
|
||||
Para ver-lo faça um clique <a href="https://www.verdnatura.es/#!form=ecomerce/ticket&ticket={0}">neste link</a>.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
subject: Your delivery note
|
||||
title: "Here is your delivery note!"
|
||||
title: Your delivery note
|
||||
dear: Dear client
|
||||
description: The delivery note from the order <strong>{0}</strong> is now available. <br/>
|
||||
You can download it by clicking on the attachment of this email.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
subject: Aquí tienes tu albarán
|
||||
title: "¡Este es tu albarán!"
|
||||
subject: Tu albarán
|
||||
title: Tu albarán
|
||||
dear: Estimado cliente
|
||||
description: Ya está disponible el albarán correspondiente al pedido {0}. <br/>
|
||||
Puedes descargarlo haciendo clic en el adjunto de este correo.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
subject: Voici votre bon de livraison
|
||||
title: "Voici votre bon de livraison!"
|
||||
subject: Votre bon de livraison
|
||||
title: Votre bon de livraison
|
||||
dear: Cher client,
|
||||
description: Le bon de livraison correspondant à la commande {0} est maintenant disponible.<br/>
|
||||
Vous pouvez le télécharger en cliquant sur la pièce jointe dans cet email.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
subject: Vossa Nota de Entrega
|
||||
title: "Esta é vossa nota de entrega!"
|
||||
subject: Vossa nota de entrega
|
||||
title: Vossa nota de entrega
|
||||
dear: Estimado cliente
|
||||
description: Já está disponível sua nota de entrega correspondente a encomenda {0}. <br/>
|
||||
Podes descarregar-la fazendo um clique no arquivo anexado ao e-mail.
|
||||
|
|
Loading…
Reference in New Issue