From: G. Richardson Date: Tue, 14 Jun 2016 13:27:56 +0000 (+0200) Subject: AR/AP.pm - Währungskonten prüfen X-Git-Tag: release-3.5.4~2227 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a1f105327081e1bf4b139f531a158136d55b1f8c;p=kivitendo-erp.git AR/AP.pm - Währungskonten prüfen Vor dem Buchen von Zahlungen mit Wechselkursen auf die Standardkonten von Wechselkurserträgen und Wechselkursaufwendungen prüfen. Abbrechen wenn keine definiert, ansonsten geht sowieso die SQL-Abfrage kaputt. --- diff --git a/SL/AP.pm b/SL/AP.pm index e8dd4958a..95b0d5208 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -319,6 +319,15 @@ sub post_transaction { $form->{"exchangerate_$i"}), 2); if ($amount != 0) { + # fetch fxgain and fxloss chart info from defaults if charts aren't already filled in form + if ( !$form->{fxgain_accno} && $::instance_conf->get_fxgain_accno_id ) { + $form->{fxgain_accno} = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_fxgain_accno_id)->accno; + }; + if ( !$form->{fxloss_accno} && $::instance_conf->get_fxloss_accno_id ) { + $form->{fxloss_accno} = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_fxloss_accno_id)->accno; + }; + die "fxloss_accno missing" if $amount < 0 and not $form->{fxloss_accno}; + die "fxgain_accno missing" if $amount > 0 and not $form->{fxgain_accno}; $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link) | . qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . diff --git a/SL/AR.pm b/SL/AR.pm index d64ddb219..8e8cf2f2c 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -275,6 +275,15 @@ sub post_transaction { $amount = $form->round_amount( $form->{"paid_$i"} * ($form->{exchangerate} - $form->{"exchangerate_$i"}) * -1, 2); if ($amount != 0) { + # fetch fxgain and fxloss chart info from defaults if charts aren't already filled in form + if ( !$form->{fxgain_accno} && $::instance_conf->get_fxgain_accno_id ) { + $form->{fxgain_accno} = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_fxgain_accno_id)->accno; + }; + if ( !$form->{fxloss_accno} && $::instance_conf->get_fxloss_accno_id ) { + $form->{fxloss_accno} = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_fxloss_accno_id)->accno; + }; + die "fxloss_accno missing" if $amount < 0 and not $form->{fxloss_accno}; + die "fxgain_accno missing" if $amount > 0 and not $form->{fxgain_accno}; my $accno = ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}; $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link) VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, (SELECT taxkey_id FROM chart WHERE accno = ?),