Revision 5bc87ade
Von Moritz Bunkus vor mehr als 9 Jahren hinzugefügt
SL/Controller/PaymentTerm.pm | ||
---|---|---|
16 | 16 |
__PACKAGE__->run_before('check_auth'); |
17 | 17 |
__PACKAGE__->run_before('load_payment_term', only => [ qw( edit update destroy) ]); |
18 | 18 |
__PACKAGE__->run_before('load_languages', only => [ qw(new list edit create update) ]); |
19 |
__PACKAGE__->run_before('setup', only => [ qw(new edit) ]); |
|
19 | 20 |
|
20 | 21 |
# |
21 | 22 |
# actions |
... | ... | |
32 | 33 |
sub action_new { |
33 | 34 |
my ($self) = @_; |
34 | 35 |
|
35 |
$self->{payment_term} = SL::DB::PaymentTerm->new; |
|
36 |
$self->{payment_term} = SL::DB::PaymentTerm->new(auto_calculation => 1);
|
|
36 | 37 |
$self->render('payment_term/form', title => $::locale->text('Create a new payment term')); |
37 | 38 |
} |
38 | 39 |
|
39 | 40 |
sub action_edit { |
40 | 41 |
my ($self) = @_; |
42 |
|
|
41 | 43 |
$self->render('payment_term/form', title => $::locale->text('Edit payment term')); |
42 | 44 |
} |
43 | 45 |
|
... | ... | |
81 | 83 |
$::auth->assert('config'); |
82 | 84 |
} |
83 | 85 |
|
86 |
sub setup { |
|
87 |
$::request->layout->use_javascript("kivi.PaymentTerm.js"); |
|
88 |
} |
|
89 |
|
|
84 | 90 |
# |
85 | 91 |
# helpers |
86 | 92 |
# |
... | ... | |
91 | 97 |
my $params = delete($::form->{payment_term}) || { }; |
92 | 98 |
|
93 | 99 |
$self->{payment_term}->assign_attributes(%{ $params }); |
100 |
$self->{payment_term}->terms_netto(0) if !$self->{payment_term}->auto_calculation; |
|
94 | 101 |
|
95 | 102 |
my @errors = $self->{payment_term}->validate; |
96 | 103 |
|
SL/DB/MetaSetup/PaymentTerm.pm | ||
---|---|---|
9 | 9 |
__PACKAGE__->meta->table('payment_terms'); |
10 | 10 |
|
11 | 11 |
__PACKAGE__->meta->columns( |
12 |
auto_calculation => { type => 'boolean', not_null => 1 }, |
|
12 | 13 |
description => { type => 'text' }, |
13 | 14 |
description_long => { type => 'text' }, |
14 | 15 |
id => { type => 'integer', not_null => 1, sequence => 'id' }, |
SL/DB/PaymentTerm.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
5 |
use List::Util qw(max); |
|
6 |
|
|
5 | 7 |
use SL::DB::MetaSetup::PaymentTerm; |
6 | 8 |
use SL::DB::Manager::PaymentTerm; |
7 | 9 |
use SL::DB::Helper::ActsAsList; |
... | ... | |
25 | 27 |
my $reference_date = $params{reference_date} || DateTime->today_local; |
26 | 28 |
$reference_date = DateTime->from_kivitendo($reference_date) unless ref($reference_date) eq 'DateTime'; |
27 | 29 |
|
30 |
if (!$self->auto_calculation) { |
|
31 |
my $due_date = $params{due_date} || $reference_date; |
|
32 |
$due_date = DateTime->from_kivitendo($due_date) unless ref($due_date) eq 'DateTime'; |
|
33 |
|
|
34 |
return max $due_date, $reference_date; |
|
35 |
} |
|
36 |
|
|
28 | 37 |
my $terms = ($params{terms} // 'net') eq 'discount' ? 'terms_skonto' : 'terms_netto'; |
29 | 38 |
my $date = $reference_date->add(days => $self->$terms); |
30 | 39 |
|
... | ... | |
58 | 67 |
=item C<calc_date [%params]> |
59 | 68 |
|
60 | 69 |
Calculates and returns a due date as an instance of L<DateTime> by |
61 |
adding one of C<$self>'s terms fields. Note that the resulting date |
|
62 |
will be the following Monday if the result falls on a weekend. |
|
70 |
adding one of C<$self>'s terms fields if automatic calculation is on; |
|
71 |
otherwise returns the currently-set due date (which must be provided) |
|
72 |
or the reference date, whichever is later. |
|
73 |
|
|
74 |
Note that for automatich calculation the resulting date will be the |
|
75 |
following Monday if the result falls on a weekend. |
|
63 | 76 |
|
64 | 77 |
C<%params> can contain the following parameters: |
65 | 78 |
|
... | ... | |
73 | 86 |
|
74 | 87 |
Defaults to the current date if unset. |
75 | 88 |
|
89 |
=item C<due_date> |
|
90 |
|
|
91 |
A currently set due date. If automatic calculation is off then this |
|
92 |
date will be returned if it is provided and greater than or equal to |
|
93 |
the C<reference_date>. Otherwise the reference date will be returned. |
|
94 |
|
|
76 | 95 |
=item C<terms> |
77 | 96 |
|
78 | 97 |
Can be either C<net> or C<discount>. For C<net> the number of days to |
SL/Form.pm | ||
---|---|---|
1703 | 1703 |
} |
1704 | 1704 |
|
1705 | 1705 |
sub set_payment_options { |
1706 |
$main::lxdebug->enter_sub(); |
|
1707 |
|
|
1708 | 1706 |
my ($self, $myconfig, $transdate) = @_; |
1709 | 1707 |
|
1710 |
return $main::lxdebug->leave_sub() unless ($self->{payment_id}); |
|
1711 |
|
|
1712 |
my $dbh = $self->get_standard_dbh($myconfig); |
|
1708 |
my $terms = $self->{payment_id} ? SL::DB::PaymentTerm->new(id => $self->{payment_id})->load : undef; |
|
1709 |
return if !$terms; |
|
1713 | 1710 |
|
1714 |
my $query = |
|
1715 |
qq|SELECT p.terms_netto, p.terms_skonto, p.percent_skonto, p.description_long , p.description | . |
|
1716 |
qq|FROM payment_terms p | . |
|
1717 |
qq|WHERE p.id = ?|; |
|
1711 |
$transdate ||= $self->{invdate} || $self->{transdate}; |
|
1712 |
my $due_date = $self->{duedate} || $self->{reqdate}; |
|
1718 | 1713 |
|
1719 |
($self->{terms_netto}, $self->{terms_skonto}, $self->{percent_skonto}, |
|
1720 |
$self->{payment_terms}, $self->{payment_description}) = |
|
1721 |
selectrow_query($self, $dbh, $query, $self->{payment_id}); |
|
1722 |
|
|
1723 |
if ($transdate eq "") { |
|
1724 |
if ($self->{invdate}) { |
|
1725 |
$transdate = $self->{invdate}; |
|
1726 |
} else { |
|
1727 |
$transdate = $self->{transdate}; |
|
1728 |
} |
|
1729 |
} |
|
1730 |
|
|
1731 |
$query = |
|
1732 |
qq|SELECT ?::date + ?::integer AS netto_date, ?::date + ?::integer AS skonto_date | . |
|
1733 |
qq|FROM payment_terms|; |
|
1734 |
($self->{netto_date}, $self->{skonto_date}) = |
|
1735 |
selectrow_query($self, $dbh, $query, $transdate, $self->{terms_netto}, $transdate, $self->{terms_skonto}); |
|
1714 |
$self->{$_} = $terms->$_ for qw(terms_netto terms_skonto percent_skonto); |
|
1715 |
$self->{payment_terms} = $terms->description_long; |
|
1716 |
$self->{payment_description} = $terms->description; |
|
1717 |
$self->{netto_date} = $terms->calc_date(reference_date => $transdate, due_date => $due_date, terms => 'net')->to_kivitendo; |
|
1718 |
$self->{skonto_date} = $terms->calc_date(reference_date => $transdate, due_date => $due_date, terms => 'discount')->to_kivitendo; |
|
1736 | 1719 |
|
1737 | 1720 |
my ($invtotal, $total); |
1738 | 1721 |
my (%amounts, %formatted_amounts); |
... | ... | |
1762 | 1745 |
} |
1763 | 1746 |
|
1764 | 1747 |
if ($self->{"language_id"}) { |
1765 |
$query = |
|
1748 |
my $dbh = $self->get_standard_dbh($myconfig); |
|
1749 |
my $query = |
|
1766 | 1750 |
qq|SELECT t.translation, l.output_numberformat, l.output_dateformat, l.output_longdates | . |
1767 | 1751 |
qq|FROM generic_translations t | . |
1768 | 1752 |
qq|LEFT JOIN language l ON t.language_id = l.id | . |
... | ... | |
1806 | 1790 |
|
1807 | 1791 |
$self->{skonto_in_percent} = $formatted_amounts{skonto_in_percent}; |
1808 | 1792 |
|
1809 |
$main::lxdebug->leave_sub(); |
|
1810 |
|
|
1811 | 1793 |
} |
1812 | 1794 |
|
1813 | 1795 |
sub get_template_language { |
... | ... | |
1980 | 1962 |
$main::lxdebug->leave_sub(); |
1981 | 1963 |
} |
1982 | 1964 |
|
1983 |
sub get_duedate { |
|
1984 |
$main::lxdebug->enter_sub(); |
|
1985 |
|
|
1986 |
my ($self, $myconfig, $reference_date) = @_; |
|
1987 |
|
|
1988 |
my $terms = $self->{payment_id} ? SL::DB::PaymentTerm->new(id => $self->{payment_id}) ->load |
|
1989 |
: $self->{customer_id} ? SL::DB::Customer ->new(id => $self->{customer_id})->load->payment |
|
1990 |
: $self->{vendor_id} ? SL::DB::Vendor ->new(id => $self->{vendor_id}) ->load->payment |
|
1991 |
: $self->{invdate} ? undef # no payment terms, therefore invdate == duedate |
|
1992 |
: croak("Missing field in \$::form: payment_id, customer_id, vendor_id or invdate"); |
|
1993 |
my $duedate = $terms ? $terms->calc_date(reference_date => $reference_date)->to_kivitendo : undef; |
|
1994 |
|
|
1995 |
$main::lxdebug->leave_sub(); |
|
1996 |
|
|
1997 |
return $duedate; |
|
1998 |
} |
|
1999 |
|
|
2000 | 1965 |
sub _get_contacts { |
2001 | 1966 |
$main::lxdebug->enter_sub(); |
2002 | 1967 |
|
SL/IS.pm | ||
---|---|---|
1960 | 1960 |
my $dateformat = $myconfig->{dateformat}; |
1961 | 1961 |
$dateformat .= "yy" if $myconfig->{dateformat} !~ /^y/; |
1962 | 1962 |
|
1963 |
my (@values, $duedate, $ref, $query); |
|
1964 |
|
|
1965 |
if ($form->{invdate}) { |
|
1966 |
$duedate = "to_date(?, '$dateformat')"; |
|
1967 |
push @values, $form->{invdate}; |
|
1968 |
} else { |
|
1969 |
$duedate = "current_date"; |
|
1970 |
} |
|
1963 |
my (@values, $ref, $query); |
|
1971 | 1964 |
|
1972 | 1965 |
my $cid = conv_i($form->{customer_id}); |
1973 | 1966 |
my $payment_id; |
1974 | 1967 |
|
1975 |
if ($form->{payment_id}) { |
|
1976 |
$payment_id = "(pt.id = ?) OR"; |
|
1977 |
push @values, conv_i($form->{payment_id}); |
|
1978 |
} |
|
1979 |
|
|
1980 | 1968 |
# get customer |
1981 | 1969 |
$query = |
1982 | 1970 |
qq|SELECT |
... | ... | |
1985 | 1973 |
c.street, c.zipcode, c.city, c.country, |
1986 | 1974 |
c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, cu.name AS curr, |
1987 | 1975 |
c.taxincluded_checked, c.direct_debit, |
1988 |
$duedate + COALESCE(pt.terms_netto, 0) AS duedate, |
|
1989 | 1976 |
b.discount AS tradediscount, b.description AS business |
1990 | 1977 |
FROM customer c |
1991 | 1978 |
LEFT JOIN business b ON (b.id = c.business_id) |
1992 |
LEFT JOIN payment_terms pt ON ($payment_id (c.payment_id = pt.id)) |
|
1993 | 1979 |
LEFT JOIN currencies cu ON (c.currency_id=cu.id) |
1994 | 1980 |
WHERE c.id = ?|; |
1995 | 1981 |
push @values, $cid; |
1996 | 1982 |
$ref = selectfirst_hashref_query($form, $dbh, $query, @values); |
1997 | 1983 |
|
1998 | 1984 |
delete $ref->{salesman_id} if !$ref->{salesman_id}; |
1985 |
delete $ref->{payment_id} if $form->{payment_id}; |
|
1999 | 1986 |
|
2000 | 1987 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
2001 | 1988 |
|
1989 |
if ($form->{payment_id}) { |
|
1990 |
my $reference_date = $form->{invdate} ? DateTime->from_kivitendo($form->{invdate}) : undef; |
|
1991 |
$form->{duedate} = SL::DB::PaymentTerm->new(id => $form->{payment_id})->load->calc_date(reference_date => $reference_date)->to_kivitendo; |
|
1992 |
} else { |
|
1993 |
$form->{duedate} = DateTime->today_local->to_kivitendo; |
|
1994 |
} |
|
1995 |
|
|
2002 | 1996 |
# use customer currency |
2003 | 1997 |
$form->{currency} = $form->{curr}; |
2004 | 1998 |
|
bin/mozilla/io.pl | ||
---|---|---|
41 | 41 |
use List::MoreUtils qw(any uniq apply); |
42 | 42 |
use List::Util qw(min max first); |
43 | 43 |
|
44 |
use SL::ClientJS; |
|
44 | 45 |
use SL::CVar; |
45 | 46 |
use SL::Common; |
47 |
use SL::Controller::Base; |
|
46 | 48 |
use SL::CT; |
47 | 49 |
use SL::Locale::String qw(t8); |
48 | 50 |
use SL::IC; |
... | ... | |
1805 | 1807 |
$main::lxdebug->leave_sub(); |
1806 | 1808 |
} |
1807 | 1809 |
|
1808 |
sub set_duedate { |
|
1809 |
$main::lxdebug->enter_sub(); |
|
1810 |
sub get_payment_terms_for_invoice { |
|
1811 |
my $terms = $::form->{payment_id} ? SL::DB::PaymentTerm->new(id => $::form->{payment_id}) ->load |
|
1812 |
: $::form->{customer_id} ? SL::DB::Customer ->new(id => $::form->{customer_id})->load->payment |
|
1813 |
: $::form->{vendor_id} ? SL::DB::Vendor ->new(id => $::form->{vendor_id}) ->load->payment |
|
1814 |
: undef; |
|
1810 | 1815 |
|
1811 |
my $form = $main::form;
|
|
1812 |
my %myconfig = %main::myconfig;
|
|
1816 |
return $terms;
|
|
1817 |
}
|
|
1813 | 1818 |
|
1819 |
sub set_duedate { |
|
1814 | 1820 |
_check_io_auth(); |
1815 | 1821 |
|
1816 |
my $invdate = $form->{invdate} eq 'undefined' ? undef : $form->{invdate}; |
|
1817 |
my $duedate = $form->get_duedate(\%myconfig, $invdate); |
|
1822 |
my $js = SL::ClientJS->new(controller => SL::Controller::Base->new); |
|
1823 |
my $terms = get_payment_terms_for_invoice(); |
|
1824 |
my $invdate = $::form->{invdate} eq 'undefined' ? DateTime->today_local : DateTime->from_kivitendo($::form->{invdate}); |
|
1825 |
my $duedate = $terms ? $terms->calc_date(reference_date => $invdate, due_date => $::form->{duedate})->to_kivitendo : ($::form->{duedate} || $invdate->to_kivitendo); |
|
1818 | 1826 |
|
1819 |
print $form->ajax_response_header() . ($duedate || $invdate); |
|
1827 |
if ($terms && $terms->auto_calculation) { |
|
1828 |
$js->hide('#duedate_container') |
|
1829 |
->show('#duedate_fixed') |
|
1830 |
->html('#duedate_fixed', $duedate); |
|
1820 | 1831 |
|
1821 |
$main::lxdebug->leave_sub(); |
|
1832 |
} else { |
|
1833 |
$js->show('#duedate_container') |
|
1834 |
->hide('#duedate_fixed'); |
|
1835 |
} |
|
1836 |
|
|
1837 |
$js->val('#duedate', $duedate) |
|
1838 |
->render; |
|
1822 | 1839 |
} |
1823 | 1840 |
|
1824 | 1841 |
sub _update_part_information { |
bin/mozilla/ir.pl | ||
---|---|---|
337 | 337 |
), @custom_hiddens, |
338 | 338 |
map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}]; |
339 | 339 |
|
340 |
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part)); |
|
340 |
$TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice(); |
|
341 |
$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}; |
|
342 |
|
|
343 |
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part client_js)); |
|
341 | 344 |
|
342 | 345 |
$form->header(); |
343 | 346 |
|
bin/mozilla/is.pl | ||
---|---|---|
43 | 43 |
|
44 | 44 |
use SL::DB::Default; |
45 | 45 |
use SL::DB::Customer; |
46 |
use SL::DB::PaymentTerm; |
|
46 | 47 |
|
47 | 48 |
require "bin/mozilla/io.pl"; |
48 | 49 |
require "bin/mozilla/invoice_io.pl"; |
... | ... | |
387 | 388 |
), @custom_hiddens, |
388 | 389 |
map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}]; |
389 | 390 |
|
390 |
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part)); |
|
391 |
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part client_js)); |
|
392 |
|
|
393 |
$TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice(); |
|
394 |
$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}; |
|
391 | 395 |
|
392 | 396 |
$form->header(); |
393 | 397 |
|
... | ... | |
778 | 782 |
|
779 | 783 |
relink_accounts(); |
780 | 784 |
|
785 |
my $terms = get_payment_terms_for_invoice(); |
|
786 |
$form->{duedate} = $terms->calc_date(reference_date => $form->{invdate}, due_date => $form->{due_due})->to_kivitendo if $terms; |
|
787 |
|
|
781 | 788 |
# If transfer_out is requested, get rose db handle and do post and |
782 | 789 |
# transfer out in one transaction. Otherwise just post the invoice. |
783 | 790 |
if ($::instance_conf->get_is_transfer_out && $form->{type} ne 'credit_note' && !$form->{storno}) { |
... | ... | |
864 | 871 |
$form->{rowcount}--; |
865 | 872 |
$form->{paidaccounts} = 1; |
866 | 873 |
$form->{invdate} = $form->current_date(\%myconfig); |
867 |
$form->{duedate} = $form->get_duedate(\%myconfig, $form->{invdate}) || $form->{invdate}; |
|
874 |
my $terms = get_payment_terms_for_invoice(); |
|
875 |
$form->{duedate} = $terms ? $terms->calc_date(reference_date => $form->{invdate})->to_kivitendo : $form->{invdate}; |
|
868 | 876 |
$form->{employee_id} = SL::DB::Manager::Employee->current->id; |
869 | 877 |
$form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy'); |
870 | 878 |
$form->{exchangerate} = $form->{forex} if $form->{forex}; |
js/kivi.PaymentTerm.js | ||
---|---|---|
1 |
namespace('kivi.PaymentTerm', function(ns) { |
|
2 |
ns.auto_calculation_changed = function() { |
|
3 |
var $ctrl = $('#payment_term_terms_netto_as_number'); |
|
4 |
|
|
5 |
if ($('#payment_term_auto_calculation').val() == 0) |
|
6 |
$ctrl.prop('disabled', true); |
|
7 |
else |
|
8 |
$ctrl.prop('disabled', false).focus(); |
|
9 |
}; |
|
10 |
}); |
|
11 |
|
|
12 |
$(function() { |
|
13 |
$('#payment_term_auto_calculation').change(kivi.PaymentTerm.auto_calculation_changed); |
|
14 |
}); |
js/kivi.SalesPurchase.js | ||
---|---|---|
86 | 86 |
this.init_on_submit_checks = function() { |
87 | 87 |
$('input[type=submit]').click(kivi.SalesPurchase.on_submit_checks); |
88 | 88 |
}; |
89 |
|
|
90 |
this.set_duedate_on_reference_date_change = function(reference_field_id) { |
|
91 |
setTimeout(function() { |
|
92 |
var data = { |
|
93 |
action: 'set_duedate', |
|
94 |
invdate: $('#' + reference_field_id).val(), |
|
95 |
duedate: $('#duedate').val(), |
|
96 |
payment_id: $('#payment_id').val(), |
|
97 |
}; |
|
98 |
$.post('is.pl', data, kivi.eval_json_result); |
|
99 |
}); |
|
100 |
}; |
|
89 | 101 |
}); |
locale/de/all | ||
---|---|---|
312 | 312 |
'Authentification database creation' => 'Anlegen der Datenbank zur Benutzerauthentifizierung', |
313 | 313 |
'Authentification tables creation' => 'Anlegen der Tabellen zur Benutzerauthentifizierung', |
314 | 314 |
'Auto Send?' => 'Auto. Versand?', |
315 |
'Automatic date calculation' => 'Automatische Datumsberechnung', |
|
315 | 316 |
'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', |
316 | 317 |
'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.', |
317 | 318 |
'Automatic skonto chart purchase' => 'Skontoautomatik Einkauf', |
... | ... | |
446 | 447 |
'CSV import: shipping addresses' => 'CSV-Import: Lieferadressen', |
447 | 448 |
'CTI settings' => 'CTI-Einstellungen', |
448 | 449 |
'Calculate' => 'Berechnen', |
450 |
'Calculate due date automatically' => 'Fälligkeitsdatum automatisch berechnen', |
|
449 | 451 |
'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.', |
450 | 452 |
'Calling #1 now' => 'Wähle jetzt #1', |
451 | 453 |
'Can not create that quantity with current stock' => 'Diese Anzahl kann mit dem gegenwärtigen Lagerbestand nicht hergestellt werden.', |
sql/Pg-upgrade2/payment_terms_automatic_calculation.sql | ||
---|---|---|
1 |
-- @tag: payment_terms_automatic_calculation |
|
2 |
-- @description: Zahlungsbedingungen: Einstellmöglichkeit zur automatischen/manuellen Datumsberechnung |
|
3 |
-- @depends: release_3_2_0 |
|
4 |
|
|
5 |
ALTER TABLE payment_terms ADD COLUMN auto_calculation BOOLEAN; |
|
6 |
UPDATE payment_terms SET auto_calculation = TRUE; |
|
7 |
ALTER TABLE payment_terms ALTER COLUMN auto_calculation SET NOT NULL; |
t/db_helper/payment.t | ||
---|---|---|
83 | 83 |
description_long => 'payment', |
84 | 84 |
terms_netto => '30', |
85 | 85 |
terms_skonto => '5', |
86 |
percent_skonto => '0.05' |
|
86 |
percent_skonto => '0.05', |
|
87 |
auto_calculation => 1, |
|
87 | 88 |
)->save; |
88 | 89 |
|
89 | 90 |
$vendor = SL::DB::Vendor->new( |
templates/webpages/ap/form_footer.html | ||
---|---|---|
48 | 48 |
[%- END %] |
49 | 49 |
|
50 | 50 |
</form> |
51 |
|
|
52 |
<script type="text/javascript"> |
|
53 |
<!-- |
|
54 |
function set_duedate() { |
|
55 |
$.ajax({ |
|
56 |
url: 'is.pl?action=set_duedate', |
|
57 |
data: { |
|
58 |
invdate: $('#transdate').val(), |
|
59 |
vendor_id: $('[name=vendor_id]').val(), |
|
60 |
}, |
|
61 |
dataType: 'text', |
|
62 |
success: function(data) { |
|
63 |
$('#duedate').val(data); |
|
64 |
} |
|
65 |
}); |
|
66 |
} |
|
67 |
//--> |
|
68 |
</script> |
templates/webpages/ir/form_header.html | ||
---|---|---|
156 | 156 |
</tr> |
157 | 157 |
<tr> |
158 | 158 |
<th align="right">[% 'Credit Note Date' | $T8 %]</th> |
159 |
<td>[% L.date_tag('invdate', invdate, onChange='set_duedate(this)') %]</td>
|
|
159 |
<td>[% L.date_tag('invdate', invdate) %]</td> |
|
160 | 160 |
</tr> |
161 | 161 |
[%- ELSE %] |
162 | 162 |
<tr> |
... | ... | |
165 | 165 |
</tr> |
166 | 166 |
<tr> |
167 | 167 |
<th align="right">[% 'Invoice Date' | $T8 %]</th> |
168 |
<td>[% L.date_tag('invdate', invdate, onChange='set_duedate(this)') %]</td>
|
|
168 |
<td>[% L.date_tag('invdate', invdate, onChange='kivi.SalesPurchase.set_duedate_on_reference_date_change("invdate")') %]</td>
|
|
169 | 169 |
</tr> |
170 | 170 |
<tr> |
171 | 171 |
<th align="right">[% 'Due Date' | $T8 %]</th> |
172 |
<td>[% L.date_tag('duedate', duedate) %]</td> |
|
172 |
<td> |
|
173 |
<span id="duedate_container"[% IF payment_terms_obj.auto_calculation %] style="display:none"[% END %]>[% L.date_tag('duedate', duedate) %]</span> |
|
174 |
<span id="duedate_fixed"[% IF !payment_terms_obj.auto_calculation %] style="display:none"[% END %]>[% HTML.escape(duedate) %]</span> |
|
175 |
</td> |
|
173 | 176 |
</tr> |
174 | 177 |
[%- END %] |
175 | 178 |
|
... | ... | |
218 | 221 |
[% ELSE %] |
219 | 222 |
[% END %] |
220 | 223 |
}); |
221 |
function set_duedate() { |
|
222 |
setTimeout(function() { |
|
223 |
$.ajax({ |
|
224 |
url: 'ir.pl?action=get_duedate_vendor', |
|
225 |
data: { |
|
226 |
invdate: $('#invdate').val(), |
|
227 |
vendor_id: $('input[name="vendor_id"]').val(), |
|
228 |
old_duedate: $('#duedate').val(), |
|
229 |
}, |
|
230 |
dataType: 'text', |
|
231 |
success: function (data) { $('#duedate').val(data); } |
|
232 |
}) |
|
233 |
}, 0); |
|
234 |
} |
|
235 | 224 |
//--> |
236 | 225 |
</script> |
237 | 226 |
<input type="hidden" name="webdav" value="[% webdav | html %]"> |
templates/webpages/is/form_footer.html | ||
---|---|---|
33 | 33 |
label_key = 'description', |
34 | 34 |
show_empty = 1 |
35 | 35 |
allow_textbox = 0 -%] |
36 |
<script type='text/javascript'>$('#payment_id').change(function(){ if (this.value) set_duedate()})</script>
|
|
36 |
<script type='text/javascript'>$('#payment_id').change(function(){ kivi.SalesPurchase.set_duedate_on_reference_date_change("invdate"); })</script>
|
|
37 | 37 |
</td> |
38 | 38 |
</tr> |
39 | 39 |
<tr> |
templates/webpages/is/form_header.html | ||
---|---|---|
194 | 194 |
</tr> |
195 | 195 |
<tr> |
196 | 196 |
<th align="right">[% 'Credit Note Date' | $T8 %]</th> |
197 |
<td>[% L.date_tag('invdate', invdate, onchange='set_duedate()') %]</td>
|
|
197 |
<td>[% L.date_tag('invdate', invdate, onchange='kivi.SalesPurchase.set_duedate_on_reference_date_change("invdate")') %]</td>
|
|
198 | 198 |
</tr> |
199 | 199 |
[%- ELSE %] |
200 | 200 |
<tr> |
... | ... | |
203 | 203 |
</tr> |
204 | 204 |
<tr> |
205 | 205 |
<th align="right">[% 'Invoice Date' | $T8 %]</th> |
206 |
<td>[% L.date_tag('invdate', invdate, onchange='set_duedate()') %]</td>
|
|
206 |
<td>[% L.date_tag('invdate', invdate, onchange='kivi.SalesPurchase.set_duedate_on_reference_date_change("invdate")') %]</td>
|
|
207 | 207 |
</tr> |
208 | 208 |
<tr> |
209 | 209 |
<th align="right">[% 'Due Date' | $T8 %]</th> |
210 |
<td>[% L.date_tag('duedate', duedate) %]</td> |
|
210 |
<td> |
|
211 |
<span id="duedate_container"[% IF payment_terms_obj.auto_calculation %] style="display:none"[% END %]>[% L.date_tag('duedate', duedate) %]</span> |
|
212 |
<span id="duedate_fixed"[% IF !payment_terms_obj.auto_calculation %] style="display:none"[% END %]>[% HTML.escape(duedate) %]</span> |
|
213 |
</td> |
|
211 | 214 |
</tr> |
212 | 215 |
<tr> |
213 | 216 |
<th align="right" nowrap>[% 'Delivery Order Number' | $T8 %]</th> |
... | ... | |
271 | 274 |
[% ELSE %] |
272 | 275 |
[% END %] |
273 | 276 |
}); |
274 |
function set_duedate() { |
|
275 |
setTimeout(function() { |
|
276 |
$.ajax({ |
|
277 |
url: 'is.pl?action=set_duedate', |
|
278 |
data: { |
|
279 |
invdate: $('#invdate').val(), |
|
280 |
payment_id: $('#payment_id').val(), |
|
281 |
}, |
|
282 |
dataType: 'text', |
|
283 |
success: function (data) { |
|
284 |
$('#duedate').val(data); |
|
285 |
} |
|
286 |
}) |
|
287 |
}, 0); |
|
288 |
} |
|
289 | 277 |
//--> |
290 | 278 |
</script> |
291 | 279 |
<table width="100%"> |
templates/webpages/payment_term/form.html | ||
---|---|---|
29 | 29 |
</tr> |
30 | 30 |
[%- END %] |
31 | 31 |
|
32 |
<tr> |
|
33 |
<td>[% LxERP.t8("Calculate due date automatically") %]</td> |
|
34 |
<td>[% L.yes_no_tag("payment_term.auto_calculation", SELF.payment_term.auto_calculation, "data-auto-calculation-toggle"="1") %]</td> |
|
35 |
</tr> |
|
36 |
|
|
32 | 37 |
<tr> |
33 | 38 |
<td>[%- 'Netto Terms' | $T8 %]</td> |
34 | 39 |
<td> |
35 |
<input name="payment_term.terms_netto_as_number" value="[%- HTML.escape(SELF.payment_term.terms_netto_as_number) %]" size="6">
|
|
40 |
[% 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)) %]
|
|
36 | 41 |
</td> |
37 | 42 |
</tr> |
38 | 43 |
|
... | ... | |
85 | 90 |
<tr><td><%bank_code%></td><td>[% LxERP.t8("Your bank code") %]</td></tr> |
86 | 91 |
</table> |
87 | 92 |
</form> |
88 |
|
templates/webpages/payment_term/list.html | ||
---|---|---|
16 | 16 |
<th align="center"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th> |
17 | 17 |
<th>[%- 'Description' | $T8 %]</th> |
18 | 18 |
<th>[%- 'Long Description' | $T8 %]</th> |
19 |
<th>[% 'Automatic date calculation' | $T8 %]</th> |
|
19 | 20 |
<th align="right">[%- 'Netto Terms' | $T8 %]</th> |
20 | 21 |
<th align="right">[%- 'Skonto Terms' | $T8 %]</th> |
21 | 22 |
<th align="right">[%- 'Skonto' | $T8 %]</th> |
... | ... | |
32 | 33 |
</a> |
33 | 34 |
</td> |
34 | 35 |
<td>[%- HTML.escape(payment_term.description_long) %]</td> |
36 |
<td>[% IF payment_term.auto_calculation %][% LxERP.t8("yes") %][% ELSE %][% LxERP.t8("no") %][% END %]</td> |
|
35 | 37 |
<td align="right">[%- HTML.escape(payment_term.terms_netto_as_number) %]</td> |
36 | 38 |
<td align="right">[%- HTML.escape(payment_term.terms_skonto_as_number) %]</td> |
37 | 39 |
<td align="right">[%- HTML.escape(payment_term.percent_skonto_as_percent) %] %</td> |
... | ... | |
47 | 49 |
</form> |
48 | 50 |
|
49 | 51 |
[% L.sortable_element('#payment_term_list tbody', url => 'controller.pl?action=PaymentTerm/reorder', with => 'payment_term_id') %] |
50 |
|
Auch abrufbar als: Unified diff
Zahlungsbedingungen: Flag »Fälligkeitsdatum automatisch berechnen«