Update detail_de_facture script

pull/8040/head
Qiuyi LI 2025-03-27 15:30:14 +01:00
parent b7408a2d51
commit 0d42e558e5
1 changed files with 31 additions and 56 deletions

View File

@ -1,56 +1,31 @@
create definer = admin@`%` view detail_de_facture as CREATE OR REPLACE VIEW detail_de_facture AS
select `s`.`name` AS `Boutique`, SELECT s.name AS 'Boutique',
`po`.`platform_order_id` AS `N° de Mabang`, po.platform_order_id AS 'N° de Mabang',
`po`.`platform_order_number` AS `N° de commande`, po.platform_order_number AS 'N° de commande',
`po`.`tracking_number` AS `N° de suivi`, po.tracking_number AS 'N° de suivi',
`po`.`order_time` AS `Date de commande`, po.order_time AS 'Date de commande',
`po`.`shipping_time` AS `Date d'expédition`, po.shipping_time AS 'Date d\'expédition',
`po`.`recipient` AS `Nom de client`, po.recipient AS 'Nom de client',
`po`.`country` AS `Pays`, po.country AS 'Pays',
`po`.`postcode` AS `Code postal`, po.postcode AS 'Code postal',
json_arrayagg(`wia_app`.`sku`.`erp_code`) AS `SKU`, JSON_ARRAYAGG(sku.erp_code) AS 'SKU',
json_arrayagg(`wia_app`.`sku`.`en_name`) AS `Nom produits`, JSON_ARRAYAGG(sku.en_name) AS 'Nom produits',
json_arrayagg(`poc`.`quantity`) AS `Quantité`, JSON_ARRAYAGG(poc.quantity) AS 'Quantité',
sum(`poc`.`purchase_fee`) AS `Frais d'achat`, SUM(poc.purchase_fee) AS 'Frais d\'achat',
`po`.`fret_fee` AS `Frais de FRET`, po.fret_fee AS 'Frais de FRET',
sum(`poc`.`shipping_fee`) AS `Frais de livraison`, SUM(poc.shipping_fee) AS 'Frais de livraison',
(`po`.`order_service_fee` + sum(`poc`.`service_fee`)) AS `Frais de service`, po.order_service_fee + SUM(poc.service_fee) AS 'Frais de service',
(`po`.`picking_fee` + sum(`poc`.`picking_fee`)) AS `Frais de préparation`, po.picking_fee + SUM(poc.picking_fee) AS 'Frais de préparation',
`po`.`packaging_material_fee` AS `Frais de matériel d'emballage`, po.packaging_material_fee AS 'Frais de matériel d\'emballage',
`po`.`insurance_fee` AS `Frais d'assurance produits`, po.insurance_fee AS `Frais d\'assurance produits`,
sum(`poc`.`vat`) AS `TVA`, SUM(poc.vat) AS 'TVA',
`po`.`shipping_invoice_number` AS `N° de facture` po.shipping_invoice_number AS 'N° de facture'
from ((`wia_app`.`platform_order_content` `poc` left join (`wia_app`.`platform_order` `po` join `wia_app`.`shop` `s` FROM platform_order po
on ((`po`.`shop_id` = `s`.`id`))) JOIN shop s ON po.shop_id = s.id
on ((`po`.`id` = `poc`.`platform_order_id`))) join `wia_app`.`sku` on ((`poc`.`sku_id` = `wia_app`.`sku`.`id`))) RIGHT JOIN platform_order_content poc ON po.id = poc.platform_order_id
where ((`po`.`order_time` > '2024-01-01') and (`po`.`shipping_invoice_number` is not null) and JOIN sku ON poc.sku_id = sku.id
(`poc`.`erp_status` <> 5)) WHERE po.order_time > '2025-01-01'
group by `po`.`id`, `s`.`name`, `po`.`order_time` AND shipping_invoice_number IS NOT NULL
order by `s`.`name`, `po`.`order_time`; AND poc.erp_status <> 5
GROUP BY po.id, s.name, po.order_time
-- comment on column detail_de_facture.Boutique not supported: ORDER BY s.name, po.order_time;
-- comment on column detail_de_facture.`N° de Mabang` not supported:
-- comment on column detail_de_facture.`N° de commande` not supported:
-- comment on column detail_de_facture.`N° de suivi` not supported:
-- comment on column detail_de_facture.`Date de commande` not supported:
-- comment on column detail_de_facture.`Date d'expédition` not supported:
-- comment on column detail_de_facture.`Nom de client` not supported:
-- comment on column detail_de_facture.Pays not supported:
-- comment on column detail_de_facture.`Code postal` not supported:
-- comment on column detail_de_facture.`Frais de FRET` not supported:
-- comment on column detail_de_facture.`Frais de matériel d'emballage` not supported:
-- comment on column detail_de_facture.`Frais d'assurance produits` not supported:
-- comment on column detail_de_facture.`N° de facture` not supported: