Revision ade02f1e
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
37 | 37 |
|
38 | 38 |
package Form; |
39 | 39 |
|
40 |
use Carp; |
|
40 | 41 |
use Data::Dumper; |
41 | 42 |
|
42 | 43 |
use CGI; |
... | ... | |
53 | 54 |
use SL::DB; |
54 | 55 |
use SL::DBConnect; |
55 | 56 |
use SL::DBUtils; |
57 |
use SL::DB::Customer; |
|
56 | 58 |
use SL::DB::Default; |
59 |
use SL::DB::PaymentTerm; |
|
60 |
use SL::DB::Vendor; |
|
57 | 61 |
use SL::DO; |
58 | 62 |
use SL::IC; |
59 | 63 |
use SL::IS; |
... | ... | |
1920 | 1924 |
|
1921 | 1925 |
my ($self, $myconfig, $reference_date) = @_; |
1922 | 1926 |
|
1923 |
$reference_date = $reference_date ? conv_dateq($reference_date) . '::DATE' : 'current_date'; |
|
1927 |
my $terms = $self->{payment_id} ? SL::DB::PaymentTerm->new(id => $self->{payment_id}) ->load |
|
1928 |
: $self->{customer_id} ? SL::DB::Customer ->new(id => $self->{customer_id})->load->payment |
|
1929 |
: $self->{vendor_id} ? SL::DB::Vendor ->new(id => $self->{vendor_id}) ->load->payment |
|
1930 |
: croak("Missing field in \$::form: payment_id, customer_id or vendor_id"); |
|
1924 | 1931 |
|
1925 |
my $dbh = $self->get_standard_dbh($myconfig); |
|
1926 |
my ($payment_id, $duedate); |
|
1927 |
|
|
1928 |
if($self->{payment_id}) { |
|
1929 |
$payment_id = $self->{payment_id}; |
|
1930 |
} elsif($self->{vendor_id}) { |
|
1931 |
my $query = 'SELECT payment_id FROM vendor WHERE id = ?'; |
|
1932 |
($payment_id) = selectrow_query($self, $dbh, $query, $self->{vendor_id}); |
|
1933 |
} |
|
1934 |
|
|
1935 |
if ($payment_id) { |
|
1936 |
my $query = qq|SELECT ${reference_date} + terms_netto FROM payment_terms WHERE id = ?|; |
|
1937 |
($duedate) = selectrow_query($self, $dbh, $query, $payment_id); |
|
1938 |
} |
|
1932 |
my $duedate = $terms->calc_date(reference_date => $reference_date)->to_kivitendo; |
|
1939 | 1933 |
|
1940 | 1934 |
$main::lxdebug->leave_sub(); |
1941 | 1935 |
|
Auch abrufbar als: Unified diff
Form::get_duedate: SL::DB::PaymentTerm::calc_date nutzen