Skip to content

Commit

Permalink
Merge pull request #4037 from ylavoie/fix-recon-reports-for-mc
Browse files Browse the repository at this point in the history
Fix recon reports for mc
  • Loading branch information
ehuelsmann committed May 4, 2019
2 parents 4d879a3 + 9c7f3a2 commit 46328fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sql/changes/mc/aa-migration.sql.checks.pl
Expand Up @@ -114,7 +114,7 @@ package mc_migration_checks;

check q|Assert all required AP exchange rates are available|,
query => q|SELECT * FROM exchangerate e
WHERE coalesce(sell,0) = 0
WHERE coalesce(buy,0) = 0
AND EXISTS (select 1 from ap
where ap.transdate = e.transdate
and ap.curr = e.curr)|,
Expand Down Expand Up @@ -158,7 +158,7 @@ package mc_migration_checks;

check q|Assert all required AR exchange rates are available|,
query => q|SELECT * FROM exchangerate e
WHERE coalesce(buy,0) = 0
WHERE coalesce(sell,0) = 0
AND EXISTS (select 1 from ar
where ar.transdate = e.transdate
and ar.curr = e.curr)|,
Expand Down
11 changes: 10 additions & 1 deletion sql/changes/mc/acc-trans-migration.sql
Expand Up @@ -132,6 +132,16 @@ BEGIN
AND NOT EXISTS (select 1 from cr_report_line cl
join lines_to_delete ltd on cl.ledger_id = ltd.assoc
where ltd.id = crl.ledger_id);
UPDATE cr_report_line crl
SET our_balance = our_balance
+ (select sum(our_balance) from cr_report_line cl
join lines_to_delete ltd on cl.ledger_id = ltd.id
where ltd.assoc = crl.ledger_id),
their_balance = their_balance
+ (select sum(their_balance) from cr_report_line cl
join lines_to_delete ltd on cl.ledger_id = ltd.id
where ltd.assoc = crl.ledger_id)
WHERE EXISTS (select 1 from lines_to_delete ltd where ltd.assoc = crl.ledger_id);
DELETE FROM cr_report_line crl
WHERE EXISTS (select 1 from lines_to_delete ltd
where ltd.id = crl.ledger_id);
Expand Down Expand Up @@ -250,4 +260,3 @@ BEGIN

END;
$migrate$;

0 comments on commit 46328fd

Please sign in to comment.