diff options
Diffstat (limited to 'sql/fixes/ar_ap_summary_fix_1.2.14.sql')
-rw-r--r-- | sql/fixes/ar_ap_summary_fix_1.2.14.sql | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sql/fixes/ar_ap_summary_fix_1.2.14.sql b/sql/fixes/ar_ap_summary_fix_1.2.14.sql new file mode 100644 index 00000000..f4a86bee --- /dev/null +++ b/sql/fixes/ar_ap_summary_fix_1.2.14.sql @@ -0,0 +1,32 @@ +BEGIN; + +UPDATE ap +SET netamount = + (select sum(amount) from acc_trans + where trans_id = ap.id + AND ((chart_id IN (select id from chart where link = 'AP') + AND amount > 0) + OR (chart_id IN + (select id from chart where link like '%tax%') + ) + ) + ) +WHERE netamount IS NULL; + +update ap set datepaid = NULL where paid = 0; + +UPDATE ar +SET netamount = -1 * + (select sum(amount) from acc_trans + where trans_id = ar.id + AND ((chart_id IN (select id from chart where link = 'AR') + AND amount < 0) + OR (chart_id IN + (select id from chart where link like '%tax%') + ) + ) + ) +WHERE netamount IS NULL; + +update ar set datepaid = NULL where paid = 0; +commit; |