Merge branch 'dev' into 6358-boxPicking_YellowZebra
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
8396b8cd64
|
@ -1,5 +0,0 @@
|
||||||
DELETE FROM salix.ACL
|
|
||||||
WHERE model = 'MailAliasAccount'
|
|
||||||
AND property = 'canEditAlias'
|
|
||||||
AND principalType = 'ROLE'
|
|
||||||
AND principalId = 'marketingBoss';
|
|
|
@ -2400,7 +2400,8 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
|
||||||
(18, 'dua', NULL, NULL, 'dua'),
|
(18, 'dua', NULL, NULL, 'dua'),
|
||||||
(19, 'inmovilizado', NULL, NULL, 'fixedAssets'),
|
(19, 'inmovilizado', NULL, NULL, 'fixedAssets'),
|
||||||
(20, 'Reclamación', 1, 1, 'claim'),
|
(20, 'Reclamación', 1, 1, 'claim'),
|
||||||
(21, 'Entrada', 1, 1, 'entry');
|
(21, 'Entrada', 1, 1, 'entry'),
|
||||||
|
(22, 'Proveedor', 1, 1, 'supplier');
|
||||||
|
|
||||||
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
|
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2412,7 +2413,8 @@ INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `wa
|
||||||
(6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()),
|
(6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()),
|
||||||
(7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
|
(7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
|
||||||
(8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
|
(8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
|
||||||
(9, 21, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'ENTRADA ID 1', util.VN_CURDATE());
|
(9, 21, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'ENTRADA ID 1', util.VN_CURDATE()),
|
||||||
|
(10, 21, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'ENTRADA DE PRUEBA', util.VN_CURDATE());
|
||||||
|
|
||||||
INSERT INTO `vn`.`claimDms`(`claimFk`, `dmsFk`)
|
INSERT INTO `vn`.`claimDms`(`claimFk`, `dmsFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -3740,3 +3742,7 @@ INSERT INTO vn.parkingLog(originFk, userFk, `action`, creationDate, description,
|
||||||
|
|
||||||
INSERT INTO vn.ticketLog (originFk,userFk,`action`,creationDate,changedModel,newInstance,changedModelId,changedModelValue)
|
INSERT INTO vn.ticketLog (originFk,userFk,`action`,creationDate,changedModel,newInstance,changedModelId,changedModelValue)
|
||||||
VALUES (18,9,'insert','2001-01-01 11:01:00.000','Ticket','{"isDeleted":true}',45,'Super Man');
|
VALUES (18,9,'insert','2001-01-01 11:01:00.000','Ticket','{"isDeleted":true}',45,'Super Man');
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`supplierDms`(`supplierFk`, `dmsFk`, `editorFk`)
|
||||||
|
VALUES
|
||||||
|
(1, 10, 9);
|
|
@ -32,7 +32,7 @@ BEGIN
|
||||||
WHERE c.available > 0
|
WHERE c.available > 0
|
||||||
GROUP BY c.item_id;
|
GROUP BY c.item_id;
|
||||||
|
|
||||||
CALL vn.catalog_calculate(vDelivery, vAddress, vAgencyMode);
|
CALL vn.catalog_calculate(vDelivery, vAddress, vAgencyMode, FALSE);
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.item;
|
DROP TEMPORARY TABLE tmp.item;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -16,7 +16,7 @@ BEGIN
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT vSelf itemFk;
|
SELECT vSelf itemFk;
|
||||||
|
|
||||||
CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
|
CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, FALSE);
|
||||||
|
|
||||||
SELECT l.warehouseFk, w.name warehouse,
|
SELECT l.warehouseFk, w.name warehouse,
|
||||||
p.`grouping`, p.price, p.rate, l.available
|
p.`grouping`, p.price, p.rate, l.available
|
||||||
|
|
|
@ -27,7 +27,7 @@ BEGIN
|
||||||
WHERE orderFk = vSelf
|
WHERE orderFk = vSelf
|
||||||
GROUP BY itemFk;
|
GROUP BY itemFk;
|
||||||
|
|
||||||
CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode);
|
CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, FALSE);
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.item;
|
DROP TEMPORARY TABLE tmp.item;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -22,7 +22,7 @@ BEGIN
|
||||||
FROM `order`
|
FROM `order`
|
||||||
WHERE id = vSelf;
|
WHERE id = vSelf;
|
||||||
|
|
||||||
CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode);
|
CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, FALSE);
|
||||||
|
|
||||||
IF account.myUser_getName() = 'visitor' THEN
|
IF account.myUser_getName() = 'visitor' THEN
|
||||||
UPDATE tmp.ticketCalculateItem
|
UPDATE tmp.ticketCalculateItem
|
||||||
|
|
|
@ -20,6 +20,7 @@ BEGIN
|
||||||
|
|
||||||
CALL vn.addressTaxArea();
|
CALL vn.addressTaxArea();
|
||||||
SELECT areaFk INTO vTaxArea FROM tmp.addressTaxArea;
|
SELECT areaFk INTO vTaxArea FROM tmp.addressTaxArea;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
DROP TEMPORARY TABLE
|
||||||
tmp.addressCompany,
|
tmp.addressCompany,
|
||||||
tmp.addressTaxArea;
|
tmp.addressTaxArea;
|
||||||
|
|
|
@ -20,7 +20,7 @@ BEGIN
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT vItemFk itemFk;
|
SELECT vItemFk itemFk;
|
||||||
|
|
||||||
CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
|
CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, TRUE);
|
||||||
DROP TEMPORARY TABLE tmp.item;
|
DROP TEMPORARY TABLE tmp.item;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`catalog_calculate`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`catalog_calculate`(
|
||||||
|
vLanded DATE,
|
||||||
|
vAddressFk INT,
|
||||||
|
vAgencyModeFk INT,
|
||||||
|
vShowExpiredZones BOOLEAN)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcula los articulos disponibles y sus precios
|
* Calcula los articulos disponibles y sus precios
|
||||||
|
@ -25,7 +29,7 @@ BEGIN
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE);
|
CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones);
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
||||||
CREATE TEMPORARY TABLE tmp.ticketLot(
|
CREATE TEMPORARY TABLE tmp.ticketLot(
|
||||||
|
|
|
@ -77,7 +77,9 @@ BEGIN
|
||||||
vNewItemFk);
|
vNewItemFk);
|
||||||
|
|
||||||
SELECT price INTO vNewPrice
|
SELECT price INTO vNewPrice
|
||||||
FROM tmp.ticketCalculateItem;
|
FROM tmp.ticketComponentPrice
|
||||||
|
ORDER BY (vQuantity % `grouping`) ASC
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
IF vNewPrice IS NULL THEN
|
IF vNewPrice IS NULL THEN
|
||||||
CALL util.throw('price retrieval failed');
|
CALL util.throw('price retrieval failed');
|
||||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
||||||
SELECT id itemFk FROM vn.item
|
SELECT id itemFk FROM vn.item
|
||||||
WHERE typeFk = vTypeFk;
|
WHERE typeFk = vTypeFk;
|
||||||
|
|
||||||
CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
|
CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, FALSE);
|
||||||
DROP TEMPORARY TABLE tmp.item;
|
DROP TEMPORARY TABLE tmp.item;
|
||||||
DROP TEMPORARY TABLE tmp.ticketLot;
|
DROP TEMPORARY TABLE tmp.ticketLot;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -23,9 +23,5 @@ BEGIN
|
||||||
CALL buy_checkItem();
|
CALL buy_checkItem();
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN
|
|
||||||
CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries');
|
|
||||||
END IF;
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -32,5 +32,9 @@ BEGIN
|
||||||
CALL util.throw('The travel has entries with booked invoices');
|
CALL util.throw('The travel has entries with booked invoices');
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN
|
||||||
|
CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries');
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES('SupplierDms', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -126,5 +126,20 @@
|
||||||
"allowedContentTypes": [
|
"allowedContentTypes": [
|
||||||
"application/x-7z-compressed"
|
"application/x-7z-compressed"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"supplierStorage": {
|
||||||
|
"name": "supplierStorage",
|
||||||
|
"connector": "loopback-component-storage",
|
||||||
|
"provider": "filesystem",
|
||||||
|
"root": "./storage/dms",
|
||||||
|
"maxFileSize": "31457280",
|
||||||
|
"allowedContentTypes": [
|
||||||
|
"image/png",
|
||||||
|
"image/jpeg",
|
||||||
|
"image/jpg",
|
||||||
|
"image/webp",
|
||||||
|
"video/mp4",
|
||||||
|
"application/pdf"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,15 +23,16 @@ export default class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
openPdf() {
|
openPdf() {
|
||||||
|
const access_token = this.vnToken.tokenMultimedia;
|
||||||
if (this.checked.length <= 1) {
|
if (this.checked.length <= 1) {
|
||||||
const [invoiceOutId] = this.checked;
|
const [invoiceOutId] = this.checked;
|
||||||
const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${this.vnToken.tokenMultimedia}`;
|
const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${access_token}`;
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
} else {
|
} else {
|
||||||
const invoiceOutIds = this.checked;
|
const invoiceOutIds = this.checked;
|
||||||
const invoicesIds = invoiceOutIds.join(',');
|
const invoicesIds = invoiceOutIds.join(',');
|
||||||
const serializedParams = this.$httpParamSerializer({
|
const serializedParams = this.$httpParamSerializer({
|
||||||
access_token: this.vnToken.token,
|
access_token,
|
||||||
ids: invoicesIds
|
ids: invoicesIds
|
||||||
});
|
});
|
||||||
const url = `api/InvoiceOuts/downloadZip?${serializedParams}`;
|
const url = `api/InvoiceOuts/downloadZip?${serializedParams}`;
|
||||||
|
|
|
@ -20,7 +20,6 @@ import './botanical';
|
||||||
import './barcode';
|
import './barcode';
|
||||||
import './summary';
|
import './summary';
|
||||||
import './waste/index/';
|
import './waste/index/';
|
||||||
import './waste/detail';
|
|
||||||
import './fixed-price';
|
import './fixed-price';
|
||||||
import './fixed-price-search-panel';
|
import './fixed-price-search-panel';
|
||||||
import './item-type';
|
import './item-type';
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
<vn-crud-model auto-load="true"
|
|
||||||
vn-id="model"
|
|
||||||
url="Items/getWasteByItem"
|
|
||||||
params="$ctrl.$params"
|
|
||||||
data="details">
|
|
||||||
</vn-crud-model>
|
|
||||||
<vn-data-viewer model="model">
|
|
||||||
<vn-card class="vn-w-md">
|
|
||||||
<section ng-repeat="detail in details" class="vn-pa-md">
|
|
||||||
<vn-horizontal class="header">
|
|
||||||
<h5>{{detail.family}} ({{detail.buyer}})</h5>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-table>
|
|
||||||
<vn-thead>
|
|
||||||
<vn-tr>
|
|
||||||
<vn-th shrink>Item</vn-th>
|
|
||||||
<vn-th number>Percentage</vn-th>
|
|
||||||
<vn-th number>Dwindle</vn-th>
|
|
||||||
<vn-th number>Total</vn-th>
|
|
||||||
</vn-tr>
|
|
||||||
</vn-thead>
|
|
||||||
<vn-tbody>
|
|
||||||
<vn-tr ng-repeat="waste in detail.lines">
|
|
||||||
<vn-td shrink>
|
|
||||||
<span
|
|
||||||
ng-click="itemDescriptor.show($event, waste.itemFk)"
|
|
||||||
class="link">
|
|
||||||
{{::waste.itemFk}}
|
|
||||||
</span>
|
|
||||||
</vn-td>
|
|
||||||
<vn-td number>{{::(waste.percentage / 100) | percentage: 2}}</vn-td>
|
|
||||||
<vn-td number>{{::waste.dwindle | currency: 'EUR'}}</vn-td>
|
|
||||||
<vn-td number>{{::waste.total | currency: 'EUR'}}</vn-td>
|
|
||||||
</vn-tr>
|
|
||||||
</vn-tbody>
|
|
||||||
</vn-table>
|
|
||||||
</section>
|
|
||||||
</vn-card>
|
|
||||||
</vn-data-viewer>
|
|
||||||
<vn-item-descriptor-popover
|
|
||||||
vn-id="item-descriptor"
|
|
||||||
warehouse-fk="$ctrl.vnConfig.warehouseFk">
|
|
||||||
</vn-item-descriptor-popover>
|
|
|
@ -1,7 +0,0 @@
|
||||||
import ngModule from '../../module';
|
|
||||||
import Section from 'salix/components/section';
|
|
||||||
|
|
||||||
ngModule.vnComponent('vnItemWasteDetail', {
|
|
||||||
template: require('./index.html'),
|
|
||||||
controller: Section
|
|
||||||
});
|
|
|
@ -1,25 +0,0 @@
|
||||||
@import "variables";
|
|
||||||
|
|
||||||
vn-item-waste {
|
|
||||||
.header {
|
|
||||||
margin-bottom: 16px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-size: 1.25rem;
|
|
||||||
line-height: 1;
|
|
||||||
padding: 7px;
|
|
||||||
padding-bottom: 7px;
|
|
||||||
padding-bottom: 4px;
|
|
||||||
font-weight: lighter;
|
|
||||||
background-color: #fde6ca;
|
|
||||||
border-bottom: 1px solid #f7931e;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
vn-table vn-th.waste-family,
|
|
||||||
vn-table vn-td.waste-family {
|
|
||||||
max-width: 64px;
|
|
||||||
width: 64px
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +1,2 @@
|
||||||
<vn-crud-model auto-load="true"
|
<vn-card>
|
||||||
vn-id="model"
|
</vn-card>
|
||||||
url="Items/getWasteByWorker"
|
|
||||||
data="details">
|
|
||||||
</vn-crud-model>
|
|
||||||
<vn-data-viewer model="model">
|
|
||||||
<vn-card>
|
|
||||||
<vn-table>
|
|
||||||
<vn-thead>
|
|
||||||
<vn-tr class="header">
|
|
||||||
<vn-th class="waste-family">Buyer</vn-th>
|
|
||||||
<vn-th class="waste-family">Family</vn-th>
|
|
||||||
<vn-th number>Percentage</vn-th>
|
|
||||||
<vn-th number>Dwindle</vn-th>
|
|
||||||
<vn-th number>Total</vn-th>
|
|
||||||
<vn-th shrink></vn-th>
|
|
||||||
</vn-tr>
|
|
||||||
</vn-thead>
|
|
||||||
<vn-tbody ng-repeat="detail in details" class="vn-mb-md">
|
|
||||||
<vn-tr class="header">
|
|
||||||
<vn-td>{{::detail.buyer}}</vn-td>
|
|
||||||
<vn-td>{{::detail.family}}</vn-td>
|
|
||||||
<vn-td number>{{::(detail.percentage / 100) | percentage: 2}}</vn-td>
|
|
||||||
<vn-td number>{{::detail.dwindle | currency: 'EUR'}}</vn-td>
|
|
||||||
<vn-td number>{{::detail.total | currency: 'EUR'}}</vn-td>
|
|
||||||
<vn-td shrink>
|
|
||||||
<vn-icon-button
|
|
||||||
ng-class="{'hidden': !$ctrl.wasteConfig[detail.buyer].hidden}"
|
|
||||||
class="arrow pointer"
|
|
||||||
icon="keyboard_arrow_up"
|
|
||||||
vn-tooltip="Minimize/Maximize"
|
|
||||||
ng-click="$ctrl.toggleHidePanel(detail)">
|
|
||||||
</vn-icon-button>
|
|
||||||
</vn-td>
|
|
||||||
</vn-tr>
|
|
||||||
<a ng-repeat="waste in detail.lines" class="clickable vn-tr"
|
|
||||||
ui-sref="item.waste.detail({buyer: waste.buyer, family: waste.family})"
|
|
||||||
ng-show="$ctrl.wasteConfig[detail.buyer].hidden">
|
|
||||||
<vn-td></vn-td>
|
|
||||||
<vn-td>{{::waste.family}}</vn-td>
|
|
||||||
<vn-td number>{{::(waste.percentage / 100) | percentage: 2}}</vn-td>
|
|
||||||
<vn-td number>{{::waste.dwindle | currency: 'EUR'}}</vn-td>
|
|
||||||
<vn-td number>{{::waste.total | currency: 'EUR'}}</vn-td>
|
|
||||||
<vn-td shrink></vn-td>
|
|
||||||
</a>
|
|
||||||
</vn-tbody>
|
|
||||||
</vn-table>
|
|
||||||
</vn-card>
|
|
||||||
</vn-data-viewer>
|
|
||||||
|
|
|
@ -5,27 +5,11 @@ import './style.scss';
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
|
|
||||||
this.getWasteConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getWasteConfig() {
|
async $onInit() {
|
||||||
return this.wasteConfig = JSON.parse(localStorage.getItem('wasteConfig')) || {};
|
this.$state.go('item.index');
|
||||||
}
|
window.location.href = 'https://grafana.verdnatura.es/d/TTNXQAxVk';
|
||||||
|
|
||||||
setWasteConfig() {
|
|
||||||
localStorage.setItem('wasteConfig', JSON.stringify(this.wasteConfig));
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleHidePanel(detail) {
|
|
||||||
if (!this.wasteConfig[detail.buyer]) {
|
|
||||||
this.wasteConfig[detail.buyer] = {
|
|
||||||
hidden: true
|
|
||||||
};
|
|
||||||
} else
|
|
||||||
this.wasteConfig[detail.buyer].hidden = !this.wasteConfig[detail.buyer].hidden;
|
|
||||||
|
|
||||||
this.setWasteConfig();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
import './index.js';
|
|
||||||
import crudModel from 'core/mocks/crud-model';
|
|
||||||
|
|
||||||
describe('Item', () => {
|
|
||||||
describe('Component vnItemWasteIndex', () => {
|
|
||||||
let $scope;
|
|
||||||
let controller;
|
|
||||||
|
|
||||||
beforeEach(ngModule('item'));
|
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $rootScope) => {
|
|
||||||
$scope = $rootScope.$new();
|
|
||||||
$scope.model = crudModel;
|
|
||||||
const $element = angular.element('<vn-item-waste-index></vn-item-waste-index>');
|
|
||||||
controller = $componentController('vnItemWasteIndex', {$element, $scope});
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('getWasteConfig / setWasteConfig', () => {
|
|
||||||
it('should return the local storage wasteConfig', () => {
|
|
||||||
const result = controller.getWasteConfig();
|
|
||||||
|
|
||||||
expect(result).toEqual({});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set and return the local storage wasteConfig', () => {
|
|
||||||
controller.wasteConfig = {salesPerson: {hidden: true}};
|
|
||||||
controller.setWasteConfig();
|
|
||||||
|
|
||||||
const result = controller.getWasteConfig();
|
|
||||||
|
|
||||||
expect(result).toEqual(controller.wasteConfig);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('toggleHidePanel()', () => {
|
|
||||||
it('should make details hidden by default', () => {
|
|
||||||
controller.wasteConfig = {};
|
|
||||||
|
|
||||||
controller.toggleHidePanel({buyer: 'salesPerson'});
|
|
||||||
|
|
||||||
expect(controller.wasteConfig.salesPerson.hidden).toEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should toggle hidden false', () => {
|
|
||||||
controller.wasteConfig = {salesPerson: {hidden: true}};
|
|
||||||
|
|
||||||
controller.toggleHidePanel({buyer: 'salesPerson'});
|
|
||||||
|
|
||||||
expect(controller.wasteConfig.salesPerson.hidden).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -92,10 +92,11 @@ module.exports = Self => {
|
||||||
// Calculate items
|
// Calculate items
|
||||||
const order = await Self.findById(orderFk, null, myOptions);
|
const order = await Self.findById(orderFk, null, myOptions);
|
||||||
stmts.push(new ParameterizedSQL(
|
stmts.push(new ParameterizedSQL(
|
||||||
'CALL vn.catalog_calculate(?, ?, ?)', [
|
'CALL vn.catalog_calculate(?, ?, ?, ?)', [
|
||||||
order.landed,
|
order.landed,
|
||||||
order.address_id,
|
order.address_id,
|
||||||
order.agency_id,
|
order.agency_id,
|
||||||
|
false
|
||||||
]
|
]
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -64,10 +64,11 @@ module.exports = Self => {
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(
|
stmt = new ParameterizedSQL(
|
||||||
'CALL vn.catalog_calculate(?, ?, ?)', [
|
'CALL vn.catalog_calculate(?, ?, ?,?)', [
|
||||||
order.landed,
|
order.landed,
|
||||||
order.addressFk,
|
order.addressFk,
|
||||||
order.agencyModeFk,
|
order.agencyModeFk,
|
||||||
|
false
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
|
@ -35,16 +35,18 @@ export default class Controller extends Section {
|
||||||
|
|
||||||
showRouteReport() {
|
showRouteReport() {
|
||||||
const routesIds = [];
|
const routesIds = [];
|
||||||
|
const access_token = this.vnToken.tokenMultimedia;
|
||||||
|
|
||||||
for (let route of this.checked)
|
for (let route of this.checked)
|
||||||
routesIds.push(route.id);
|
routesIds.push(route.id);
|
||||||
const stringRoutesIds = routesIds.join(',');
|
const stringRoutesIds = routesIds.join(',');
|
||||||
|
|
||||||
if (this.checked.length <= 1) {
|
if (this.checked.length <= 1) {
|
||||||
const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.tokenMultimedia}`;
|
const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${access_token}`;
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
} else {
|
} else {
|
||||||
const serializedParams = this.$httpParamSerializer({
|
const serializedParams = this.$httpParamSerializer({
|
||||||
access_token: this.vnToken.token,
|
access_token,
|
||||||
id: stringRoutesIds
|
id: stringRoutesIds
|
||||||
});
|
});
|
||||||
const url = `api/Routes/downloadZip?${serializedParams}`;
|
const url = `api/Routes/downloadZip?${serializedParams}`;
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('downloadFile', {
|
||||||
|
description: 'Get the supplier file',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'Number',
|
||||||
|
description: 'The file id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: [
|
||||||
|
{
|
||||||
|
arg: 'body',
|
||||||
|
type: 'file',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'Content-Type',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'Content-Disposition',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: `/:id/downloadFile`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.downloadFile = async function(ctx, id) {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const SupplierContainer = models.SupplierContainer;
|
||||||
|
const dms = await models.Dms.findById(id);
|
||||||
|
const pathHash = SupplierContainer.getHash(dms.id);
|
||||||
|
try {
|
||||||
|
await SupplierContainer.getFile(pathHash, dms.file);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.code != 'ENOENT')
|
||||||
|
throw e;
|
||||||
|
|
||||||
|
const error = new UserError(`File doesn't exists`);
|
||||||
|
error.statusCode = 404;
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const stream = SupplierContainer.downloadStream(pathHash, dms.file);
|
||||||
|
|
||||||
|
return [stream, dms.contentType, `filename="${dms.file}"`];
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,53 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('removeFile', {
|
||||||
|
description: 'Removes a entry document',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: {
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
description: 'The file id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
},
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/removeFile`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.removeFile = async(ctx, id, options) => {
|
||||||
|
const myOptions = {};
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const targetSupplierDms = await Self.findById(id, null, myOptions);
|
||||||
|
const targetDms = await Self.app.models.Dms.removeFile(ctx, targetSupplierDms.dmsFk, myOptions);
|
||||||
|
|
||||||
|
if (!targetDms)
|
||||||
|
throw new UserError('Try again');
|
||||||
|
|
||||||
|
const supplierDmsDestroyed = await targetSupplierDms.destroy(myOptions);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
return supplierDmsDestroyed;
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('uploadFile', {
|
||||||
|
description: 'Upload and attach a file',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
description: 'The supplier id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'warehouseId',
|
||||||
|
type: 'number',
|
||||||
|
description: 'The warehouse id',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'companyId',
|
||||||
|
type: 'number',
|
||||||
|
description: 'The company id',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'dmsTypeId',
|
||||||
|
type: 'number',
|
||||||
|
description: 'The dms type id',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'reference',
|
||||||
|
type: 'string',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'description',
|
||||||
|
type: 'string',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'hasFile',
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'True if has an attached file',
|
||||||
|
required: true
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/uploadFile`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.uploadFile = async(ctx, id, options) => {
|
||||||
|
const {Dms, SupplierDms} = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const uploadedFiles = await Dms.uploadFile(ctx, myOptions);
|
||||||
|
|
||||||
|
const promises = uploadedFiles.map(dms => SupplierDms.create({
|
||||||
|
supplierFk: id,
|
||||||
|
dmsFk: dms.id
|
||||||
|
}, myOptions));
|
||||||
|
await Promise.all(promises);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
return uploadedFiles;
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -5,6 +5,12 @@
|
||||||
"Supplier": {
|
"Supplier": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"SupplierDms": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"SupplierContainer": {
|
||||||
|
"dataSource": "supplierStorage"
|
||||||
|
},
|
||||||
"SupplierAddress": {
|
"SupplierAddress": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"name": "SupplierContainer",
|
||||||
|
"base": "Container",
|
||||||
|
"acls": [{
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}]
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
require('../methods/supplier/supplier-dms/removeFile')(Self);
|
||||||
|
require('../methods/supplier/supplier-dms/downloadFile')(Self);
|
||||||
|
require('../methods/supplier/supplier-dms/uploadFile')(Self);
|
||||||
|
|
||||||
|
Self.rewriteDbError(function(err) {
|
||||||
|
if (err.code === 'ER_DUP_ENTRY')
|
||||||
|
return new UserError(`The file is already attached to another entry`);
|
||||||
|
return err;
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"name": "SupplierDms",
|
||||||
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "supplierDms"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"allowedContentTypes": [
|
||||||
|
"image/png",
|
||||||
|
"image/jpeg",
|
||||||
|
"image/jpg",
|
||||||
|
"application/pdf"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"dmsFk": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true,
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"supplier": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Supplier",
|
||||||
|
"foreignKey": "supplierFk"
|
||||||
|
},
|
||||||
|
"dms": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Dms",
|
||||||
|
"foreignKey": "dmsFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('hasUncheckedTicket', {
|
||||||
|
description:
|
||||||
|
'Get boolean if the collection of ticket has a ticket not checked',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'ticketFk',
|
||||||
|
type: 'integer',
|
||||||
|
required: true,
|
||||||
|
description: 'Ticket id'
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'boolean',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/hasUncheckedTicket`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.hasUncheckedTicket = async(ticketFk, options) => {
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const result = await Self.rawSql(`
|
||||||
|
SELECT tc2.ticketFk
|
||||||
|
FROM vn.ticketCollection tc
|
||||||
|
JOIN vn.ticketCollection tc2 ON tc2.collectionFk = tc.collectionFk
|
||||||
|
LEFT JOIN vn.ticketState ts ON ts.ticketFk = tc2.ticketFk
|
||||||
|
JOIN vn.state s ON s.id = ts.stateFk
|
||||||
|
JOIN vn.state s2 ON s2.code = 'CHECKED'
|
||||||
|
WHERE tc.ticketFk = ? AND s.order < s2.id
|
||||||
|
LIMIT 1;`,
|
||||||
|
[ticketFk], myOptions);
|
||||||
|
return result.length > 0 && result[0]['ticketFk'] > 0;
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('ticketCollection hasUncheckedTicket()', () => {
|
||||||
|
it('should return false because there are not tickets not checked', async() => {
|
||||||
|
const ticketFk = 1;
|
||||||
|
const result = await models.TicketCollection.hasUncheckedTicket(ticketFk);
|
||||||
|
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true because there is a ticket not checked', async() => {
|
||||||
|
const ticketFk = 1;
|
||||||
|
const stateFkCurrent = 16;
|
||||||
|
const stateFkUpdated = 7;
|
||||||
|
|
||||||
|
const tx = await models.TicketTracking.beginTransaction({});
|
||||||
|
const myOptions = {transaction: tx};
|
||||||
|
const filter = {where: {
|
||||||
|
ticketFk: 1,
|
||||||
|
stateFk: stateFkCurrent}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const ticketTracking = await models.TicketTracking.findOne(filter, myOptions);
|
||||||
|
await ticketTracking.updateAttributes({
|
||||||
|
stateFk: stateFkUpdated
|
||||||
|
}, myOptions);
|
||||||
|
const result = await models.TicketCollection.hasUncheckedTicket(ticketFk, myOptions);
|
||||||
|
|
||||||
|
expect(result).toBe(true);
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
require('../methods/ticket-collection/hasUncheckedTicket')(Self);
|
||||||
|
};
|
|
@ -13,6 +13,9 @@
|
||||||
},
|
},
|
||||||
"usedShelves": {
|
"usedShelves": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"collectionFk": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
@ -20,6 +23,11 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Ticket",
|
"model": "Ticket",
|
||||||
"foreignKey": "ticketFk"
|
"foreignKey": "ticketFk"
|
||||||
|
},
|
||||||
|
"collection": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Collection",
|
||||||
|
"foreignKey": "collectionFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -71,6 +71,34 @@ describe('workerTimeControl clockIn()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should updates the time entry direction and remaining not be manual', async() => {
|
||||||
|
activeCtx.accessToken.userId = HHRRId;
|
||||||
|
const workerId = teamBossId;
|
||||||
|
|
||||||
|
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const entryTime = "2000-12-25T11:00:00.000Z";
|
||||||
|
ctx.args = {timed: entryTime, direction: 'in'};
|
||||||
|
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||||
|
|
||||||
|
const middleTime ="2000-12-25T16:00:00.000Z";
|
||||||
|
ctx.args = {timed: middleTime, direction: 'middle'};
|
||||||
|
const middleEntryTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||||
|
middleEntryTime.updateAttribute('manual', false);
|
||||||
|
|
||||||
|
const direction = 'out';
|
||||||
|
const outTimeEntryId = await models.WorkerTimeControl.updateTimeEntry(ctx, middleEntryTime.id, direction, options);
|
||||||
|
|
||||||
|
const outTimeEntry = await models.WorkerTimeControl.findById(outTimeEntryId, null, options);
|
||||||
|
expect(outTimeEntry.manual).toBeFalsy();
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
describe('as Role errors', () => {
|
describe('as Role errors', () => {
|
||||||
it('should add if the current user is team boss and the target user is himself', async() => {
|
it('should add if the current user is team boss and the target user is himself', async() => {
|
||||||
activeCtx.accessToken.userId = teamBossId;
|
activeCtx.accessToken.userId = teamBossId;
|
||||||
|
@ -144,7 +172,7 @@ describe('workerTimeControl clockIn()', () => {
|
||||||
const middleTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
const middleTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||||
|
|
||||||
const direction = 'out';
|
const direction = 'out';
|
||||||
const {id:outTimeEntryId} = await models.WorkerTimeControl.updateTimeEntry(
|
const outTimeEntryId = await models.WorkerTimeControl.updateTimeEntry(
|
||||||
ctx, middleTime.id, direction, options
|
ctx, middleTime.id, direction, options
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ module.exports = Self => {
|
||||||
Self.updateTimeEntry = async(ctx, timeEntryId, direction, options) => {
|
Self.updateTimeEntry = async(ctx, timeEntryId, direction, options) => {
|
||||||
const currentUserId = ctx.req.accessToken.userId;
|
const currentUserId = ctx.req.accessToken.userId;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {userId: currentUserId};
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
|
@ -41,7 +41,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {id, userFk, timed} = await Self.findById(timeEntryId, null, myOptions);
|
const {id, userFk, timed, manual} = await Self.findById(timeEntryId, null, myOptions);
|
||||||
const isSubordinate = await models.Worker.isSubordinate(ctx, userFk, myOptions);
|
const isSubordinate = await models.Worker.isSubordinate(ctx, userFk, myOptions);
|
||||||
const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE');
|
const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE');
|
||||||
const isHimself = currentUserId == userFk;
|
const isHimself = currentUserId == userFk;
|
||||||
|
@ -50,12 +50,15 @@ module.exports = Self => {
|
||||||
if (notAllowed) throw new UserError(`You don't have enough privileges`);
|
if (notAllowed) throw new UserError(`You don't have enough privileges`);
|
||||||
|
|
||||||
await models.WorkerTimeControl.deleteById(id, myOptions);
|
await models.WorkerTimeControl.deleteById(id, myOptions);
|
||||||
const timeEntryUpdatedId = await Self.clockIn(userFk, timed, direction, null, myOptions);
|
const {id: newTimeEntryId} = await Self.clockIn(
|
||||||
|
userFk, timed, direction, null, myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!manual) await Self.updateAll({id: newTimeEntryId}, {manual: false}, myOptions);
|
||||||
await models.WorkerTimeControl.resendWeeklyHourEmail(ctx, userFk, timed, myOptions);
|
await models.WorkerTimeControl.resendWeeklyHourEmail(ctx, userFk, timed, myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
return timeEntryUpdatedId;
|
return newTimeEntryId;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
</table>
|
</table>
|
||||||
<p v-html="$t('wasteDetailLink')"></p>
|
<p v-html="$t('wasteDetailLink')"></p>
|
||||||
<div class="external-link vn-pa-sm vn-m-md">
|
<div class="external-link vn-pa-sm vn-m-md">
|
||||||
<a href="https://salix.verdnatura.es/#!/item/waste/index" target="_blank">
|
<a href="https://grafana.verdnatura.es/d/TTNXQAxVk" target="_blank">
|
||||||
https://salix.verdnatura.es/#!/item/waste/index
|
https://grafana.verdnatura.es/d/TTNXQAxVk
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue