Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Gerard 2019-03-25 09:36:30 +01:00
commit f4ddf3544d
29 changed files with 314 additions and 34 deletions

View File

@ -26,7 +26,8 @@ module.exports = Self => {
});
Self.send = async(ctx, data, transaction) => {
const userId = ctx.options && ctx.options.accessToken.userId || ctx.req && ctx.req.accessToken.userId;
const accessToken = ctx.options && ctx.options.accessToken || ctx.req && ctx.req.accessToken;
const userId = accessToken.userId;
const models = Self.app.models;
const sender = await models.Account.findById(userId, transaction);
const recipient = await models.Account.findById(data.recipientFk, transaction);

View File

@ -0,0 +1,39 @@
USE `vn`;
DROP procedure IF EXISTS `ticketGetVisibleAvailable`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetVisibleAvailable`(
vTicket INT)
BEGIN
DECLARE vVisibleCalc INT;
DECLARE vAvailableCalc INT;
DECLARE vShipped DATE;
DECLARE vWarehouse TINYINT;
DECLARE vAlertLevel INT;
SELECT t.warehouseFk, t.shipped, ts.alertLevel INTO vWarehouse, vShipped, vAlertLevel
FROM ticket t
LEFT JOIN ticketState ts ON ts.ticketFk = vTicket
WHERE t.id = vTicket;
IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN
IF vShipped >= CURDATE() THEN
CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped);
END IF;
IF vShipped = CURDATE() THEN
CALL cache.visible_refresh(vVisibleCalc, FALSE, vWarehouse);
END IF;
END IF;
SELECT s.id, s.itemFk, s.quantity, s.concept, s.price, s.reserved, s.discount, v.visible, av.available, it.image, it.subName
FROM sale s
LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCalc
LEFT JOIN cache.available av ON av.item_id = s.itemFk AND av.calc_id = vAvailableCalc
LEFT JOIN item it ON it.id = s.itemFk
WHERE s.ticketFk = vTicket
ORDER BY s.concept;
END$$
DELIMITER ;

View File

@ -353,15 +353,15 @@ INSERT INTO `vn`.`creditInsurance`(`id`, `creditClassification`, `credit`, `crea
(2, 2 , 6000, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL),
(3, 3, 10000 , DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL);
INSERT INTO `vn`.`route`(`id`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`)
INSERT INTO `vn`.`route`(`id`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`)
VALUES
(1, 56, CURDATE(), 1, 1, 'first route', null),
(2, 56, CURDATE(), 1, 1, 'second route', 4.2),
(3, 56, CURDATE(), 2, 7, 'third route', 5.3),
(4, 56, CURDATE(), 3, 7, 'fourth route', 6.4),
(5, 56, CURDATE(), 4, 8, 'fifth route', 7.5),
(6, 57, CURDATE(), 5, 8, 'sixth route', 8.6),
(7, 57, CURDATE(), 6, null, 'seventh route', 9.7);
(1, 56, CURDATE(), 1, 1, 'first route', null, 10, CURDATE(), CURDATE()),
(2, 56, CURDATE(), 1, 1, 'second route', 4.2, 20, CURDATE(), CURDATE()),
(3, 56, CURDATE(), 2, 7, 'third route', 5.3, 30, CURDATE(), CURDATE()),
(4, 56, CURDATE(), 3, 7, 'fourth route', 6.4, 40, CURDATE(), CURDATE()),
(5, 56, CURDATE(), 4, 8, 'fifth route', 7.5, 50, CURDATE(), CURDATE()),
(6, 57, CURDATE(), 5, 8, 'sixth route', 8.6, 60, CURDATE(), CURDATE()),
(7, 57, CURDATE(), 6, null, 'seventh route', 9.7, 70, CURDATE(), CURDATE());
INSERT INTO `vn2008`.`empresa_grupo`(`empresa_grupo_id`, `grupo`)
VALUES

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('pbx path', () => {
describe('Worker pbx path', () => {
const nightmare = createNightmare();
beforeAll(() => {

View File

@ -52,7 +52,7 @@ module.exports = Self => {
});
if (!ticketFk) {
ticketFk = await createTicket({
ticketFk = await createTicket(ctx, {
clientFk: address.clientFk,
addressFk: addressFk,
warehouseFk: sale.ticket().warehouseFk,
@ -134,7 +134,8 @@ module.exports = Self => {
async function createTicket(ctx, params, transaction) {
let ticket = await Self.app.models.Ticket.new(ctx,
{shipped: new Date(),
{
shipped: new Date(),
landed: new Date(),
clientFk: params.clientFk,
warehouseFk: params.warehouseFk,

View File

@ -100,8 +100,8 @@ module.exports = Self => {
`SELECT i.id, i.image, i.name, i.description,
i.size, i.tag5, i.value5, i.tag6, i.value6,
i.tag7, i.value7, i.tag8, i.value8,
i.tag9, i.value9, i.tag10, i.value10, i.isActive,
t.name type, u.nickname userNickname,
i.tag9, i.value9, i.tag10, i.value10, i.subName,
i.isActive, t.name type, u.nickname userNickname,
t.name type, u.id userId,
intr.description AS intrastat, i.stems,
ori.code AS origin, t.name AS type,

View File

@ -1,5 +1,8 @@
<vn-horizontal>
<vn-one>{{::$ctrl.title}}</vn-one>
<vn-one ng-if="$ctrl.subName">
<h3>{{::$ctrl.subName}}</h3>
</vn-one>
<vn-auto>
<section
class="inline-tag ellipsize"

View File

@ -6,6 +6,7 @@ ngModule.component('vnFetchedTags', {
bindings: {
maxLength: '<',
item: '<',
title: '<'
title: '<',
subName: '<?'
}
});

View File

@ -12,6 +12,15 @@ vn-fetched-tags {
text-overflow: ellipsis;
min-width: 5em;
}
& > vn-one:nth-child(2) h3 {
color: $color-font-secondary;
text-transform: uppercase;
line-height: initial;
text-align: center;
font-size: 1em
}
& > vn-auto {
display: flex;
padding-left: .4em;
@ -39,7 +48,7 @@ vn-fetched-tags {
flex-direction: column;
& > vn-one {
padding-bottom: .2em;
padding-bottom: .2em
}
& > vn-auto {
white-space: initial;

View File

@ -62,7 +62,8 @@
<vn-fetched-tags
max-length="6"
item="::item"
title="::item.name">
title="::item.name"
sub-name="::item.subName">
</vn-fetched-tags>
</vn-td>
<vn-td number>{{::item.stems}}</vn-td>

View File

@ -43,7 +43,8 @@
<vn-fetched-tags
max-length="6"
item="::row.item"
title="::row.item.name">
title="::row.item.name"
sub-name="::row.item.subName">
</vn-fetched-tags>
</vn-td>
<vn-td>{{::row.warehouse.name}}</vn-td>

View File

@ -70,11 +70,12 @@
</vn-td>
<vn-td expand>
<vn-fetched-tags
max-length="6"
item="::row.item"
title="::row.item.name">
</vn-fetched-tags>
</vn-td>
max-length="6"
item="::row.item"
title="::row.item.name"
sub-name="::row.item.subName">
</vn-fetched-tags>
</vn-td>
<vn-td number>{{::row.quantity}}</vn-td>
<vn-td number>{{::row.price | currency: 'EUR':2}}</vn-td>
<vn-td number>{{::row.quantity * row.price | currency: 'EUR':2}}</vn-td>

View File

@ -42,7 +42,8 @@
<vn-fetched-tags
max-length="6"
item="::row.item"
title="::row.item.name">
title="::row.item.name"
sub-name="::row.item.subName">
</vn-fetched-tags>
</vn-td>
<vn-td number>{{::row.quantity}}</vn-td>

View File

@ -0,0 +1,76 @@
<mg-ajax path="/api/Routes/{{patch.params.id}}" options="vnPatch"></mg-ajax>
<vn-watcher
vn-id="watcher"
data="$ctrl.route"
form="form"
save="patch">
</vn-watcher>
<form name="form" ng-submit="watcher.submit()" compact>
<vn-card pad-large>
<vn-horizontal>
<vn-autocomplete
vn-one
field="$ctrl.route.workerFk"
url="/api/Clients/activeWorkersWithRole"
show-field="nickname"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Worker">
</vn-autocomplete>
<vn-autocomplete
vn-one
field="$ctrl.route.vehicleFk"
url="/api/Vehicles"
show-field="numberPlate"
value-field="id"
label="Vehicle">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker
vn-one
label="Created"
model="$ctrl.route.created"
ini-options="{dateFormat: 'd-m-Y'}">
</vn-date-picker>
<vn-autocomplete
vn-one
field="$ctrl.route.agencyModeFk"
url="/api/AgencyModes"
show-field="name"
value-field="id"
label="Agency">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Km start"
field="$ctrl.route.kmStart">
</vn-textfield>
<vn-textfield
vn-one
label="Km end"
model="$ctrl.route.kmEnd">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker
vn-one
label="Date started"
model="$ctrl.route.started"
ini-options="{dateFormat: 'd-m-Y'}">
</vn-date-picker>
<vn-date-picker
vn-one
label="Date finished"
model="$ctrl.route.finished"
ini-options="{dateFormat: 'd-m-Y'}">
</vn-date-picker>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</form>

View File

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

View File

@ -0,0 +1,4 @@
Date finished: Fecha fin
Date started: Fecha inicio
Km start: Km de inicio
Km end: Km de fin

View File

@ -6,7 +6,22 @@ export default class Controller {
this.$stateParams = $stateParams;
this.route = null;
this.filter = {
fields: ['id', 'agencyModeFk', 'created', 'm3', 'warehouseFk', 'description', 'vehicleFk'],
fields: [
'id',
'workerFk',
'agencyModeFk',
'created',
'm3',
'warehouseFk',
'description',
'vehicleFk',
'kmStart',
'kmEnd',
'started',
'finished',
'cost'
],
where: {id: $stateParams.id},
include: [
{

View File

@ -0,0 +1,60 @@
<mg-ajax path="/api/Routes" options="vnPost"></mg-ajax>
<vn-watcher
vn-id="watcher"
data="$ctrl.route"
form="form"
save="post">
</vn-watcher>
<div class="content-block">
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
<vn-card pad-large>
<vn-horizontal>
<vn-autocomplete
vn-one
field="$ctrl.route.workerFk"
url="/api/Clients/activeWorkersWithRole"
show-field="nickname"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Worker">
</vn-autocomplete>
<vn-date-picker
vn-one
label="Created"
model="$ctrl.route.created"
ini-options="{dateFormat: 'd-m-Y'}">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
field="$ctrl.route.vehicleFk"
url="/api/Vehicles"
show-field="numberPlate"
value-field="id"
label="Vehicle">
</vn-autocomplete>
<vn-autocomplete
vn-one
field="$ctrl.route.agencyModeFk"
url="/api/AgencyModes"
show-field="name"
value-field="id"
label="Agency">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Description"
field="$ctrl.route.description">
</vn-textfield>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Create"></vn-submit>
<vn-button ui-sref="route.index" label="Cancel"></vn-button>
</vn-button-bar>
</form>
</div>

View File

@ -0,0 +1,20 @@
import ngModule from '../module';
export default class Controller {
constructor($scope, $state) {
this.$scope = $scope;
this.$state = $state;
}
onSubmit() {
this.$scope.watcher.submit().then(
res => this.$state.go('route.card.summary', {id: res.data.id})
);
}
}
Controller.$inject = ['$scope', '$state'];
ngModule.component('vnRouteCreate', {
template: require('./index.html'),
controller: Controller
});

View File

@ -5,3 +5,5 @@ import './search-panel';
import './descriptor';
import './summary';
import './card';
import './create';
import './basic-data';

View File

@ -73,3 +73,6 @@
vn-id="workerDescriptor"
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>
<a ui-sref="route.create" vn-tooltip="New route" vn-bind="+" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>
</a>

View File

@ -4,6 +4,8 @@
"icon": "icon-delivery",
"validations" : true,
"dependencies": ["client", "worker", "ticket"],
"menu": [
{"state": "route.card.basicData", "icon": "settings"}],
"routes": [
{
"url": "/route",
@ -19,6 +21,12 @@
"component": "vn-route-index",
"description": "Routes"
},
{
"url": "/create",
"state": "route.create",
"component": "vn-route-create",
"description": "New route"
},
{
"url": "/:id",
"state": "route.card",
@ -33,6 +41,16 @@
"params": {
"route": "$ctrl.route"
}
},
{
"url": "/basic-data",
"state": "route.card.basicData",
"component": "vn-route-basic-data",
"description": "Basic data",
"params": {
"route": "$ctrl.route"
},
"acl": ["delivery"]
}
]
}

View File

@ -51,7 +51,8 @@
<vn-fetched-tags
max-length="6"
item="::sale.item"
title="::sale.concept">
title="::sale.concept"
sub-name="::sale.item.subName">
</vn-fetched-tags>
</td>
<td rowspan="{{::sale.components.length + 1}}" number>

View File

@ -17,9 +17,9 @@
<td number>{{("000000"+sale.itemFk).slice(-6)}}</td>
<td expand>
<vn-fetched-tags
max-length="6"
item="::sale.item"
title="::sale.concept">
max-length="6"
item="::sale.item"
title="::sale.concept">
</vn-fetched-tags>
</td>
<td number>{{::sale.quantity}}</td>

View File

@ -37,7 +37,8 @@
<vn-fetched-tags
max-length="6"
item="::sale.item"
title="::sale.concept">
title="::sale.concept"
sub-name="::sale.item.subName">
</vn-fetched-tags>
</vn-td>
<vn-td number>{{::sale.quantity}}</vn-td>

View File

@ -41,7 +41,8 @@
<vn-fetched-tags
max-length="6"
item="::sale.item"
title="::sale.concept">
title="::sale.concept"
sub-name="::sale.item.subName">
</vn-fetched-tags>
</vn-td>
<vn-td>{{::sale.quantity}}</vn-td>

View File

@ -121,7 +121,8 @@
<vn-fetched-tags
max-length="6"
item="::sale.tags"
title="::sale.concept">
title="::sale.concept"
sub-name="::sale.subName">
</vn-fetched-tags>
</vn-td>
<vn-td number ng-if="$ctrl.isEditable">

View File

@ -97,7 +97,13 @@
</span>
</vn-td>
<vn-td number>{{::sale.quantity}}</vn-td>
<vn-td expand><vn-fetched-tags max-length="6" item="sale.item" title="sale.concept"/></vn-td>
<vn-td expand>
<vn-fetched-tags
max-length="6"
item="::sale.item"
title="::sale.concept"
sub-name="::sale.item.subName"/>
</vn-td>
<vn-td number>{{::sale.price | currency: 'EUR':2}}</vn-td>
<vn-td number>{{::sale.discount}} %</vn-td>
<vn-td number>{{::sale.quantity * sale.price | currency: 'EUR':2}}</vn-td>

View File

@ -38,7 +38,13 @@
{{sale.itemFk | zeroFill:6}}
</span>
</vn-td>
<vn-td expand><vn-fetched-tags max-length="6" item="::sale.item" title="::sale.concept"/></vn-td>
<vn-td expand>
<vn-fetched-tags
max-length="6"
item="::sale.item"
title="::sale.concept"
sub-name="::sale.item.subName"/>
</vn-td>
<vn-td number>{{::sale.quantity}}</vn-td>
<vn-td number>{{::sale.volume.m3 | number:3}}</vn-td>
</vn-tr>