Revision 049677eb
Von Jan Büren vor fast 7 Jahren hinzugefügt
SL/Controller/BankTransaction.pm | ||
---|---|---|
263 | 263 |
my $vendor_of_transaction = SL::DB::Manager::Vendor->find_by(iban => $self->transaction->{remote_account_number}); |
264 | 264 |
my $use_vendor_filter = $self->transaction->{remote_account_number} && $vendor_of_transaction; |
265 | 265 |
|
266 |
my $templates = SL::DB::Manager::RecordTemplate->get_all(
|
|
266 |
my $templates_ap = SL::DB::Manager::RecordTemplate->get_all(
|
|
267 | 267 |
where => [ template_type => 'ap_transaction' ], |
268 | 268 |
with_objects => [ qw(employee vendor) ], |
269 | 269 |
); |
270 |
my $templates_gl = SL::DB::Manager::RecordTemplate->get_all( |
|
271 |
query => [ template_type => 'gl_transaction', |
|
272 |
chart_id => SL::DB::Manager::BankAccount->find_by(id => $self->transaction->local_bank_account_id)->chart_id, |
|
273 |
], |
|
274 |
with_objects => [ qw(employee record_template_items) ], |
|
275 |
); |
|
270 | 276 |
|
271 |
#Filter templates
|
|
272 |
$templates = [ grep { $_->vendor_id == $vendor_of_transaction->id } @{ $templates } ] if $use_vendor_filter;
|
|
277 |
# pre filter templates_ap, if we have a vendor match (IBAN eq IBAN) - show and allow user to edit this via gui!
|
|
278 |
$templates_ap = [ grep { $_->vendor_id == $vendor_of_transaction->id } @{ $templates_ap } ] if $use_vendor_filter;
|
|
273 | 279 |
|
274 | 280 |
$self->callback($self->url_for( |
275 | 281 |
action => 'list', |
... | ... | |
281 | 287 |
$self->render( |
282 | 288 |
'bank_transactions/create_invoice', |
283 | 289 |
{ layout => 0 }, |
284 |
title => t8('Create invoice'), |
|
285 |
TEMPLATES => $templates, |
|
286 |
vendor_name => $use_vendor_filter ? $vendor_of_transaction->name : undef, |
|
290 |
title => t8('Create invoice'), |
|
291 |
TEMPLATES_GL => $use_vendor_filter ? undef : $templates_gl, |
|
292 |
TEMPLATES_AP => $templates_ap, |
|
293 |
vendor_name => $use_vendor_filter ? $vendor_of_transaction->name : undef, |
|
287 | 294 |
); |
288 | 295 |
} |
289 | 296 |
|
... | ... | |
319 | 326 |
$self->{transaction} = SL::DB::Manager::BankTransaction->find_by(id => $::form->{bt_id}); |
320 | 327 |
|
321 | 328 |
my @filter; |
322 |
push @filter, ('vendor.name' => { ilike => '%' . $::form->{vendor} . '%' }) if $::form->{vendor}; |
|
329 |
push @filter, ('vendor.name' => { ilike => '%' . $::form->{vendor} . '%' }) if $::form->{vendor}; |
|
330 |
push @filter, ('template_name' => { ilike => '%' . $::form->{template} . '%' }) if $::form->{template}; |
|
331 |
push @filter, ('reference' => { ilike => '%' . $::form->{reference} . '%' }) if $::form->{reference}; |
|
323 | 332 |
|
324 |
my $templates = SL::DB::Manager::RecordTemplate->get_all( |
|
325 |
where => [ template_type => 'ap_transaction', (or => \@filter) x !!@filter ],
|
|
333 |
my $templates_ap = SL::DB::Manager::RecordTemplate->get_all(
|
|
334 |
where => [ template_type => 'ap_transaction', (and => \@filter) x !!@filter ],
|
|
326 | 335 |
with_objects => [ qw(employee vendor) ], |
327 | 336 |
); |
337 |
my $templates_gl = SL::DB::Manager::RecordTemplate->get_all( |
|
338 |
query => [ template_type => 'gl_transaction', |
|
339 |
chart_id => SL::DB::Manager::BankAccount->find_by(id => $self->transaction->local_bank_account_id)->chart_id, |
|
340 |
(and => \@filter) x !!@filter |
|
341 |
], |
|
342 |
with_objects => [ qw(employee record_template_items) ], |
|
343 |
); |
|
328 | 344 |
|
329 | 345 |
$::form->{filter} //= {}; |
330 | 346 |
|
... | ... | |
338 | 354 |
my $output = $self->render( |
339 | 355 |
'bank_transactions/_template_list', |
340 | 356 |
{ output => 0 }, |
341 |
TEMPLATES => $templates, |
|
357 |
TEMPLATES_AP => $templates_ap, |
|
358 |
TEMPLATES_GL => $templates_gl, |
|
342 | 359 |
); |
343 | 360 |
|
344 | 361 |
$self->render(\to_json({ html => $output }), { type => 'json', process => 0 }); |
... | ... | |
864 | 881 |
); |
865 | 882 |
} |
866 | 883 |
|
884 |
sub load_gl_record_template_url { |
|
885 |
my ($self, $template) = @_; |
|
886 |
|
|
887 |
return $self->url_for( |
|
888 |
controller => 'gl.pl', |
|
889 |
action => 'load_record_template', |
|
890 |
id => $template->id, |
|
891 |
'form_defaults.amount_1' => -1 * $self->transaction->amount, |
|
892 |
'form_defaults.transdate' => $self->transaction->transdate_as_date, |
|
893 |
'form_defaults.callback' => $self->callback, |
|
894 |
); |
|
895 |
} |
|
896 |
|
|
867 | 897 |
sub setup_search_action_bar { |
868 | 898 |
my ($self, %params) = @_; |
869 | 899 |
|
Auch abrufbar als: Unified diff
Kontoauszug verbuchen -> Buchung erstellen erweitert
a) Filter erweitert, um nach Vorlagenname zu suchen
b) Filter korrekt in <form> gepackt, um submit und reset form
wie gewohnt zu unterstützen
c) Buchungsmöglichkeit um gl_transactions (Dialogbuchungsvorlagen)
erweitert, dass heißt in der Auswahlliste der Vorlagen werden
jetzt Dialogbuchungsvorlagen angezeigt, falls ein Buchungskonto
mit dem aktuellem Bankkonto übereinstimmt:
(bank_accounts.chart_id == record_template_items.chart_id)
d) Filter erweitert, um nach Referenz (nur in gl_transactions)
zu suchen
e) gl.pl erweitert, sodass die Metadaten der Vorlage geladen werden
und mit den sinnvollen Vorgaben aus bank_transactions gefüllt werden