From: Moritz Bunkus Date: Wed, 8 Jan 2014 09:57:40 +0000 (+0100) Subject: Feld ar.datepaid bei durch SEPA-Zahlungen nachträglich richtig setzen X-Git-Tag: release-3.1.0beta1~22^2~22^2~19^2~2^2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=1b3cfa7bcfd98ff171824aed2690ddb5b813dde3;p=kivitendo-erp.git Feld ar.datepaid bei durch SEPA-Zahlungen nachträglich richtig setzen Behebt #1925. --- 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 + );