From 8b5bed7fe52952d9c09b3cc18ef483f6670a78d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 3 Dec 2020 16:41:51 +0100 Subject: [PATCH] Kreditorenbuchungen: Zahlungsbedingungen laden/speichern --- bin/mozilla/ap.pl | 17 +++++++++++++++-- templates/webpages/ap/form_header.html | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 2fe8041c9..8e9e4cae1 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -48,6 +48,7 @@ use SL::DB::Chart; use SL::DB::Currency; use SL::DB::Default; use SL::DB::Order; +use SL::DB::PaymentTerm; use SL::DB::PurchaseInvoice; use SL::DB::RecordTemplate; use SL::DB::Tax; @@ -252,7 +253,12 @@ sub add { $form->{transdate} = $form->{initial_transdate}; if ($form->{vendor_id}) { - my $last_used_ap_chart = SL::DB::Vendor->load_cached($form->{vendor_id})->last_used_ap_chart; + my $vendor = SL::DB::Vendor->load_cached($form->{vendor_id}); + + # set initial payment terms + $form->{payment_id} = $vendor->payment_id; + + my $last_used_ap_chart = $vendor->last_used_ap_chart; $form->{"AP_amount_chart_id_1"} = $last_used_ap_chart->id if $last_used_ap_chart; } @@ -556,6 +562,7 @@ sub form_header { print $form->parse_html_template('ap/form_header', { today => DateTime->today, currencies => SL::DB::Manager::Currency->get_all_sorted, + payment_terms => SL::DB::Manager::PaymentTerm->get_all_sorted(query => [ or => [ obsolete => 0, id => $::form->{payment_id}*1 ]]), }); $main::lxdebug->leave_sub(); @@ -656,8 +663,14 @@ sub update { if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) { IR->get_vendor(\%::myconfig, $form); + + my $vendor = SL::DB::Vendor->load_cached($form->{vendor_id}); + + # reset payment to new vendor + $form->{payment_id} = $vendor->payment_id; + if (($form->{rowcount} == 1) && ($form->{amount_1} == 0)) { - my $last_used_ap_chart = SL::DB::Vendor->load_cached($form->{vendor_id})->last_used_ap_chart; + my $last_used_ap_chart = $vendor->last_used_ap_chart; $form->{"AP_amount_chart_id_1"} = $last_used_ap_chart->id if $last_used_ap_chart; } } diff --git a/templates/webpages/ap/form_header.html b/templates/webpages/ap/form_header.html index a332733af..1c5a51d94 100644 --- a/templates/webpages/ap/form_header.html +++ b/templates/webpages/ap/form_header.html @@ -242,6 +242,7 @@ [% 'Notes' | $T8 %] [% 'Internal Notes' | $T8 %] + [% 'Payment Terms' | $T8 %] @@ -250,6 +251,9 @@ [% L.textarea_tag("intnotes", intnotes, wrap="soft", rows=textarea_rows, cols=50, readonly=readonly) %] + + [% L.select_tag('payment_id', payment_terms, default=payment_id, title_key='description', with_empty=1, style="width: 250px") %] + -- 2.20.1