Skip to content

Instantly share code, notes, and snippets.

@jandolejs
Last active November 8, 2022 08:58
Show Gist options
  • Save jandolejs/9db1af744cc1bf64f8d26e9ccc271d6f to your computer and use it in GitHub Desktop.
Save jandolejs/9db1af744cc1bf64f8d26e9ccc271d6f to your computer and use it in GitHub Desktop.
Change dph on invoices (mainly for merchants who complains about wrong tax amount)
-- manualni zemna sazby dph pouze na fakturach (nyni na 27%)
UPDATE
sales_flat_invoice
SET tax_amount = ROUND(grand_total - (grand_total / 1.21), 2),
base_tax_amount = ROUND(base_grand_total - (base_grand_total / 1.21), 2),
cod_fee = ROUND((cod_fee + cod_tax_amount) / 1.21, 2),
base_cod_fee = ROUND((base_cod_fee + base_cod_tax_amount) / 1.21, 2),
cod_tax_amount = ROUND((cod_fee + cod_tax_amount) - ((cod_fee + cod_tax_amount) / 1.21), 2),
base_cod_tax_amount = ROUND((base_cod_fee + base_cod_tax_amount) - ((base_cod_fee + base_cod_tax_amount) / 1.21), 2)
WHERE entity_id IN
(6590536); -- entity id faktury
UPDATE
sales_flat_invoice_item
SET base_price = ROUND(base_price_incl_tax / 1.21, 2),
base_tax_amount = base_price_incl_tax - (ROUND(base_price_incl_tax / 1.21, 2)),
base_row_total = (ROUND(base_price_incl_tax / 1.21, 2)) * qty,
price = ROUND(price_incl_tax / 1.21, 2),
tax_amount = price_incl_tax - (ROUND(price_incl_tax / 1.21, 2)),
row_total = (ROUND(price_incl_tax / 1.21, 2)) * qty
WHERE parent_id IN
(6590536); -- entity id faktury
UPDATE
sales_flat_order
SET tax_amount = ROUND(grand_total - (grand_total / 1.21), 2),
base_tax_amount = ROUND(base_grand_total - (base_grand_total / 1.21), 2),
cod_fee = ROUND((cod_fee + cod_tax_amount) / 1.21, 2),
base_cod_fee = ROUND((base_cod_fee + base_cod_tax_amount) / 1.21, 2),
cod_tax_amount = ROUND((cod_fee + cod_tax_amount) - ((cod_fee + cod_tax_amount) / 1.21), 2),
base_cod_tax_amount = ROUND((base_cod_fee + base_cod_tax_amount) - ((base_cod_fee + base_cod_tax_amount) / 1.21), 2)
WHERE entity_id IN
(9181445); -- entity id objednavky
UPDATE
sales_flat_order_item
SET base_price = ROUND(base_price_incl_tax / 1.21, 2),
base_tax_amount = base_price_incl_tax - (ROUND(base_price_incl_tax / 1.21, 2)),
base_row_total = (ROUND(base_price_incl_tax / 1.21, 2)) * qty_ordered,
price = ROUND(price_incl_tax / 1.21, 2),
tax_amount = price_incl_tax - (ROUND(price_incl_tax / 1.21, 2)),
row_total = (ROUND(price_incl_tax / 1.21, 2)) * qty_ordered
WHERE order_id IN
(9181445); -- entity id objednavky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment