Skip to content

Commit

Permalink
Merge pull request #7764 from ehuelsmann/fix/master/missing-aa-trx-wo…
Browse files Browse the repository at this point in the history
…rkflows

Add missing workflows for AR/AP transactions
  • Loading branch information
ehuelsmann authored Dec 2, 2023
2 parents d7456e3 + 48d5886 commit 5a0d92f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions sql/changes/1.11/workflow-for-aa-transactions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@


WITH aa_transactions AS (
UPDATE transactions trx
SET workflow_id = nextval('workflow_seq')
WHERE workflow_id IS NULL
AND (EXISTS (select 1 from ar where trx.id = ar.id and not ar.invoice)
OR EXISTS (select 1 from ap where trx.id = ap.id and not ap.invoice))
RETURNING *
),
new_workflow AS (
INSERT INTO workflow
SELECT workflow_id, 'AR/AP' as type,
CASE WHEN approved THEN 'POSTED' ELSE 'SAVED' END as state,
now() as last_update
FROM aa_transactions
RETURNING workflow_id, state, last_update
)
INSERT INTO workflow_history
SELECT nextval('workflow_History_seq') as workflow_hist_id,
workflow_id,
'<upgrade>' as action,
'History item created for existing transaction during schema upgrade' as description,
state,
'<upgrade>' as workflow_user,
last_update as history_date
FROM new_workflow;
1 change: 1 addition & 0 deletions sql/changes/LOADORDER
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,4 @@ mc/delete-migration-validation-data.sql
1.11/aa-column-cleanup.sql
1.11/rename-action-parameter.sql
1.11/gl-workflows.sql
1.11/workflow-for-aa-transactions.sql

0 comments on commit 5a0d92f

Please sign in to comment.