X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FGL.pm;h=245e5b8008776b4d48fbcdcaf674397bd23697a9;hb=982ea31671dc3073ee90ebf57f92578d95b70201;hp=f46a95427ca6440a0f5ab90d9b84ed4718559d2d;hpb=529e6bf96e1ad74ae2e770a9e74f29f26a28d3c8;p=kivitendo-erp.git diff --git a/SL/GL.pm b/SL/GL.pm index f46a95427..245e5b800 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -45,6 +45,7 @@ use Data::Dumper; use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::DB::Chart; +use SL::DB::Draft; use SL::Util qw(trim); use SL::DB; @@ -122,12 +123,12 @@ sub _post_transaction { $query = qq|UPDATE gl SET reference = ?, description = ?, notes = ?, - transdate = ?, department_id = ?, taxincluded = ?, + transdate = ?, deliverydate = ?, department_id = ?, taxincluded = ?, storno = ?, storno_id = ?, ob_transaction = ?, cb_transaction = ? WHERE id = ?|; @values = ($form->{reference}, $form->{description}, $form->{notes}, - conv_date($form->{transdate}), conv_i($form->{department_id}), $form->{taxincluded} ? 't' : 'f', + conv_date($form->{transdate}), conv_date($form->{deliverydate}), conv_i($form->{department_id}), $form->{taxincluded} ? 't' : 'f', $form->{storno} ? 't' : 'f', conv_i($form->{storno_id}), $form->{ob_transaction} ? 't' : 'f', $form->{cb_transaction} ? 't' : 'f', conv_i($form->{id})); do_query($form, $dbh, $query, @values); @@ -190,19 +191,20 @@ sub _post_transaction { do_query($form, $dbh, qq|UPDATE gl SET storno = 't' WHERE id = ?|, conv_i($form->{storno_id})); } + if ($form->{draft_id}) { + SL::DB::Manager::Draft->delete_all(where => [ id => delete($form->{draft_id}) ]); + } + # safety check datev export if ($::instance_conf->get_datev_check_on_gl_transaction) { - my $transdate = $::form->{transdate} ? DateTime->from_lxoffice($::form->{transdate}) : undef; - $transdate ||= DateTime->today; + # create datev object my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, dbh => $dbh, trans_id => $form->{id}, ); - $datev->export; + $datev->generate_datev_data; if ($datev->errors) { die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; @@ -635,7 +637,8 @@ sub transaction { if ($form->{id}) { $query = - qq|SELECT g.reference, g.description, g.notes, g.transdate, g.storno, g.storno_id, + qq|SELECT g.reference, g.description, g.notes, g.transdate, g.deliverydate, + g.storno, g.storno_id, g.department_id, d.description AS department, e.name AS employee, g.taxincluded, g.gldate, g.ob_transaction, g.cb_transaction @@ -770,12 +773,22 @@ sub get_chart_balances { } sub get_active_taxes_for_chart { - my ($self, $chart_id, $transdate) = @_; + my ($self, $chart_id, $transdate, $tax_id) = @_; my $chart = SL::DB::Chart->new(id => $chart_id)->load; my $active_taxkey = $chart->get_active_taxkey($transdate); + + my $where = [ chart_categories => { like => '%' . $chart->category . '%' } ]; + + if ( defined $tax_id && $tax_id >= 0 ) { + $where = [ or => [ chart_categories => { like => '%' . $chart->category . '%' }, + id => $tax_id + ] + ]; + } + my $taxes = SL::DB::Manager::Tax->get_all( - where => [ chart_categories => { like => '%' . $chart->category . '%' }], + where => $where, sort_by => 'taxkey, rate', ); @@ -786,3 +799,48 @@ sub get_active_taxes_for_chart { } 1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::GL - some useful GL functions + +=head1 FUNCTIONS + +=over 4 + +=item C $transdate $tax_id + +Returns a list of valid taxes for a certain chart. + +If the optional param transdate exists one entry in the returning list +may get the attribute C for this specific tax-dependent date. +The possible entries are filtered by the charttype of the tax, i.e. only taxes +whose chart_categories match the category of the chart will be shown. + +In the case of existing records, e.g. when opening an old ar record, due to +changes in the configurations the desired tax might not be available in the +dropdown anymore. If we are loading an old record and know its tax_id (from +acc_trans), we can pass $tax_id as the third parameter and be sure that the +original tax always appears in the dropdown. + +The functions returns an array which may be used for building dropdowns in ar/ap/gl code. + +=back + +=head1 TODO + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +G. Richardson Egrichardson@kivitec.de + +=cut