my $vendor_of_transaction = SL::DB::Manager::Vendor->find_by(iban => $self->transaction->{remote_account_number});
my $use_vendor_filter = $self->transaction->{remote_account_number} && $vendor_of_transaction;
- my $templates = SL::DB::Manager::RecordTemplate->get_all(
+ my $templates_ap = SL::DB::Manager::RecordTemplate->get_all(
where => [ template_type => 'ap_transaction' ],
with_objects => [ qw(employee vendor) ],
);
+ my $templates_gl = SL::DB::Manager::RecordTemplate->get_all(
+ query => [ template_type => 'gl_transaction',
+ chart_id => SL::DB::Manager::BankAccount->find_by(id => $self->transaction->local_bank_account_id)->chart_id,
+ ],
+ with_objects => [ qw(employee record_template_items) ],
+ );
- #Filter templates
- $templates = [ grep { $_->vendor_id == $vendor_of_transaction->id } @{ $templates } ] if $use_vendor_filter;
+ # pre filter templates_ap, if we have a vendor match (IBAN eq IBAN) - show and allow user to edit this via gui!
+ $templates_ap = [ grep { $_->vendor_id == $vendor_of_transaction->id } @{ $templates_ap } ] if $use_vendor_filter;
$self->callback($self->url_for(
action => 'list',
$self->render(
'bank_transactions/create_invoice',
{ layout => 0 },
- title => t8('Create invoice'),
- TEMPLATES => $templates,
- vendor_name => $use_vendor_filter ? $vendor_of_transaction->name : undef,
+ title => t8('Create invoice'),
+ TEMPLATES_GL => $use_vendor_filter ? undef : $templates_gl,
+ TEMPLATES_AP => $templates_ap,
+ vendor_name => $use_vendor_filter ? $vendor_of_transaction->name : undef,
);
}
$self->{transaction} = SL::DB::Manager::BankTransaction->find_by(id => $::form->{bt_id});
my @filter;
- push @filter, ('vendor.name' => { ilike => '%' . $::form->{vendor} . '%' }) if $::form->{vendor};
+ push @filter, ('vendor.name' => { ilike => '%' . $::form->{vendor} . '%' }) if $::form->{vendor};
+ push @filter, ('template_name' => { ilike => '%' . $::form->{template} . '%' }) if $::form->{template};
+ push @filter, ('reference' => { ilike => '%' . $::form->{reference} . '%' }) if $::form->{reference};
- my $templates = SL::DB::Manager::RecordTemplate->get_all(
- where => [ template_type => 'ap_transaction', (or => \@filter) x !!@filter ],
+ my $templates_ap = SL::DB::Manager::RecordTemplate->get_all(
+ where => [ template_type => 'ap_transaction', (and => \@filter) x !!@filter ],
with_objects => [ qw(employee vendor) ],
);
+ my $templates_gl = SL::DB::Manager::RecordTemplate->get_all(
+ query => [ template_type => 'gl_transaction',
+ chart_id => SL::DB::Manager::BankAccount->find_by(id => $self->transaction->local_bank_account_id)->chart_id,
+ (and => \@filter) x !!@filter
+ ],
+ with_objects => [ qw(employee record_template_items) ],
+ );
$::form->{filter} //= {};
my $output = $self->render(
'bank_transactions/_template_list',
{ output => 0 },
- TEMPLATES => $templates,
+ TEMPLATES_AP => $templates_ap,
+ TEMPLATES_GL => $templates_gl,
);
$self->render(\to_json({ html => $output }), { type => 'json', process => 0 });
);
}
+sub load_gl_record_template_url {
+ my ($self, $template) = @_;
+
+ return $self->url_for(
+ controller => 'gl.pl',
+ action => 'load_record_template',
+ id => $template->id,
+ 'form_defaults.amount_1' => -1 * $self->transaction->amount,
+ 'form_defaults.transdate' => $self->transaction->transdate_as_date,
+ 'form_defaults.callback' => $self->callback,
+ );
+}
+
sub setup_search_action_bar {
my ($self, %params) = @_;
use SL::Webdav;
use SL::Locale::String qw(t8);
use SL::Helper::GlAttachments qw(count_gl_attachments);
-
+use Carp;
require "bin/mozilla/common.pl";
require "bin/mozilla/reportgenerator.pl";
die "invalid template type" unless $template->template_type eq 'gl_transaction';
$template->substitute_variables;
-
+ my $payment_suggestion = $::form->{form_defaults}->{amount_1};
+ # croak ("hier" . $payment_suggestion);
# Clean the current $::form before rebuilding it from the template.
my $form_defaults = delete $::form->{form_defaults};
delete @{ $::form }{ grep { !m{^(?:script|login)$}i } keys %{ $::form } };
$::form->{"accno_id_${row}"} = $item->chart_id;
$::form->{"previous_accno_id_${row}"} = $item->chart_id;
- $::form->{"debit_${row}"} = $::form->format_amount(\%::myconfig, $item->amount1, 2) if $item->amount1 * 1;
- $::form->{"credit_${row}"} = $::form->format_amount(\%::myconfig, $item->amount2, 2) if $item->amount2 * 1;
+ $::form->{"debit_${row}"} = $::form->format_amount(\%::myconfig, ($payment_suggestion ? $payment_suggestion : $item->amount1), 2) if $item->amount1 * 1;
+ $::form->{"credit_${row}"} = $::form->format_amount(\%::myconfig, ($payment_suggestion ? $payment_suggestion : $item->amount2), 2) if $item->amount2 * 1;
$::form->{"taxchart_${row}"} = $item->tax_id . '--' . $tax->rate;
$::form->{"${_}_${row}"} = $item->$_ for qw(source memo project_id);
}
$form->error($err[$errno]);
}
- undef($form->{callback});
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
$form->{snumbers} = qq|gltransaction_| . $form->{id};
}
# /saving the history
+ if ($form->{callback} =~ /BankTransaction/) {
+ print $form->redirect_header($form->{callback});
+ $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id});
+ }
+ # remove or clarify
+ undef($form->{callback});
$main::lxdebug->leave_sub();
}
'AP Transaction Storno (one letter abbreviation)' => 'S',
'AP Transaction with Storno (abbreviation)' => 'K(S)',
'AP Transactions' => 'Kreditorenbuchungen',
+ 'AP template suggestions' => 'Vorschlag Kreditorenbuchung',
'AP transaction posted.' => 'Kreditorenbuchung verbucht.',
'AP transactions changeable' => 'Änderbarkeit von Kreditorenbuchungen',
'AP transactions with sales taxkeys and/or AR transactions with input taxkeys' => 'Kreditorenbuchungen mit Umsatzsteuer-Steuerschlüsseln und/oder Debitorenbuchungen mit Vorsteuer-Steuerschlüsseln',
'Filter for customer variables' => 'Filter für benutzerdefinierte Kundenvariablen',
'Filter for item variables' => 'Filter für benutzerdefinierte Artikelvariablen',
'Filter parts' => 'Artikel filtern',
- 'Filter vendors' => 'Lieferanten filtern',
'Financial Controlling' => 'Finanzcontrolling',
'Financial Controlling Report' => 'Finanzcontrollingbericht',
'Financial Overview' => 'Finanzübersicht',
'GL Transaction (abbreviation)' => 'DB',
'GL Transactions' => 'Dialogbuchungen',
'GL search' => 'FiBu Suche',
+ 'GL template suggestions' => 'Vorschlag Dialogbuchung',
'GL transactions changeable' => 'Änderbarkeit von Dialogbuchungen',
'GLN' => 'GLN',
'Gegenkonto' => 'Gegenkonto',
'No' => 'Nein',
'No %s was found matching the search parameters.' => 'Es wurde kein %s gefunden, auf den die Suchparameter zutreffen.',
'No 1:n or n:1 relation' => 'Keine 1:n oder n:1 Beziehung',
+ 'No AP template was found.' => 'Keine Kreditorenbuchungsvorlage gefunden.',
'No Company Address given' => 'Keine Firmenadresse hinterlegt!',
'No Company Name given' => 'Kein Firmenname hinterlegt!',
'No Customer was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Endkunde gefunden',
+ 'No GL template was found.' => 'Keine Dialogbuchungsvorlage gefunden.',
'No Journal' => 'Kein Journal',
'No Vendor was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Händler gefunden',
'No action defined.' => 'Keine Aktion definiert.',
'No such job #1 in the database.' => 'Hintergrund-Job #1 existiert nicht mehr.',
'No summary account' => 'Kein Sammelkonto',
'No template has been selected yet.' => 'Es wurde noch keine Vorlage ausgewählt.',
- 'No template was found.' => 'Es wurde keine Vorlage gefunden.',
'No text blocks have been created for this position.' => 'Für diese Position wurden noch keine Textblöcke angelegt.',
'No text has been entered yet.' => 'Es wurde noch kein Text eingegeben.',
'No title yet' => 'Bisher ohne Titel',
'Reference' => 'Referenz',
'Reference / Invoice Number' => 'Referenz / Rechnungsnummer',
'Reference day' => 'Referenztag',
+ 'Reference filter for transaction templates' => 'Dialogbuchungs-Referenz',
'Reference missing!' => 'Referenz fehlt!',
'Release From Stock' => 'Lagerausgang',
'Remaining' => 'Rest',
'Telephone' => 'Telefon',
'Template' => 'Druckvorlage',
'Template Code' => 'Vorlagenkürzel',
+ 'Template Description' => 'Name der Vorlage',
'Template database' => 'Datenbankvorlage',
'Template date' => 'Vorlagendatum',
- 'Template suggestions' => 'Vorschläge für Vorlagen',
'Templates' => 'Vorlagen',
'Terms missing in row ' => '+Tage fehlen in Zeile ',
'Test database connectivity' => 'Datenbankverbindung testen',
-[%- USE HTML -%][%- USE LxERP -%][%- USE P -%][% IF TEMPLATES.size %]
- [% LxERP.t8('Template suggestions') %]:
+[%- USE HTML -%][%- USE LxERP -%][%- USE P -%]
+
+[% IF TEMPLATES_AP.size %]
+ [% LxERP.t8('AP template suggestions') %]:
<table>
<thead>
<tr>
</thead>
<tbody>
- [% FOREACH template = TEMPLATES %]
+ [% FOREACH template = TEMPLATES_AP %]
<tr class="listrow">
<td>[% P.link(SELF.load_ap_record_template_url(template), template.template_name) %]</td>
<td>[% HTML.escape(template.vendor.name) %]</td>
</tbody>
</table>
[% ELSE %]
- <p class="message_hint">[% LxERP.t8('No template was found.') %]</p>
+ <p class="message_hint">[% LxERP.t8('No AP template was found.') %]</p>
+[% END %]
+
+[% IF TEMPLATES_GL.size %]
+ [% LxERP.t8('GL template suggestions') %]:
+ <table>
+ <thead>
+ <tr>
+ <th class="listheading">[% LxERP.t8('Description') %]</th>
+ <th class="listheading">[% LxERP.t8('Reference') %]</th>
+ <th class="listheading">[% LxERP.t8('Employee') %]</th>
+ <th class="listheading">[% LxERP.t8('Template date') %]</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ [% FOREACH template = TEMPLATES_GL %]
+ <tr class="listrow">
+ <td>[% P.link(SELF.load_gl_record_template_url(template), template.template_name) %]</td>
+ <td>[% HTML.escape(template.reference) %]</td>
+ <td>[% HTML.escape(template.employee.name || template.employee.login) %]</td>
+ <td>[% HTML.escape(template.itime_as_date) %]</td>
+ </tr>
+ [% END %]
+ </tbody>
+ </table>
+[% ELSE %]
+ <p class="message_hint">[% LxERP.t8('No GL template was found.') %]</p>
[% END %]
<br>
-[% LxERP.t8('Vendor filter for AP transaction templates') %]:
-<form method="post" action="javascript:kivi.BankTransaction.filter_templates()">
+<form method="post" action="javascript:kivi.BankTransaction.filter_templates()" id="create_invoice_window_form">
[% L.hidden_tag("bt_id", SELF.transaction.id) %]
[% L.hidden_tag("filter.bank_account", FORM.filter.bank_account) %]
[% L.hidden_tag("filter.fromdate", FORM.filter.fromdate) %]
[% L.hidden_tag("filter.todate", FORM.filter.todate) %]
<table>
+ <tr>
+ <th align="right">[%- LxERP.t8("Template Description") %]</th>
+ <td>[% P.input_tag("template", template_name, style="width: 250px") %]</td>
+ </tr>
<tr>
<th align="right">[%- LxERP.t8("Vendor") %]</th>
- <td>[% P.input_tag("vendor", vendor_name, class="initial_focus", style="width: 250px") %]</td>
+ <td>[% P.input_tag("vendor", vendor_name, style="width: 250px") %]</td>
+ </tr>
+ <tr>
+ <th align="right">[%- LxERP.t8("Reference") %]</th>
+ <td>[% P.input_tag("reference", reference_name, style="width: 250px") %]</td>
</tr>
</table>
-</form>
-
<p>
- [% P.button_tag("kivi.BankTransaction.filter_templates()", LxERP.t8("Filter vendors")) %]
+ [% P.submit_tag('', LxERP.t8("Filter")) %]
+ [% P.button_tag('$("#create_invoice_window_form").resetForm()', LxERP.t8('Reset')) %]
<a href="#" onclick="$('#create_invoice_window').dialog('close');">[% LxERP.t8("Cancel") %]</a>
</p>
-
+</form>
<hr>
<div id="templates">
[% PROCESS "bank_transactions/_template_list.html" %]
</div>
+
+<script type="text/javascript">
+<!--
+$(function() {
+ $('#template').focus();
+});
+
+//-->
+</script>