use SL::DB::Currency;
use SL::DB::Default;
use SL::DB::Order;
+use SL::DB::PaymentTerm;
use SL::DB::PurchaseInvoice;
use SL::DB::RecordTemplate;
use SL::DB::Tax;
$form->{transdate} = $form->{initial_transdate};
if ($form->{vendor_id}) {
- my $last_used_ap_chart = SL::DB::Vendor->load_cached($form->{vendor_id})->last_used_ap_chart;
+ my $vendor = SL::DB::Vendor->load_cached($form->{vendor_id});
+
+ # set initial payment terms
+ $form->{payment_id} = $vendor->payment_id;
+
+ my $last_used_ap_chart = $vendor->last_used_ap_chart;
$form->{"AP_amount_chart_id_1"} = $last_used_ap_chart->id if $last_used_ap_chart;
}
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 ]]),
});
$main::lxdebug->leave_sub();
if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) {
IR->get_vendor(\%::myconfig, $form);
+
+ my $vendor = SL::DB::Vendor->load_cached($form->{vendor_id});
+
+ # reset payment to new vendor
+ $form->{payment_id} = $vendor->payment_id;
+
if (($form->{rowcount} == 1) && ($form->{amount_1} == 0)) {
- my $last_used_ap_chart = SL::DB::Vendor->load_cached($form->{vendor_id})->last_used_ap_chart;
+ my $last_used_ap_chart = $vendor->last_used_ap_chart;
$form->{"AP_amount_chart_id_1"} = $last_used_ap_chart->id if $last_used_ap_chart;
}
}
<tr>
<th align="left">[% 'Notes' | $T8 %]</th>
<th align="left">[% 'Internal Notes' | $T8 %]</th>
+ <th align="left">[% 'Payment Terms' | $T8 %]</th>
</tr>
<tr valign="top">
<td>
<td>
[% L.textarea_tag("intnotes", intnotes, wrap="soft", rows=textarea_rows, cols=50, readonly=readonly) %]
</td>
+ <td>
+ [% L.select_tag('payment_id', payment_terms, default=payment_id, title_key='description', with_empty=1, style="width: 250px") %]
+ </td>
<tr>
</table>
</td>