X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/d32410ac096b92aa0d2b5085bbc031aea900b096..f217d072d76183bc07723dcc29503b732bd2022d:/SL/Controller/PayPostingImport.pm diff --git a/SL/Controller/PayPostingImport.pm b/SL/Controller/PayPostingImport.pm index a2d103f2f..733dc5d28 100644 --- a/SL/Controller/PayPostingImport.pm +++ b/SL/Controller/PayPostingImport.pm @@ -17,7 +17,15 @@ sub action_upload_pay_postings { my ($self, %params) = @_; $self->setup_pay_posting_action_bar; - $self->render('pay_posting_import/form', title => $::locale->text('Import Pay Postings')); + + # new closedto + my $today = DateTime->now(); + $today->subtract(months => 1); + + my $dt = DateTime->last_day_of_month(year => $today->year, month => $today->month); + + my $new_closedto = $dt->to_kivitendo(); + $self->render('pay_posting_import/form', title => $::locale->text('Import Pay Postings'), closedto => $new_closedto); } sub action_import_datev_pay_postings { @@ -39,6 +47,9 @@ sub action_import_datev_pay_postings { if (parse_and_import($self)) { flash_later('info', t8("All pay postings successfully imported.")); } + if ($::form->{set_closedto} && _set_closedto($self)) { + flash_later('info', t8("Books closed until:") . ' ' . $::form->{closedto}); + } $self->setup_pay_posting_action_bar; $self->render('pay_posting_import/form', title => $::locale->text('Imported Pay Postings')); } @@ -82,7 +93,7 @@ sub parse_and_import { # optional KOST1 - KOST2 ? $department_name = $row->[36]; if ($department_name) { - $department = SL::DB::Manager::Department->get_first(description => { like => $department_name . '%' }); + $department = SL::DB::Manager::Department->get_first(where => [ description => { ilike => $department_name . '%' } ]); } my $amount = $::form->parse_amount({ numberformat => '1000,00' }, $row->[0]); @@ -124,6 +135,19 @@ sub parse_and_import { }) or do { die t8("Cannot add Booking, reason: #1 DB: #2 ", $@, SL::DB->client->error) }; } + +sub _set_closedto { + my $self = shift; + die "no date:" . $::form->{closedto} unless $::form->{closedto}; + + my $defaults = SL::DB::Default->get; + + $defaults->closedto(DateTime->from_kivitendo($::form->{closedto})); + $defaults->save || die "Cannot save closedto!"; + + return 1; +} + sub check_auth { $::auth->assert('general_ledger'); }