From 1b3cfa7bcfd98ff171824aed2690ddb5b813dde3 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 8 Jan 2014 10:57:40 +0100 Subject: [PATCH] =?utf8?q?Feld=20ar.datepaid=20bei=20durch=20SEPA-Zahlunge?= =?utf8?q?n=20nachtr=C3=A4glich=20richtig=20setzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Behebt #1925. --- .../fix_datepaid_for_sepa_transfers.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 sql/Pg-upgrade2/fix_datepaid_for_sepa_transfers.sql diff --git a/sql/Pg-upgrade2/fix_datepaid_for_sepa_transfers.sql b/sql/Pg-upgrade2/fix_datepaid_for_sepa_transfers.sql new file mode 100644 index 000000000..dd2b06b6d --- /dev/null +++ b/sql/Pg-upgrade2/fix_datepaid_for_sepa_transfers.sql @@ -0,0 +1,19 @@ +-- @tag: fix_datepaid_for_sepa_transfers +-- @description: Feld »datepaid« bei via SEPA durchgeführten Transfers richtig setzen +-- @depends: release_3_0_0 +UPDATE ar +SET datepaid = ( + SELECT MAX(acc.transdate) + FROM acc_trans acc + LEFT JOIN chart c ON (c.id = acc.chart_id) + WHERE (acc.trans_id = ar.id) + AND (c.link LIKE '%paid%') +) +WHERE (ar.amount != 0) + AND NOT ar.storno + AND ar.id IN ( + SELECT sei.ar_id + FROM sepa_export_items sei + WHERE (sei.ar_id IS NOT NULL) + AND sei.executed + ); -- 2.20.1