Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7641-refactorEntryReport
This commit is contained in:
commit
a91f952778
|
@ -139,6 +139,12 @@
|
|||
"StarredModule": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"SaySimpleCountry": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"SaySimpleConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"TempContainer": {
|
||||
"dataSource": "tempStorage"
|
||||
},
|
||||
|
|
|
@ -44,6 +44,11 @@
|
|||
"type": "belongsTo",
|
||||
"model": "Continent",
|
||||
"foreignKey": "continentFk"
|
||||
},
|
||||
"saySimpleCountry": {
|
||||
"type": "hasOne",
|
||||
"model": "SaySimpleCountry",
|
||||
"foreignKey": "countryFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
@ -54,4 +59,4 @@
|
|||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "SaySimpleConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "saySimpleConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "SaySimpleCountry",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "saySimpleCountry"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"countryFk": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"channel": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -4022,3 +4022,10 @@ INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, c
|
|||
(10, 0, 2000, 500, 13000, 1, 1, 1, '05A', 5, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL);
|
||||
|
||||
|
||||
INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
|
||||
VALUES (19, 1169),
|
||||
(8, 1183),
|
||||
(NULL, 1320);
|
||||
|
||||
INSERT IGNORE INTO vn.saySimpleConfig (url)
|
||||
VALUES ('saysimle-url-mock');
|
|
@ -9,45 +9,54 @@ BEGIN
|
|||
* @param vOrder El identificador del pedido
|
||||
* @return tmp.orderTax Bases imponibles, IVA y recargo de equivalencia
|
||||
*/
|
||||
-- No poner create or replace, ya que da problemas
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
|
||||
CREATE TEMPORARY TABLE tmp.addressCompany
|
||||
(INDEX (addressFk, companyFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT DISTINCT o.address_id addressFk, o.company_id companyFk
|
||||
FROM tmp.`order` tmpOrder
|
||||
JOIN hedera.`order` o ON o.id = tmpOrder.orderFk;
|
||||
JOIN `order` o ON o.id = tmpOrder.orderFk;
|
||||
|
||||
CALL vn.addressTaxArea;
|
||||
CALL vn.addressTaxArea();
|
||||
|
||||
-- Calcula el IVA y el recargo desglosado.
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.orderTax;
|
||||
CREATE TEMPORARY TABLE tmp.orderTax
|
||||
(INDEX (orderFk))
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.orderTax
|
||||
(PRIMARY KEY (orderFk, code, rate))
|
||||
ENGINE = MEMORY
|
||||
SELECT o.id orderFk,
|
||||
WITH orders AS (
|
||||
SELECT tor.orderFk,
|
||||
oro.amount * oro.price total,
|
||||
s.countryFk,
|
||||
ata.areaFk,
|
||||
itc.taxClassFk
|
||||
FROM hedera.orderRow oro
|
||||
JOIN tmp.order tor ON tor.orderFk = oro.orderFk
|
||||
JOIN hedera.`order` o ON o.id = tor.orderFk
|
||||
JOIN vn.item i ON i.id = oro.itemFk
|
||||
JOIN vn.`client` c ON c.id = o.customer_id
|
||||
JOIN vn.supplier s ON s.id = o.company_id
|
||||
JOIN tmp.addressTaxArea ata ON ata.addressFk = o.address_id
|
||||
AND ata.companyFk = o.company_id
|
||||
JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id
|
||||
AND itc.countryFk = s.countryFk
|
||||
HAVING total
|
||||
)
|
||||
SELECT o.orderFk,
|
||||
tc.code,
|
||||
SUM(m.amount * m.price) taxableBase,
|
||||
SUM(o.total) taxableBase,
|
||||
pgc.rate
|
||||
FROM tmp.`order` tmpOrder
|
||||
JOIN `order` o ON o.id = tmpOrder.orderFk
|
||||
JOIN orderRow m ON m.orderFk = o.id
|
||||
JOIN vn.item i ON i.id = m.itemFk
|
||||
JOIN vn.`client` c ON c.id = o.customer_id
|
||||
JOIN vn.supplier s ON s.id = o.company_id
|
||||
JOIN tmp.addressTaxArea ata
|
||||
ON ata.addressFk = o.address_id AND ata.companyFk = o.company_id
|
||||
JOIN vn.itemTaxCountry itc
|
||||
ON itc.itemFk = i.id AND itc.countryFk = s.countryFk
|
||||
JOIN vn.bookingPlanner bp
|
||||
ON bp.countryFk = s.countryFk
|
||||
AND bp.taxAreaFk = ata.areaFk
|
||||
AND bp.taxClassFk = itc.taxClassFk
|
||||
JOIN vn.pgc ON pgc.`code` = bp.pgcFk
|
||||
FROM orders o
|
||||
JOIN vn.bookingPlanner bp ON bp.countryFk = o.countryFk
|
||||
AND bp.taxAreaFk = o.areaFk
|
||||
AND bp.taxClassFk = o.taxClassFk
|
||||
JOIN vn.pgc ON pgc.code = bp.pgcFk
|
||||
JOIN vn.taxClass tc ON tc.id = bp.taxClassFk
|
||||
GROUP BY tmpOrder.orderFk, pgc.`code`, pgc.rate
|
||||
HAVING taxableBase != 0;
|
||||
GROUP BY o.orderFk, pgc.code, pgc.rate
|
||||
HAVING taxableBase
|
||||
ORDER BY bp.priority;
|
||||
|
||||
-- No poner create or replace, ya que da problemas
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount;
|
||||
CREATE TEMPORARY TABLE tmp.orderAmount
|
||||
(INDEX (orderFk))
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
CREATE TABLE IF NOT EXISTS vn.saySimpleCountry(
|
||||
countryFk MEDIUMINT(8) UNSIGNED,
|
||||
channel INT(4) COMMENT 'channel de whatsapp de saySimple',
|
||||
PRIMARY KEY (countryFk),
|
||||
CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS vn.saySimpleConfig(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
url VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
|
||||
VALUES (19, 1169),
|
||||
(8, 1183),
|
||||
(NULL, 1320);
|
|
@ -54,7 +54,10 @@ module.exports = Self => {
|
|||
{
|
||||
relation: 'country',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
fields: ['id', 'name'],
|
||||
include: {
|
||||
relation: 'saySimpleCountry',
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue