This commit is contained in:
Gerard 2019-02-25 10:10:47 +01:00
commit 2872dcdd3e
24 changed files with 795 additions and 1095 deletions

View File

@ -93,7 +93,7 @@ export default class Calendar extends Component {
} }
applyOffset(date) { applyOffset(date) {
date.setTime(date.getTime() - date.getTimezoneOffset() * 60000); // date.setTime(date.getTime() - date.getTimezoneOffset() * 60000);
} }
repaint() { repaint() {

View File

@ -3,6 +3,7 @@
<div class="textField"> <div class="textField">
<div class="leftIcons"> <div class="leftIcons">
<vn-icon-button <vn-icon-button
ng-if="::$ctrl.step"
icon="remove" icon="remove"
ng-click="$ctrl.remove()" ng-click="$ctrl.remove()"
tabindex="-1" tabindex="-1"
@ -13,7 +14,7 @@
<input <input
class="mdl-textfield__input" class="mdl-textfield__input"
type="number" type="number"
name="{{$ctrl.name}}" name="{{::$ctrl.name}}"
ng-model="$ctrl.value" ng-model="$ctrl.value"
ng-disabled="$ctrl.disabled" ng-disabled="$ctrl.disabled"
ng-readonly="$ctrl.readonly" ng-readonly="$ctrl.readonly"
@ -26,14 +27,15 @@
<div class="selected underline"></div> <div class="selected underline"></div>
<div class="suffix"> <div class="suffix">
<vn-icon-button <vn-icon-button
ng-if="::$ctrl.step"
icon="add" icon="add"
ng-click="$ctrl.add()" ng-click="$ctrl.add()"
tabindex="-1" tabindex="-1"
translate-attr="{title: 'Add'}"> translate-attr="{title: 'Add'}">
</vn-icon-button> </vn-icon-button>
<i class="material-icons" <i class="material-icons"
ng-if="$ctrl.hasInfo" ng-if="::$ctrl.hasInfo"
vn-tooltip="{{$ctrl.info}}"> vn-tooltip="{{::$ctrl.info}}">
info_outline info_outline
</i> </i>
</div> </div>

View File

@ -3,7 +3,6 @@ import Textfield from '../textfield/textfield';
import './style.scss'; import './style.scss';
export default class InputNumber extends Textfield { export default class InputNumber extends Textfield {
constructor($element, $scope, $attrs, vnTemplate, $transclude) { constructor($element, $scope, $attrs, vnTemplate, $transclude) {
super($element, $scope, $attrs, vnTemplate, $transclude); super($element, $scope, $attrs, vnTemplate, $transclude);
@ -56,30 +55,30 @@ export default class InputNumber extends Textfield {
if ((this.validate() !== undefined && !this.validate()) || if ((this.validate() !== undefined && !this.validate()) ||
(this.max && this.value > this.max) || (this.max && this.value > this.max) ||
(this.min && this.value < this.min) || (this.min && this.value < this.min) ||
(this.step && this.value % this.step != 0)) { (this.step && this.value % this.step != 0))
this.$element[0].querySelector('.infix').classList.add('invalid', 'validated'); this.$element[0].querySelector('.infix').classList.add('invalid', 'validated');
}
if (this.onChange) if (this.onChange)
this.onChange(); this.onChange();
} }
add() { add() {
if (this.step && this.value % this.step != 0) { if (this.step && this.value % this.step != 0)
this.value += (this.step - this.value % this.step); this.value += (this.step - this.value % this.step);
} else { else
this.value += this.step; this.value += this.step;
}
this.validateValue(); this.validateValue();
} }
remove() { remove() {
if (this.step && this.value % this.step != 0) { if (this.step && this.value % this.step != 0)
this.value -= (this.step + this.value % this.step); this.value -= (this.step + this.value % this.step);
} else { else
this.value -= this.step; this.value -= this.step;
}
this.validateValue(); this.validateValue();
} }
} }

View File

@ -24,6 +24,18 @@ class VnMySQL extends MySQL {
} }
} }
fromColumnValue(prop, val) {
if (val == null || !prop || prop.type !== Date)
return MySQL.prototype.fromColumnValue.call(this, prop, val);
let date = new Date(val);
let locale = new Date(val);
let offset = locale.getTimezoneOffset() * 60000;
date.setTime(date.getTime() + offset);
return date;
}
/** /**
* Promisified version of execute(). * Promisified version of execute().
* *
@ -34,6 +46,16 @@ class VnMySQL extends MySQL {
* @return {Promise} The operation promise * @return {Promise} The operation promise
*/ */
executeP(query, params, options = {}, cb) { executeP(query, params, options = {}, cb) {
if (params) {
for (let param of params) {
if (param && typeof param.getMonth === 'function') {
let locale = new Date(param);
let offset = locale.getTimezoneOffset() * 60000;
param.setTime(param.getTime() - offset);
}
}
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.execute(query, params, options, (error, response) => { this.execute(query, params, options, (error, response) => {
if (cb) if (cb)
@ -230,11 +252,12 @@ exports.initialize = function initialize(dataSource, callback) {
dataSource.EnumFactory = EnumFactory; dataSource.EnumFactory = EnumFactory;
if (callback) if (callback) {
if (dataSource.settings.lazyConnect) { if (dataSource.settings.lazyConnect) {
process.nextTick(function() { process.nextTick(function() {
callback(); callback();
}); });
} else } else
dataSource.connector.connect(callback); dataSource.connector.connect(callback);
}
}; };

View File

@ -17,7 +17,9 @@ class Controller {
this.ndMonth = this.$scope.ndMonth; this.ndMonth = this.$scope.ndMonth;
} }
get zone() { // Disabled until implementation
// of holidays by node
/* get zone() {
return this._zone; return this._zone;
} }
@ -41,7 +43,7 @@ class Controller {
this.events = this.events.concat(events); this.events = this.events.concat(events);
}); });
} } */
get data() { get data() {
return this._data; return this._data;

View File

@ -51,14 +51,12 @@
<vn-input-number vn-one <vn-input-number vn-one
label="Price" label="Price"
field="$ctrl.zone.price" field="$ctrl.zone.price"
min="0.00" min="0.00">
step="0.50">
</vn-input-number> </vn-input-number>
<vn-input-number vn-one <vn-input-number vn-one
label="Bonus" label="Bonus"
field="$ctrl.zone.bonus" field="$ctrl.zone.bonus"
min="0.00" min="0.00">
step="0.50">
</vn-input-number> </vn-input-number>
</vn-horizontal> </vn-horizontal>
</vn-card> </vn-card>

View File

@ -23,12 +23,13 @@ class Controller {
} }
onSelection(item, isIncluded) { onSelection(item, isIncluded) {
item.isIncluded = isIncluded; let node = Object.assign({}, item);
const path = '/agency/api/ZoneIncludeds/toggleIsIncluded'; node.isIncluded = isIncluded;
const params = {zoneFk: this.zone.id, item}; node.childs = []; // Data too large
this.$http.post(path, params).then(() => {
}); const path = '/agency/api/ZoneIncludeds/toggleIsIncluded';
const params = {zoneFk: this.zone.id, item: node};
this.$http.post(path, params);
} }
} }

View File

@ -10,7 +10,7 @@
<vn-card> <vn-card>
<vn-horizontal class="catalog-header" pad-medium-h> <vn-horizontal class="catalog-header" pad-medium-h>
<vn-one> <vn-one>
<div> <!-- ng-if="model.moreRows" --> <div ng-if="model.moreRows">
<span translate>More than</span> {{model.limit}} <span translate>results</span> <span translate>More than</span> {{model.limit}} <span translate>results</span>
</div> </div>
</vn-one> </vn-one>

View File

@ -1,4 +0,0 @@
CREATE TABLE `vn`.`localLog` (
`id` INT NOT NULL AUTO_INCREMENT,
`ticketFk` VARCHAR(45) NULL,
PRIMARY KEY (`id`));

View File

@ -1,21 +0,0 @@
DROP TRIGGER IF EXISTS `vn2008`.`TicketsAfterUpdate`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` TRIGGER `vn2008`.`TicketsAfterUpdate`
AFTER UPDATE ON `Tickets` FOR EACH ROW
BEGIN
IF NEW.Id_Ruta IS NULL AND OLD.Id_Ruta IS NOT NULL THEN
INSERT INTO vn.routeLog(originFk, userFk, `action`, description)
VALUES (OLD.Id_Ruta, account.userGetId(), 'update', CONCAT('Saca el ticket ', OLD.Id_Ticket, ' de la ruta'));
ELSEIF NOT (NEW.Id_Ruta <=> OLD.Id_Ruta) THEN
INSERT INTO vn.routeLog(originFk, userFk, `action`, description)
VALUES (NEW.Id_Ruta, account.userGetId(), 'update', CONCAT('Añade el ticket ', OLD.Id_Ticket, ' a la ruta'));
END IF;
CALL stock.queueAdd ('ticket', NEW.Id_Ticket, OLD.Id_Ticket);
INSERT INTO vn.localLog(ticketFk)
VALUES(NEW.Id_Ticket);
END$$
DELIMITER ;

View File

@ -1,58 +0,0 @@
DROP TRIGGER IF EXISTS `vn2008`.`ClientesBeforeUpdate`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` TRIGGER `ClientesBeforeUpdate`
BEFORE UPDATE ON `Clientes`
FOR EACH ROW
BEGIN
DECLARE vText VARCHAR(255) DEFAULT NULL;
DECLARE isAlreadyUsedIf BOOLEAN;
SELECT (COUNT(*) > 1) INTO isAlreadyUsedIf
FROM Clientes
WHERE `IF` = TRIM(NEW.`IF`);
IF isAlreadyUsedIf THEN
CALL util.throw ('Error. El NIF/CIF está repetido');
END IF;
-- Comprueba que el formato de los teléfonos es válido
IF !(NEW.telefono <=> OLD.telefono) THEN
CALL pbx.phoneIsValid (NEW.telefono);
END IF;
IF !(NEW.movil <=> OLD.movil) THEN
CALL pbx.phoneIsValid (NEW.movil);
END IF;
IF !(NEW.fax <=> OLD.fax) THEN
CALL pbx.phoneIsValid (NEW.fax);
END IF;
-- Avisar al comercial si ha llegado la documentación sepa/core
IF NEW.sepavnl AND !OLD.sepavnl THEN
SET vText = 'Sepa de VNL';
END IF;
IF NEW.corevnl AND !OLD.corevnl THEN
SET vText = 'Core de VNL';
END IF;
IF vText IS NOT NULL
THEN
INSERT INTO mail(`to`, reply_to, subject, text)
SELECT
CONCAT(IF(ac.id,name, 'jgallego'), '@verdnatura.es'),
'administracion@verdnatura.es',
CONCAT('Cliente ', NEW.Id_Cliente),
CONCAT('Recibida la documentación: ', vText)
FROM Trabajadores t
LEFT JOIN account.user u ON t.user_id = u.id AND active
LEFT JOIN account.account ac ON ac.id = u.id
WHERE t.Id_Trabajador = NEW.Id_Trabajador;
END IF;
END$$
DELIMITER ;

View File

@ -1,17 +0,0 @@
USE `vn`;
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `itemType` AS
SELECT
`t`.`tipo_id` AS `id`,
`t`.`Id_Tipo` AS `code`,
`t`.`Tipo` AS `name`,
`t`.`reino_id` AS `categoryFk`,
`t`.`life` AS `life`,
`t`.`Id_Trabajador` AS `workerFk`,
`t`.`warehouseFk` AS `warehouseFk`,
`t`.`isPackaging` AS `isPackaging`
FROM
`vn2008`.`Tipos` `t`;

View File

@ -1,70 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `ticketGetTax`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetTax`()
READS SQL DATA
BEGIN
/**
* Calcula la base imponible, el IVA y el recargo de equivalencia para
* un conjunto de tickets.
*
* @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
* @return tmp.ticketTax Impuesto desglosado para cada ticket
* @return tmp.ticketAmount
*/
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
CREATE TEMPORARY TABLE tmp.addressCompany
(INDEX (addressFk, companyFk))
ENGINE = MEMORY
SELECT DISTINCT t.addressFk, t.companyFk
FROM tmp.ticket tmpTicket
JOIN ticket t ON t.id = tmpTicket.ticketFk;
CALL addressTaxArea ();
DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax;
CREATE TEMPORARY TABLE tmp.ticketTax
(INDEX (ticketFk))
ENGINE = MEMORY
SELECT tmpTicket.ticketFk,
bp.pgcFk,
ROUND(SUM(s.quantity * s.price * (100 - s.discount)/100
),2) AS taxableBase,
ROUND(SUM(s.quantity * s.price * (100 - s.discount)/100
) * pgc.rate / 100,2) AS tax,
tc.code
FROM tmp.ticket tmpTicket
JOIN sale s ON s.ticketFk = tmpTicket.ticketFk
JOIN item i ON i.id = s.itemFk
JOIN ticket t ON t.id = tmpTicket.ticketFk
JOIN supplier su ON su.id = t.companyFk
JOIN tmp.addressTaxArea ata
ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
JOIN itemTaxCountry itc
ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
JOIN bookingPlanner bp
ON bp.countryFk = su.countryFk
AND bp.taxAreaFk = ata.areaFk
AND bp.taxClassFk = itc.taxClassFk
JOIN pgc ON pgc.code = bp.pgcFk
JOIN taxClass tc ON tc.id = bp.taxClassFk
GROUP BY tmpTicket.ticketFk, pgc.code
HAVING taxableBase != 0;
DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount;
CREATE TEMPORARY TABLE tmp.ticketAmount
(INDEX (ticketFk))
ENGINE = MEMORY
SELECT ticketFk, taxableBase, SUM(tax) tax
FROM tmp.ticketTax
GROUP BY ticketFk, code;
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea;
END$$
DELIMITER ;

View File

@ -1,154 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `ticketComponentUpdateSale`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentUpdateSale`(vOption INT)
BEGIN
/**
* A partir de la tabla tmp.sale, crea los Movimientos_componentes
* y modifica el campo Preu de la tabla Movimientos
*
* @param i_option integer tipo de actualizacion
* @param table tmp.sale tabla memory con el campo Id_Movimiento, warehouse_id
**/
DECLARE vComponentFk INT;
DECLARE vRenewComponents BOOLEAN;
DECLARE vKeepPrices BOOLEAN;
CASE vOption
WHEN 1 THEN
SET vRenewComponents = TRUE;
SET vKeepPrices = FALSE;
WHEN 2 THEN
SET vComponentFk = 17;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 3 THEN
SET vComponentFk = 37;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 4 THEN
SET vComponentFk = 34;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 5 THEN
SET vComponentFk = 35;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 6 THEN
SET vComponentFk = 36;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 7 THEN
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.8, 3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
AND sc.componentFk NOT IN (28, 29)
GROUP BY s.id;
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 29, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.2, 3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
AND sc.componentFk NOT IN (28, 29)
GROUP BY s.id;
SET vRenewComponents = FALSE;
SET vKeepPrices = FALSE;
WHEN 8 THEN
DELETE sc.*
FROM tmp.sale tmps JOIN saleComponent sc ON sc.saleFk = tmps.saleFk;
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100)), 3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id;
SET vRenewComponents = FALSE;
SET vKeepPrices = FALSE;
WHEN 9 THEN
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
END CASE;
IF vRenewComponents THEN
DELETE sc.*
FROM tmp.sale tmps
JOIN saleComponent sc ON sc.saleFk = tmps.saleFk
JOIN componentRate cr ON cr.id = sc.componentFk
WHERE cr.isRenewable;
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, tc.componentFk, ROUND(tc.cost,3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
AND sc.componentFk = tc.componentFk
LEFT JOIN componentRate cr ON cr.id = tc.componentFk
WHERE IF(sc.componentFk IS NULL AND NOT cr.isRenewable, FALSE, TRUE);
END IF;
IF vKeepPrices THEN
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, vComponentFk, ROUND((s.price * (100 - s.discount) / 100) - SUM(sc.value), 3) dif
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE sc.saleFk <> vComponentFk
GROUP BY s.id
HAVING dif <> 0;
ELSE
UPDATE sale s
JOIN item i on i.id = s.itemFk
JOIN itemType it on it.id = i.typeFk
JOIN (SELECT SUM(sc.value) sumValue, sc.saleFk
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
SET s.price = sumValue
WHERE it.code != 'PRT';
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 21, ROUND((s.price * (100 - s.discount) / 100) - sum(value),3) saleValue
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE sc.componentFk != 21
GROUP BY s.id
HAVING ROUND(saleValue, 4) <> 0;
END IF;
UPDATE sale s
JOIN (
SELECT SUM(sc.value) sumValue, sc.saleFk
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
JOIN componentRate cr ON cr.id = sc.componentFk
JOIN componentTypeRate ctr on ctr.id = cr.componentTypeRate AND ctr.base
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
SET s.priceFixed = sumValue, s.isPriceFixed = 1;
DELETE sc.*
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
JOIN sale s on s.id = sc.saleFk
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
WHERE it.code = 'PRT';
INSERT INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 15, ROUND(s.price,3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
JOIN item i ON i.id = s.itemFK
JOIN itemType it ON it.id = i.typeFk
WHERE it.code = 'PRT' AND s.price > 0;
END$$
DELIMITER ;

View File

@ -1,40 +0,0 @@
DROP TRIGGER IF EXISTS `vn2008`.`CompresAfterInsert`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` TRIGGER `CompresAfterInsert` AFTER INSERT ON `Compres` FOR EACH ROW BEGIN
DECLARE vWarehouse INT;
DECLARE vWarehouseOut INT;
DECLARE isMerchandise BOOLEAN;
CALL stock.queueAdd ('buy', NEW.Id_Compra, NULL);
SELECT warehouse_id, warehouse_id_out INTO vWarehouse, vWarehouseOut
FROM Entradas E
JOIN travel T ON T.id = E.travel_id
WHERE E.Id_Entrada = NEW.Id_Entrada;
-- Actualiza el volumen unitario
SELECT k.merchandise INTO isMerchandise
FROM vn.itemCategory k
JOIN vn.itemType it ON it.categoryFk = k.id
JOIN vn.item i ON i.typeFk = it.id
WHERE i.id = NEW.Id_Article;
If isMerchandise THEN
REPLACE bi.rotacion(Id_Article, warehouse_id, cm3)
VALUES (NEW.Id_ARticle, vWarehouse, vn2008.cm3_unidad(NEW.Id_Compra));
END IF;
IF (SELECT fuente FROM warehouse where id = vWarehouseOut AND id <> 13) AND
(SELECT has_notify_passport(NEW.Id_Article,NEW.Id_Compra))
THEN
CALL notify_passport(NEW.Id_Article, NEW.Etiquetas, NEW.Packing,NEW.Id_Compra);
CALL insert_producer_plantpassport(NEW.Id_Compra);
END IF;
END$$
DELIMITER ;

View File

@ -1,38 +0,0 @@
DROP TRIGGER IF EXISTS `vn2008`.`CompresAfterUpdate`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` TRIGGER `CompresAfterUpdate`
AFTER UPDATE ON `Compres` FOR EACH ROW
BEGIN
DECLARE vWarehouse INT;
DECLARE vWarehouseOut INT;
DECLARE isMerchandise BOOLEAN;
CALL stock.queueAdd ('buy', NEW.Id_Compra, OLD.Id_Compra);
SELECT warehouse_id, warehouse_id_out INTO vWarehouse, vWarehouseOut
FROM Entradas E
JOIN travel T ON T.id = E.travel_id
WHERE E.Id_Entrada = NEW.Id_Entrada;
SELECT k.merchandise INTO isMerchandise
FROM vn.itemCategory k
JOIN vn.itemType it ON it.categoryFk = k.id
JOIN vn.item i ON i.typeFk = it.id
WHERE i.id = NEW.Id_Article;
IF isMerchandise AND NOT(NEW.Id_Cubo <=> OLD.Id_Cubo AND NEW.Id_Entrada <=> OLD.Id_Entrada)
THEN
REPLACE bi.rotacion(Id_Article, warehouse_id, cm3)
VALUES (NEW.Id_ARticle, vWarehouse, vn2008.cm3_unidad(NEW.Id_Compra));
END IF;
IF (SELECT fuente FROM warehouse where id = vWarehouseOut AND id <> 13) AND
(SELECT has_notify_passport(NEW.Id_Article,NEW.Id_Compra)) > 0
THEN
CALL notify_passport(NEW.Id_Article, NEW.Etiquetas, NEW.Packing,NEW.Id_Compra);
CALL insert_producer_plantpassport(NEW.Id_Compra);
END IF;
END$$
DELIMITER ;

View File

@ -1,18 +0,0 @@
USE `vn`;
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `vn`.`workerDepartment` AS
SELECT
`p`.`id_trabajador` AS `workerFk`,
`d`.`id` AS `departmentFk`
FROM
(((`postgresql`.`person` `p`
JOIN `postgresql`.`profile` `pr` ON ((`pr`.`person_id` = `p`.`person_id`)))
LEFT JOIN (`postgresql`.`business` `b`
LEFT JOIN `postgresql`.`business_labour` `bl` ON ((`b`.`business_id` = `bl`.`business_id`))) ON ((`pr`.`profile_id` = `b`.`client_id`)))
JOIN `vn`.`department` `d` ON ((`d`.`id` = `bl`.`department_id`)))
WHERE
(ISNULL(`b`.`date_end`)
OR (`b`.`date_end` > CURDATE()));

View File

@ -1,108 +0,0 @@
USE `hedera`;
DROP procedure IF EXISTS `orderAddItem`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `orderAddItem`(IN `vOrder` INT, IN `vWarehouse` INT, IN `vItem` INT, IN `vAmount` INT)
BEGIN
DECLARE vRow INT;
DECLARE vAdd INT;
DECLARE vAvailable INT;
DECLARE vDone BOOL;
DECLARE vGrouping INT;
DECLARE vRate INT;
DECLARE vShipment DATE;
DECLARE vPrice DECIMAL(10,2);
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
DECLARE cur CURSOR FOR
SELECT grouping, price, rate
FROM tmp.bionic_price
WHERE warehouse_id = vWarehouse
AND item_id = vItem
ORDER BY grouping DESC;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
SELECT date_send, address_id, agency_id
INTO vDate, vAddress, vAgencyMode
FROM `order`
WHERE id = vOrder;
CALL vn2008.bionic_from_item(vDate, vAddress, vAgencyMode, vItem);
START TRANSACTION;
SELECT shipped INTO vShipment
FROM tmp.travel_tree
WHERE warehouseFk = vWarehouse;
SELECT available INTO vAvailable
FROM tmp.bionic_lot
WHERE warehouse_id = vWarehouse
AND item_id = vItem;
IF vAmount > IFNULL(vAvailable, 0)
THEN
CALL util.throw ('ORDER_ROW_UNAVAILABLE');
END IF;
OPEN cur;
l: LOOP
SET vDone = FALSE;
FETCH cur INTO vGrouping, vPrice, vRate;
IF vDone THEN
LEAVE l;
END IF;
SET vAdd = vAmount - MOD(vAmount, vGrouping);
SET vAmount = vAmount - vAdd;
IF vAdd = 0 THEN
ITERATE l;
END IF;
INSERT INTO order_row SET
order_id = vOrder,
item_id = vItem,
warehouse_id = vWarehouse,
shipment = vShipment,
rate = vRate,
amount = vAdd,
price = vPrice;
SET vRow = LAST_INSERT_ID();
INSERT INTO order_component (order_row_id, component_id, price)
SELECT vRow, c.component_id, c.cost
FROM tmp.bionic_component c
JOIN bi.tarifa_componentes t
ON t.Id_Componente = c.component_id
AND (t.tarifa_class IS NULL OR t.tarifa_class = vRate)
WHERE c.warehouse_id = vWarehouse
AND c.item_id = vItem;
END LOOP;
CLOSE cur;
IF vAmount > 0
THEN
CALL util.throw ('AMOUNT_NOT_MATCH_GROUPING');
END IF;
COMMIT;
CALL vn2008.bionic_free ();
END$$
DELIMITER ;

View File

@ -1 +0,0 @@
INSERT INTO salix.ACL(id,model, property, accessType, permission, principalType, principalId)VALUES(147,'UserConfigView', '*', '*', 'ALLOW', 'ROLE', 'employee');

View File

@ -1,99 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `ticketGetTax`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetTax`()
READS SQL DATA
BEGIN
/**
* Calcula la base imponible, el IVA y el recargo de equivalencia para
* un conjunto de tickets.
*
* @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
* @return tmp.ticketAmount
* @return tmp.ticketTax Impuesto desglosado para cada ticket.
*/
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
CREATE TEMPORARY TABLE tmp.addressCompany
(INDEX (addressFk, companyFk))
ENGINE = MEMORY
SELECT DISTINCT t.addressFk, t.companyFk
FROM tmp.ticket tmpTicket
JOIN ticket t ON t.id = tmpTicket.ticketFk;
CALL addressTaxArea ();
/** Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente
* No se debería cambiar el sistema por problemas con los decimales
*/
DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax;
CREATE TEMPORARY TABLE tmp.ticketTax
(INDEX (ticketFk))
ENGINE = MEMORY
SELECT tmpTicket.ticketFk,
bp.pgcFk,
SUM(s.quantity * s.price * (100 - s.discount)/100 ) AS taxableBase,
pgc.rate,
tc.code
FROM tmp.ticket tmpTicket
JOIN sale s ON s.ticketFk = tmpTicket.ticketFk
JOIN item i ON i.id = s.itemFk
JOIN ticket t ON t.id = tmpTicket.ticketFk
JOIN supplier su ON su.id = t.companyFk
JOIN tmp.addressTaxArea ata
ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
JOIN itemTaxCountry itc
ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
JOIN bookingPlanner bp
ON bp.countryFk = su.countryFk
AND bp.taxAreaFk = ata.areaFk
AND bp.taxClassFk = itc.taxClassFk
JOIN pgc ON pgc.code = bp.pgcFk
JOIN taxClass tc ON tc.id = bp.taxClassFk
GROUP BY tmpTicket.ticketFk, pgc.code,pgc.rate
HAVING taxableBase != 0;
DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax;
CREATE TEMPORARY TABLE tmp.ticketServiceTax
(INDEX (ticketFk))
ENGINE = MEMORY
SELECT tt.ticketFk,
SUM(ts.quantity * ts.price) AS taxableBase,
pgc.rate,
tc.code
FROM tmp.ticketTax tt
JOIN ticketService ts ON ts.ticketFk = tt.ticketFk
JOIN ticket t ON t.id = tt.ticketFk
JOIN supplier su ON su.id = t.companyFk
JOIN tmp.addressTaxArea ata
ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
JOIN bookingPlanner bp
ON bp.countryFk = su.countryFk
AND bp.taxAreaFk = ata.areaFk
AND bp.taxClassFk = ts.taxClassFk
JOIN pgc ON pgc.code = bp.pgcFk AND pgc.rate = tt.rate
JOIN taxClass tc ON tc.id = bp.taxClassFk
GROUP BY tt.ticketFk, tt.code,tt.rate
HAVING taxableBase != 0;
UPDATE tmp.ticketTax tt
JOIN tmp.ticketServiceTax ts ON tt.ticketFk = ts.ticketFk AND tt.code = ts.code AND tt.rate = ts.rate
SET tt.taxableBase = tt.taxableBase + ts.taxableBase;
DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount;
CREATE TEMPORARY TABLE tmp.ticketAmount
(INDEX (ticketFk))
ENGINE = MEMORY
SELECT ticketFk, taxableBase, SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,code
FROM tmp.ticketTax
GROUP BY ticketFk, code;
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea;
END$$
DELIMITER ;

View File

@ -1,34 +0,0 @@
DROP PROCEDURE IF EXISTS vn.ticketGetTaxAdd;
DELIMITER $$
$$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticketGetTaxAdd`(vTicketFk INT)
BEGIN
/**
* Añade un ticket a la tabla tmp.ticket para calcular
* el IVA y el recargo de equivalencia y devuelve el resultado.
*/
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
CREATE TEMPORARY TABLE tmp.ticket
ENGINE = MEMORY
SELECT vTicketFk ticketFk;
CALL vn.ticketGetTax();
SELECT
tt.ticketFk,
CAST(tt.taxableBase AS DECIMAL(10, 2)) AS taxableBase,
CAST(tt.rate * tt.taxableBase / 100 AS DECIMAL(10, 2)) AS tax,
pgc.*,
CAST(IF(pe.equFk IS NULL, taxableBase, 0) AS DECIMAL(10, 2)) AS Base,
pgc.rate / 100 as vatPercent
FROM tmp.ticketTax tt
JOIN vn.pgc ON pgc.code = tt.pgcFk
LEFT JOIN vn.pgcEqu pe ON pe.equFk = pgc.code;
DROP TEMPORARY TABLE tmp.ticket;
DROP TEMPORARY TABLE tmp.ticketTax;
DROP TEMPORARY TABLE tmp.ticketAmount;
END$$
DELIMITER ;

File diff suppressed because one or more lines are too long

View File

@ -593,11 +593,11 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
(5, 29, -18.72), (5, 29, -18.72),
(5, 39, 0.02), (5, 39, 0.02),
(6, 23, 6.5), (6, 23, 6.5),
(7, 15, 0.29), (7, 15, 0.2899),
(7, 28, 5.6), (7, 28, 5.6),
(7, 29, -4.6), (7, 29, -4.6),
(7, 39, 0.01), (7, 39, 0.01),
(8, 15, 0.044), (8, 15, 0.0435),
(8, 21, -0.004), (8, 21, -0.004),
(8, 28, 20.72), (8, 28, 20.72),
(8, 29, -19.72), (8, 29, -19.72),
@ -624,7 +624,7 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
(12, 29, -19.72), (12, 29, -19.72),
(12, 37, 2), (12, 37, 2),
(12, 39, 0.01), (12, 39, 0.01),
(13, 15, 0.29), (13, 15, 0.2899),
(13, 28, 5.6), (13, 28, 5.6),
(13, 29, -4.6), (13, 29, -4.6),
(13, 39, 0.01), (13, 39, 0.01),
@ -927,7 +927,7 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`)
(5, 29, -18.72), (5, 29, -18.72),
(5, 39, 0.02), (5, 39, 0.02),
(6, 23, 6.5), (6, 23, 6.5),
(7, 15, 0.29), (7, 15, 0.2899),
(7, 28, 5.6), (7, 28, 5.6),
(7, 29, -4.6), (7, 29, -4.6),
(7, 39, 0.01), (7, 39, 0.01),

File diff suppressed because it is too large Load Diff