refactor: refs #7424 Component type refactor #2656

Merged
guillermo merged 1 commits from 7424-componentType into dev 2024-07-03 05:22:50 +00:00
12 changed files with 63 additions and 54 deletions

View File

@ -59,7 +59,7 @@ BEGIN
JOIN vn.saleComponent sc ON sc.saleFk = s.id
JOIN vn.component c ON c.id = sc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk
WHERE ct.code = 'FREIGHT'
WHERE ct.code = 'freight'
AND r.created BETWEEN vDatedFrom AND vDatedTo
GROUP BY r.id
) sub ON sub.routeFk = r.Id_Ruta

View File

@ -2,7 +2,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`tarifa_componentes_series`
AS SELECT `ct`.`id` AS `tarifa_componentes_series_id`,
`ct`.`type` AS `Serie`,
`ct`.`name` AS `Serie`,
`ct`.`isBase` AS `base`,
`ct`.`isMargin` AS `margen`
FROM `vn`.`componentType` `ct`

View File

@ -8,7 +8,7 @@ BEGIN
JOIN vn.component c ON c.id = sc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk
WHERE s.ticketFk = vTicketFk
AND ct.`type` = 'otros';
AND ct.code = 'other';
UPDATE vn.sale s
JOIN (

View File

@ -20,7 +20,8 @@ BEGIN
JOIN itemCategory ic ON ic.id = tp.categoryFk
JOIN saleComponent sc ON sc.saleFk = s.id
JOIN component c ON c.id = sc.componentFk
JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1
JOIN componentType ct ON ct.id = c.typeFk
AND ct.code = 'cost'
WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo
AND ic.merchandise;

View File

@ -66,7 +66,7 @@ BEGIN
JOIN vn.componentType ct ON ct.id = c.typeFk
JOIN vn.sale s ON s.id = sc.saleFk
JOIN tmp.ticket t ON t.ticketFk = s.ticketFk
WHERE ct.code = 'FREIGHT'
WHERE ct.code = 'freight'
GROUP BY t.ticketFk) sb ON sb.ticketFk = tf.ticketFk
SET tf.freight = sb.freight;
@ -88,7 +88,7 @@ BEGIN
-- Margin
UPDATE tmp.ticketFloramondo tf
JOIN (SELECT SUM(IF(ct.code = 'COST',sc.value, 0)) cost,
JOIN (SELECT SUM(IF(ct.code = 'cost',sc.value, 0)) cost,
SUM(IF(ct.isMargin, sc.value, 0)) margin,
t.ticketFk
FROM vn.saleComponent sc

View File

@ -19,4 +19,4 @@ FROM (
)
JOIN `vn`.`componentType` `ct` ON(`ct`.`id` = `c`.`typeFk`)
)
WHERE `ct`.`type` = 'coste'
WHERE `ct`.`code` = 'cost'

View File

@ -16,6 +16,6 @@ FROM (
)
JOIN `vn`.`componentType` `ct` ON(
`ct`.`id` = `c`.`typeFk`
AND `ct`.`type` = 'agencia'
AND `ct`.`code` = 'freight'
)
)

View File

@ -0,0 +1,9 @@
ALTER TABLE vn.componentType
CHANGE code code varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL AFTER id;
ALTER TABLE vn.componentType
CHANGE `type` name varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
UPDATE IGNORE vn.componentType
SET code = LOWER(code);
UPDATE IGNORE vn.componentType
SET code = 'other'
WHERE id = 12;

View File

@ -12,7 +12,7 @@
"type": "number",
"description": "Identifier"
},
"type": {
"name": {
"type": "string"
},
"isBase":{

View File

@ -51,7 +51,7 @@
ng-repeat="saleComponent in sale.components track by saleComponent.componentFk"
class="components">
<td>
{{::saleComponent.component.componentType.type}}
{{::saleComponent.component.componentType.name}}
</td>
<td>
{{::saleComponent.component.name}}

View File

@ -20,7 +20,7 @@ class Controller extends Section {
include: {
relation: 'componentType',
scope: {
fields: ['type', 'isBase']
fields: ['name', 'isBase']
}
}
}

View File

@ -1,43 +1,42 @@
SELECT
s.id,
s.itemFk,
s.concept,
s.quantity,
s.price,
s.price - SUM(IF(ctr.id = 6, sc.value, 0)) netPrice,
s.discount,
i.size,
i.stems,
i.category,
it.id itemTypeId,
o.code AS origin,
i.inkFk,
s.ticketFk,
tcl.code vatType,
ib.ediBotanic botanical,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM vn.sale s
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
LEFT JOIN component cr ON cr.id = sc.componentFk
LEFT JOIN componentType ctr ON ctr.id = cr.typeFk
LEFT JOIN item i ON i.id = s.itemFk
LEFT JOIN ticket t ON t.id = s.ticketFk
LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN country c ON c.id = o.countryFk
LEFT JOIN supplier sp ON sp.id = t.companyFk
LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id
AND itc.countryFk = sp.countryFk
LEFT JOIN taxClass tcl ON tcl.id = itc.taxClassFk
LEFT JOIN itemBotanicalWithGenus ib ON ib.itemFk = i.id
AND ic.code = 'plant'
AND ib.ediBotanic IS NOT NULL
WHERE s.ticketFk = ?
GROUP BY s.id
ORDER BY (it.isPackaging), s.concept, s.itemFk
SELECT s.id,
s.itemFk,
s.concept,
s.quantity,
s.price,
s.price - SUM(IF(ctr.code = 'freight', sc.value, 0)) netPrice,
s.discount,
i.size,
i.stems,
i.category,
it.id itemTypeId,
o.code origin,
i.inkFk,
s.ticketFk,
tcl.code vatType,
ib.ediBotanic botanical,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM vn.sale s
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
LEFT JOIN component cr ON cr.id = sc.componentFk
LEFT JOIN componentType ctr ON ctr.id = cr.typeFk
LEFT JOIN item i ON i.id = s.itemFk
LEFT JOIN ticket t ON t.id = s.ticketFk
LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN country c ON c.id = o.countryFk
LEFT JOIN supplier sp ON sp.id = t.companyFk
LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id
AND itc.countryFk = sp.countryFk
LEFT JOIN taxClass tcl ON tcl.id = itc.taxClassFk
LEFT JOIN itemBotanicalWithGenus ib ON ib.itemFk = i.id
AND ic.code = 'plant'
AND ib.ediBotanic IS NOT NULL
WHERE s.ticketFk = ?
GROUP BY s.id
ORDER BY (it.isPackaging), s.concept, s.itemFk