SELECT o.id, o.date_send, o.note, o.company_id,
ag.description agency, v.code method, c.credit,
ad.consignee, ad.zip_code, ad.city, ad.name address
FROM basket o
JOIN vn2008.Agencias ag ON ag.Id_Agencia = o.agency_id
LEFT JOIN address_view ad ON ad.id = o.address_id
JOIN vn2008.Vistas v ON v.vista_id = o.delivery_method_id
JOIN customer_view c
CALL basket_get_vat ();
SELECT
IFNULL(SUM(tax_base), 0) tax_base,
IFNULL(SUM(vat + surcharge), 0) vat
FROM t_order_vat;
DROP TEMPORARY TABLE t_order_vat;
CALL basket_confirm ();
SELECT customer_get_debt();
OrderPlacedSuccessfully