From 5bc87ade7044239fa9e893b9d7cbd476dc627eea Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 16 Jun 2015 16:17:51 +0200 Subject: [PATCH] =?utf8?q?Zahlungsbedingungen:=20Flag=20=C2=BBF=C3=A4lligk?= =?utf8?q?eitsdatum=20automatisch=20berechnen=C2=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/PaymentTerm.pm | 9 ++- SL/DB/MetaSetup/PaymentTerm.pm | 1 + SL/DB/PaymentTerm.pm | 23 +++++++- SL/Form.pm | 57 ++++--------------- SL/IS.pm | 24 +++----- bin/mozilla/io.pl | 33 ++++++++--- bin/mozilla/ir.pl | 5 +- bin/mozilla/is.pl | 12 +++- js/kivi.PaymentTerm.js | 14 +++++ js/kivi.SalesPurchase.js | 12 ++++ locale/de/all | 2 + .../payment_terms_automatic_calculation.sql | 7 +++ t/db_helper/payment.t | 3 +- templates/webpages/ap/form_footer.html | 18 ------ templates/webpages/ir/form_header.html | 23 ++------ templates/webpages/is/form_footer.html | 2 +- templates/webpages/is/form_header.html | 24 ++------ templates/webpages/payment_term/form.html | 8 ++- templates/webpages/payment_term/list.html | 3 +- 19 files changed, 147 insertions(+), 133 deletions(-) create mode 100644 js/kivi.PaymentTerm.js create mode 100644 sql/Pg-upgrade2/payment_terms_automatic_calculation.sql diff --git a/SL/Controller/PaymentTerm.pm b/SL/Controller/PaymentTerm.pm index da5850df4..5064f756d 100644 --- a/SL/Controller/PaymentTerm.pm +++ b/SL/Controller/PaymentTerm.pm @@ -16,6 +16,7 @@ use Rose::Object::MakeMethods::Generic __PACKAGE__->run_before('check_auth'); __PACKAGE__->run_before('load_payment_term', only => [ qw( edit update destroy) ]); __PACKAGE__->run_before('load_languages', only => [ qw(new list edit create update) ]); +__PACKAGE__->run_before('setup', only => [ qw(new edit) ]); # # actions @@ -32,12 +33,13 @@ sub action_list { sub action_new { my ($self) = @_; - $self->{payment_term} = SL::DB::PaymentTerm->new; + $self->{payment_term} = SL::DB::PaymentTerm->new(auto_calculation => 1); $self->render('payment_term/form', title => $::locale->text('Create a new payment term')); } sub action_edit { my ($self) = @_; + $self->render('payment_term/form', title => $::locale->text('Edit payment term')); } @@ -81,6 +83,10 @@ sub check_auth { $::auth->assert('config'); } +sub setup { + $::request->layout->use_javascript("kivi.PaymentTerm.js"); +} + # # helpers # @@ -91,6 +97,7 @@ sub create_or_update { my $params = delete($::form->{payment_term}) || { }; $self->{payment_term}->assign_attributes(%{ $params }); + $self->{payment_term}->terms_netto(0) if !$self->{payment_term}->auto_calculation; my @errors = $self->{payment_term}->validate; diff --git a/SL/DB/MetaSetup/PaymentTerm.pm b/SL/DB/MetaSetup/PaymentTerm.pm index 7dd067f6b..7c863cd45 100644 --- a/SL/DB/MetaSetup/PaymentTerm.pm +++ b/SL/DB/MetaSetup/PaymentTerm.pm @@ -9,6 +9,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->table('payment_terms'); __PACKAGE__->meta->columns( + auto_calculation => { type => 'boolean', not_null => 1 }, description => { type => 'text' }, description_long => { type => 'text' }, id => { type => 'integer', not_null => 1, sequence => 'id' }, diff --git a/SL/DB/PaymentTerm.pm b/SL/DB/PaymentTerm.pm index c087b7ffa..5d84d6881 100644 --- a/SL/DB/PaymentTerm.pm +++ b/SL/DB/PaymentTerm.pm @@ -2,6 +2,8 @@ package SL::DB::PaymentTerm; use strict; +use List::Util qw(max); + use SL::DB::MetaSetup::PaymentTerm; use SL::DB::Manager::PaymentTerm; use SL::DB::Helper::ActsAsList; @@ -25,6 +27,13 @@ sub calc_date { my $reference_date = $params{reference_date} || DateTime->today_local; $reference_date = DateTime->from_kivitendo($reference_date) unless ref($reference_date) eq 'DateTime'; + if (!$self->auto_calculation) { + my $due_date = $params{due_date} || $reference_date; + $due_date = DateTime->from_kivitendo($due_date) unless ref($due_date) eq 'DateTime'; + + return max $due_date, $reference_date; + } + my $terms = ($params{terms} // 'net') eq 'discount' ? 'terms_skonto' : 'terms_netto'; my $date = $reference_date->add(days => $self->$terms); @@ -58,8 +67,12 @@ SL::DB::PaymentTerm - Rose model for the payment_terms table =item C Calculates and returns a due date as an instance of L by -adding one of C<$self>'s terms fields. Note that the resulting date -will be the following Monday if the result falls on a weekend. +adding one of C<$self>'s terms fields if automatic calculation is on; +otherwise returns the currently-set due date (which must be provided) +or the reference date, whichever is later. + +Note that for automatich calculation the resulting date will be the +following Monday if the result falls on a weekend. C<%params> can contain the following parameters: @@ -73,6 +86,12 @@ is parsed via L. Defaults to the current date if unset. +=item C + +A currently set due date. If automatic calculation is off then this +date will be returned if it is provided and greater than or equal to +the C. Otherwise the reference date will be returned. + =item C Can be either C or C. For C the number of days to diff --git a/SL/Form.pm b/SL/Form.pm index 9209f3a73..487df6dd0 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1703,36 +1703,19 @@ sub get_default_currency { } sub set_payment_options { - $main::lxdebug->enter_sub(); - my ($self, $myconfig, $transdate) = @_; - return $main::lxdebug->leave_sub() unless ($self->{payment_id}); - - my $dbh = $self->get_standard_dbh($myconfig); + my $terms = $self->{payment_id} ? SL::DB::PaymentTerm->new(id => $self->{payment_id})->load : undef; + return if !$terms; - my $query = - qq|SELECT p.terms_netto, p.terms_skonto, p.percent_skonto, p.description_long , p.description | . - qq|FROM payment_terms p | . - qq|WHERE p.id = ?|; + $transdate ||= $self->{invdate} || $self->{transdate}; + my $due_date = $self->{duedate} || $self->{reqdate}; - ($self->{terms_netto}, $self->{terms_skonto}, $self->{percent_skonto}, - $self->{payment_terms}, $self->{payment_description}) = - selectrow_query($self, $dbh, $query, $self->{payment_id}); - - if ($transdate eq "") { - if ($self->{invdate}) { - $transdate = $self->{invdate}; - } else { - $transdate = $self->{transdate}; - } - } - - $query = - qq|SELECT ?::date + ?::integer AS netto_date, ?::date + ?::integer AS skonto_date | . - qq|FROM payment_terms|; - ($self->{netto_date}, $self->{skonto_date}) = - selectrow_query($self, $dbh, $query, $transdate, $self->{terms_netto}, $transdate, $self->{terms_skonto}); + $self->{$_} = $terms->$_ for qw(terms_netto terms_skonto percent_skonto); + $self->{payment_terms} = $terms->description_long; + $self->{payment_description} = $terms->description; + $self->{netto_date} = $terms->calc_date(reference_date => $transdate, due_date => $due_date, terms => 'net')->to_kivitendo; + $self->{skonto_date} = $terms->calc_date(reference_date => $transdate, due_date => $due_date, terms => 'discount')->to_kivitendo; my ($invtotal, $total); my (%amounts, %formatted_amounts); @@ -1762,7 +1745,8 @@ sub set_payment_options { } if ($self->{"language_id"}) { - $query = + my $dbh = $self->get_standard_dbh($myconfig); + my $query = qq|SELECT t.translation, l.output_numberformat, l.output_dateformat, l.output_longdates | . qq|FROM generic_translations t | . qq|LEFT JOIN language l ON t.language_id = l.id | . @@ -1806,8 +1790,6 @@ sub set_payment_options { $self->{skonto_in_percent} = $formatted_amounts{skonto_in_percent}; - $main::lxdebug->leave_sub(); - } sub get_template_language { @@ -1980,23 +1962,6 @@ sub get_employee_data { $main::lxdebug->leave_sub(); } -sub get_duedate { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $reference_date) = @_; - - my $terms = $self->{payment_id} ? SL::DB::PaymentTerm->new(id => $self->{payment_id}) ->load - : $self->{customer_id} ? SL::DB::Customer ->new(id => $self->{customer_id})->load->payment - : $self->{vendor_id} ? SL::DB::Vendor ->new(id => $self->{vendor_id}) ->load->payment - : $self->{invdate} ? undef # no payment terms, therefore invdate == duedate - : croak("Missing field in \$::form: payment_id, customer_id, vendor_id or invdate"); - my $duedate = $terms ? $terms->calc_date(reference_date => $reference_date)->to_kivitendo : undef; - - $main::lxdebug->leave_sub(); - - return $duedate; -} - sub _get_contacts { $main::lxdebug->enter_sub(); diff --git a/SL/IS.pm b/SL/IS.pm index 687c4379d..4fd440425 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1960,23 +1960,11 @@ sub get_customer { my $dateformat = $myconfig->{dateformat}; $dateformat .= "yy" if $myconfig->{dateformat} !~ /^y/; - my (@values, $duedate, $ref, $query); - - if ($form->{invdate}) { - $duedate = "to_date(?, '$dateformat')"; - push @values, $form->{invdate}; - } else { - $duedate = "current_date"; - } + my (@values, $ref, $query); my $cid = conv_i($form->{customer_id}); my $payment_id; - if ($form->{payment_id}) { - $payment_id = "(pt.id = ?) OR"; - push @values, conv_i($form->{payment_id}); - } - # get customer $query = qq|SELECT @@ -1985,20 +1973,26 @@ sub get_customer { c.street, c.zipcode, c.city, c.country, c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, cu.name AS curr, c.taxincluded_checked, c.direct_debit, - $duedate + COALESCE(pt.terms_netto, 0) AS duedate, b.discount AS tradediscount, b.description AS business FROM customer c LEFT JOIN business b ON (b.id = c.business_id) - LEFT JOIN payment_terms pt ON ($payment_id (c.payment_id = pt.id)) LEFT JOIN currencies cu ON (c.currency_id=cu.id) WHERE c.id = ?|; push @values, $cid; $ref = selectfirst_hashref_query($form, $dbh, $query, @values); delete $ref->{salesman_id} if !$ref->{salesman_id}; + delete $ref->{payment_id} if $form->{payment_id}; map { $form->{$_} = $ref->{$_} } keys %$ref; + if ($form->{payment_id}) { + my $reference_date = $form->{invdate} ? DateTime->from_kivitendo($form->{invdate}) : undef; + $form->{duedate} = SL::DB::PaymentTerm->new(id => $form->{payment_id})->load->calc_date(reference_date => $reference_date)->to_kivitendo; + } else { + $form->{duedate} = DateTime->today_local->to_kivitendo; + } + # use customer currency $form->{currency} = $form->{curr}; diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index a050e746a..2ef7319e7 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -41,8 +41,10 @@ use CGI; use List::MoreUtils qw(any uniq apply); use List::Util qw(min max first); +use SL::ClientJS; use SL::CVar; use SL::Common; +use SL::Controller::Base; use SL::CT; use SL::Locale::String qw(t8); use SL::IC; @@ -1805,20 +1807,35 @@ sub relink_accounts { $main::lxdebug->leave_sub(); } -sub set_duedate { - $main::lxdebug->enter_sub(); +sub get_payment_terms_for_invoice { + my $terms = $::form->{payment_id} ? SL::DB::PaymentTerm->new(id => $::form->{payment_id}) ->load + : $::form->{customer_id} ? SL::DB::Customer ->new(id => $::form->{customer_id})->load->payment + : $::form->{vendor_id} ? SL::DB::Vendor ->new(id => $::form->{vendor_id}) ->load->payment + : undef; - my $form = $main::form; - my %myconfig = %main::myconfig; + return $terms; +} +sub set_duedate { _check_io_auth(); - my $invdate = $form->{invdate} eq 'undefined' ? undef : $form->{invdate}; - my $duedate = $form->get_duedate(\%myconfig, $invdate); + my $js = SL::ClientJS->new(controller => SL::Controller::Base->new); + my $terms = get_payment_terms_for_invoice(); + my $invdate = $::form->{invdate} eq 'undefined' ? DateTime->today_local : DateTime->from_kivitendo($::form->{invdate}); + my $duedate = $terms ? $terms->calc_date(reference_date => $invdate, due_date => $::form->{duedate})->to_kivitendo : ($::form->{duedate} || $invdate->to_kivitendo); - print $form->ajax_response_header() . ($duedate || $invdate); + if ($terms && $terms->auto_calculation) { + $js->hide('#duedate_container') + ->show('#duedate_fixed') + ->html('#duedate_fixed', $duedate); - $main::lxdebug->leave_sub(); + } else { + $js->show('#duedate_container') + ->hide('#duedate_fixed'); + } + + $js->val('#duedate', $duedate) + ->render; } sub _update_part_information { diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 5bd354816..1b5840f30 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -337,7 +337,10 @@ sub form_header { ), @custom_hiddens, map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}]; - $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part)); + $TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice(); + $form->{duedate} = $TMPL_VAR{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{due_due})->to_kivitendo if $TMPL_VAR{payment_terms_obj}; + + $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part client_js)); $form->header(); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 5f23c8ea8..c330ec2f5 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -43,6 +43,7 @@ use English qw(-no_match_vars); use SL::DB::Default; use SL::DB::Customer; +use SL::DB::PaymentTerm; require "bin/mozilla/io.pl"; require "bin/mozilla/invoice_io.pl"; @@ -387,7 +388,10 @@ sub form_header { ), @custom_hiddens, map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}]; - $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part)); + $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part client_js)); + + $TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice(); + $form->{duedate} = $TMPL_VAR{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{due_due})->to_kivitendo if $TMPL_VAR{payment_terms_obj}; $form->header(); @@ -778,6 +782,9 @@ sub post { relink_accounts(); + my $terms = get_payment_terms_for_invoice(); + $form->{duedate} = $terms->calc_date(reference_date => $form->{invdate}, due_date => $form->{due_due})->to_kivitendo if $terms; + # If transfer_out is requested, get rose db handle and do post and # transfer out in one transaction. Otherwise just post the invoice. if ($::instance_conf->get_is_transfer_out && $form->{type} ne 'credit_note' && !$form->{storno}) { @@ -864,7 +871,8 @@ sub use_as_new { $form->{rowcount}--; $form->{paidaccounts} = 1; $form->{invdate} = $form->current_date(\%myconfig); - $form->{duedate} = $form->get_duedate(\%myconfig, $form->{invdate}) || $form->{invdate}; + my $terms = get_payment_terms_for_invoice(); + $form->{duedate} = $terms ? $terms->calc_date(reference_date => $form->{invdate})->to_kivitendo : $form->{invdate}; $form->{employee_id} = SL::DB::Manager::Employee->current->id; $form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy'); $form->{exchangerate} = $form->{forex} if $form->{forex}; diff --git a/js/kivi.PaymentTerm.js b/js/kivi.PaymentTerm.js new file mode 100644 index 000000000..fd4892d43 --- /dev/null +++ b/js/kivi.PaymentTerm.js @@ -0,0 +1,14 @@ +namespace('kivi.PaymentTerm', function(ns) { + ns.auto_calculation_changed = function() { + var $ctrl = $('#payment_term_terms_netto_as_number'); + + if ($('#payment_term_auto_calculation').val() == 0) + $ctrl.prop('disabled', true); + else + $ctrl.prop('disabled', false).focus(); + }; +}); + +$(function() { + $('#payment_term_auto_calculation').change(kivi.PaymentTerm.auto_calculation_changed); +}); diff --git a/js/kivi.SalesPurchase.js b/js/kivi.SalesPurchase.js index 3edefdef9..303ae5fdc 100644 --- a/js/kivi.SalesPurchase.js +++ b/js/kivi.SalesPurchase.js @@ -86,4 +86,16 @@ namespace('kivi.SalesPurchase', function(ns) { this.init_on_submit_checks = function() { $('input[type=submit]').click(kivi.SalesPurchase.on_submit_checks); }; + + this.set_duedate_on_reference_date_change = function(reference_field_id) { + setTimeout(function() { + var data = { + action: 'set_duedate', + invdate: $('#' + reference_field_id).val(), + duedate: $('#duedate').val(), + payment_id: $('#payment_id').val(), + }; + $.post('is.pl', data, kivi.eval_json_result); + }); + }; }); diff --git a/locale/de/all b/locale/de/all index 27be322a9..3abb53368 100755 --- a/locale/de/all +++ b/locale/de/all @@ -312,6 +312,7 @@ $self->{texts} = { 'Authentification database creation' => 'Anlegen der Datenbank zur Benutzerauthentifizierung', 'Authentification tables creation' => 'Anlegen der Tabellen zur Benutzerauthentifizierung', 'Auto Send?' => 'Auto. Versand?', + 'Automatic date calculation' => 'Automatische Datumsberechnung', 'Automatic deletion of leading, trailing and excessive (repetitive) spaces in customer or vendor names' => 'Automatisches Löschen von voran-/nachgestellten und aufeinanderfolgenden Leerzeichen im Kunden- oder Lieferantennamen', 'Automatic deletion of leading, trailing and excessive (repetitive) spaces in part description and part notes. Affects the CSV import as well.' => 'Automatisches Löschen von voran-/nachgestellten und aufeinanderfolgenden Leerzeichen in Artikelbeschreibungen und -bemerkungen. Betrifft auch den CSV-Import.', 'Automatic skonto chart purchase' => 'Skontoautomatik Einkauf', @@ -446,6 +447,7 @@ $self->{texts} = { 'CSV import: shipping addresses' => 'CSV-Import: Lieferadressen', 'CTI settings' => 'CTI-Einstellungen', 'Calculate' => 'Berechnen', + 'Calculate due date automatically' => 'Fälligkeitsdatum automatisch berechnen', 'Calculate the value of goods for delivery plan (WARNING: Experimental (not taxincluded safe!)' => 'Warenverkaufswert anzeigen (Brutto / Netto), so wie im Auftrags-Beleg gespeichert. Benötigt das Recht: Verkaufs-Aufträge bearbeiten.', 'Calling #1 now' => 'Wähle jetzt #1', 'Can not create that quantity with current stock' => 'Diese Anzahl kann mit dem gegenwärtigen Lagerbestand nicht hergestellt werden.', diff --git a/sql/Pg-upgrade2/payment_terms_automatic_calculation.sql b/sql/Pg-upgrade2/payment_terms_automatic_calculation.sql new file mode 100644 index 000000000..4c0285f60 --- /dev/null +++ b/sql/Pg-upgrade2/payment_terms_automatic_calculation.sql @@ -0,0 +1,7 @@ +-- @tag: payment_terms_automatic_calculation +-- @description: Zahlungsbedingungen: Einstellmöglichkeit zur automatischen/manuellen Datumsberechnung +-- @depends: release_3_2_0 + +ALTER TABLE payment_terms ADD COLUMN auto_calculation BOOLEAN; +UPDATE payment_terms SET auto_calculation = TRUE; +ALTER TABLE payment_terms ALTER COLUMN auto_calculation SET NOT NULL; diff --git a/t/db_helper/payment.t b/t/db_helper/payment.t index 0d29156b2..718f537db 100644 --- a/t/db_helper/payment.t +++ b/t/db_helper/payment.t @@ -83,7 +83,8 @@ sub reset_state { description_long => 'payment', terms_netto => '30', terms_skonto => '5', - percent_skonto => '0.05' + percent_skonto => '0.05', + auto_calculation => 1, )->save; $vendor = SL::DB::Vendor->new( diff --git a/templates/webpages/ap/form_footer.html b/templates/webpages/ap/form_footer.html index d98e28393..b7659fc51 100644 --- a/templates/webpages/ap/form_footer.html +++ b/templates/webpages/ap/form_footer.html @@ -48,21 +48,3 @@ [%- END %] - - diff --git a/templates/webpages/ir/form_header.html b/templates/webpages/ir/form_header.html index 362bd8957..15cb81ae8 100644 --- a/templates/webpages/ir/form_header.html +++ b/templates/webpages/ir/form_header.html @@ -156,7 +156,7 @@ [% 'Credit Note Date' | $T8 %] - [% L.date_tag('invdate', invdate, onChange='set_duedate(this)') %] + [% L.date_tag('invdate', invdate) %] [%- ELSE %] @@ -165,11 +165,14 @@ [% 'Invoice Date' | $T8 %] - [% L.date_tag('invdate', invdate, onChange='set_duedate(this)') %] + [% L.date_tag('invdate', invdate, onChange='kivi.SalesPurchase.set_duedate_on_reference_date_change("invdate")') %] [% 'Due Date' | $T8 %] - [% L.date_tag('duedate', duedate) %] + + + + [%- END %] @@ -218,20 +221,6 @@ [% ELSE %] [% END %] }); - function set_duedate() { - setTimeout(function() { - $.ajax({ - url: 'ir.pl?action=get_duedate_vendor', - data: { - invdate: $('#invdate').val(), - vendor_id: $('input[name="vendor_id"]').val(), - old_duedate: $('#duedate').val(), - }, - dataType: 'text', - success: function (data) { $('#duedate').val(data); } - }) - }, 0); - } //--> diff --git a/templates/webpages/is/form_footer.html b/templates/webpages/is/form_footer.html index e3775c83f..fdbdc21b8 100644 --- a/templates/webpages/is/form_footer.html +++ b/templates/webpages/is/form_footer.html @@ -33,7 +33,7 @@ label_key = 'description', show_empty = 1 allow_textbox = 0 -%] - + diff --git a/templates/webpages/is/form_header.html b/templates/webpages/is/form_header.html index 52e89b75b..ca11fb1dc 100644 --- a/templates/webpages/is/form_header.html +++ b/templates/webpages/is/form_header.html @@ -194,7 +194,7 @@ [% 'Credit Note Date' | $T8 %] - [% L.date_tag('invdate', invdate, onchange='set_duedate()') %] + [% L.date_tag('invdate', invdate, onchange='kivi.SalesPurchase.set_duedate_on_reference_date_change("invdate")') %] [%- ELSE %] @@ -203,11 +203,14 @@ [% 'Invoice Date' | $T8 %] - [% L.date_tag('invdate', invdate, onchange='set_duedate()') %] + [% L.date_tag('invdate', invdate, onchange='kivi.SalesPurchase.set_duedate_on_reference_date_change("invdate")') %] [% 'Due Date' | $T8 %] - [% L.date_tag('duedate', duedate) %] + + + + [% 'Delivery Order Number' | $T8 %] @@ -271,21 +274,6 @@ [% ELSE %] [% END %] }); - function set_duedate() { - setTimeout(function() { - $.ajax({ - url: 'is.pl?action=set_duedate', - data: { - invdate: $('#invdate').val(), - payment_id: $('#payment_id').val(), - }, - dataType: 'text', - success: function (data) { - $('#duedate').val(data); - } - }) - }, 0); - } //--> diff --git a/templates/webpages/payment_term/form.html b/templates/webpages/payment_term/form.html index f1197289a..48cc15a76 100755 --- a/templates/webpages/payment_term/form.html +++ b/templates/webpages/payment_term/form.html @@ -29,10 +29,15 @@ [%- END %] + + + + + @@ -85,4 +90,3 @@
[% LxERP.t8("Calculate due date automatically") %][% L.yes_no_tag("payment_term.auto_calculation", SELF.payment_term.auto_calculation, "data-auto-calculation-toggle"="1") %]
[%- 'Netto Terms' | $T8 %] - + [% L.input_tag("payment_term.terms_netto_as_number", SELF.payment_term.terms_netto_as_number, size="6", disabled=(SELF.payment_term.auto_calculation ? '' : 1)) %]
<%bank_code%>[% LxERP.t8("Your bank code") %]
- diff --git a/templates/webpages/payment_term/list.html b/templates/webpages/payment_term/list.html index 7fb28953e..d2f4748b1 100644 --- a/templates/webpages/payment_term/list.html +++ b/templates/webpages/payment_term/list.html @@ -16,6 +16,7 @@ [%- LxERP.t8('reorder item') %] [%- 'Description' | $T8 %] [%- 'Long Description' | $T8 %] + [% 'Automatic date calculation' | $T8 %] [%- 'Netto Terms' | $T8 %] [%- 'Skonto Terms' | $T8 %] [%- 'Skonto' | $T8 %] @@ -32,6 +33,7 @@ [%- HTML.escape(payment_term.description_long) %] + [% IF payment_term.auto_calculation %][% LxERP.t8("yes") %][% ELSE %][% LxERP.t8("no") %][% END %] [%- HTML.escape(payment_term.terms_netto_as_number) %] [%- HTML.escape(payment_term.terms_skonto_as_number) %] [%- HTML.escape(payment_term.percent_skonto_as_percent) %] % @@ -47,4 +49,3 @@ [% L.sortable_element('#payment_term_list tbody', url => 'controller.pl?action=PaymentTerm/reorder', with => 'payment_term_id') %] - -- 2.20.1