summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/fixes/amount_blank_ap_transactions.sql29
1 files changed, 29 insertions, 0 deletions
diff --git a/sql/fixes/amount_blank_ap_transactions.sql b/sql/fixes/amount_blank_ap_transactions.sql
new file mode 100644
index 00000000..924e0116
--- /dev/null
+++ b/sql/fixes/amount_blank_ap_transactions.sql
@@ -0,0 +1,29 @@
+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 ar
+SET netamount = -1 *
+ (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;
+
+commit;