summaryrefslogtreecommitdiff
path: root/sql/fixes/amount_blank_ap_transactions.sql
blob: fa7ec4f2622288192253c2892f231dbcebef0926 (plain)
  1. BEGIN;
  2. UPDATE ap
  3. SET netamount =
  4. (select sum(amount) from acc_trans
  5. where trans_id = ap.id
  6. AND ((chart_id IN (select id from chart where link = 'AP')
  7. AND amount > 0)
  8. OR (chart_id IN
  9. (select id from chart where link like '%tax%')
  10. )
  11. )
  12. )
  13. WHERE netamount IS NULL;
  14. UPDATE ar
  15. SET netamount = -1 *
  16. (select sum(amount) from acc_trans
  17. where trans_id = ar.id
  18. AND ((chart_id IN (select id from chart where link = 'AR')
  19. AND amount < 0)
  20. OR (chart_id IN
  21. (select id from chart where link like '%tax%')
  22. )
  23. )
  24. )
  25. WHERE netamount IS NULL;
  26. commit;