$::form->{currency} = $template->currency->name;
$::form->{direct_debit} = $template->direct_debit;
$::form->{globalproject_id} = $template->project_id;
+ $::form->{payment_id} = $template->payment_id;
$::form->{AP_chart_id} = $template->ar_ap_chart_id;
$::form->{transdate} = $today->to_kivitendo;
$::form->{duedate} = $today->to_kivitendo;
vendor_id => $::form->{vendor_id} || undef,
department_id => $::form->{department_id} || undef,
project_id => $::form->{globalproject_id} || undef,
+ payment_id => $::form->{payment_id} || undef,
taxincluded => $::form->{taxincluded} ? 1 : 0,
direct_debit => $::form->{direct_debit} ? 1 : 0,
ordnumber => $::form->{ordnumber},
my $follow_up_vc = $form->{vendor_id} ? SL::DB::Vendor->load_cached($form->{vendor_id})->name : '';
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)";
- $::request->layout->add_javascripts("autocomplete_chart.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.RecordTemplate.js", "kivi.File.js", "kivi.AP.js", "kivi.CustomerVendor.js", "kivi.Validator.js", "autocomplete_project.js");
+ $::request->layout->add_javascripts("autocomplete_chart.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.SalesPurchase.js", "kivi.GL.js", "kivi.RecordTemplate.js", "kivi.File.js", "kivi.AP.js", "kivi.CustomerVendor.js", "kivi.Validator.js", "autocomplete_project.js");
# $form->{totalpaid} is used by the action bar setup to determine
# whether or not canceling is allowed. Therefore it must be
# calculated prior to the action bar setup.
$form->{paid_missing} = $form->{invtotal_unformatted} - $form->{totalpaid};
+ $form->{payment_id} = $form->{invoice_obj}->{payment_id} // $form->{payment_id};
print $form->parse_html_template('ap/form_header', {
today => DateTime->today,
currencies => SL::DB::Manager::Currency->get_all_sorted,
- payment_terms => SL::DB::Manager::PaymentTerm->get_all_sorted(query => [ or => [ obsolete => 0, id => $::form->{payment_id}*1 ]]),
+ payment_terms => SL::DB::Manager::PaymentTerm->get_all_sorted(query => [ or => [ obsolete => 0, id => $form->{payment_id}*1 ]]),
});
$main::lxdebug->leave_sub();
# no restore_from_session_id needed. we like to have a newly generated
# list of invoices for bank transactions
print $form->redirect_header($form->{callback}) if ($form->{callback} =~ /BankTransaction/);
- $form->redirect($locale->text('AP transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id}) unless $inline;
- # TODO Add callback/return flag in myconfig
# With version 3.5 we can add documents, but only after posting. there should be a flag in myconfig for the user
# $form->{callback} ||= 'ap.pl?action=edit&id=' . $form->{id} if $myconfig{no_reset_arap};
+ # or a client config setting
+ if ($::instance_conf->get_ap_add_doc && $::instance_conf->get_doc_storage) {
+ my $add_doc_url = build_std_url("script=ap.pl", 'action=edit', 'id=' . E($form->{id}));
+ print $form->redirect_header($add_doc_url);
+ }
+ $form->redirect($locale->text('AP transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id}) unless $inline;
} else {
$form->error($locale->text('Cannot post transaction!'));
}
my $department_description;
$department_description = SL::DB::Manager::Department->find_by(id => $form->{department_id})->description if $form->{department_id};
+ my $project_description;
+ $project_description = SL::DB::Manager::Project->find_by(id => $form->{project_id})->description if $form->{project_id};
my @options;
push @options, $locale->text('Vendor') . " : $form->{vendor}" if ($form->{vendor});
push @options, $locale->text('Contact Person') . " : $form->{cp_name}" if ($form->{cp_name});
push @options, $locale->text('Department') . " : $department_description" if ($form->{department_id});
+ push @options, $locale->text('Project') . " : $project_description" if ($project_description);
push @options, $locale->text('Invoice Number') . " : $form->{invnumber}" if ($form->{invnumber});
push @options, $locale->text('Order Number') . " : $form->{ordnumber}" if ($form->{ordnumber});
push @options, $locale->text('Notes') . " : $form->{notes}" if ($form->{notes});