38 |
38 |
use SL::DB::Default;
|
39 |
39 |
use SL::DB::Department;
|
40 |
40 |
use SL::DB::PurchaseInvoice;
|
|
41 |
use SL::DB::Vendor;
|
41 |
42 |
use List::Util qw(max sum);
|
42 |
43 |
use List::UtilsBy qw(sort_by);
|
43 |
44 |
|
... | ... | |
110 |
111 |
# create links
|
111 |
112 |
$form->create_links("AP", \%myconfig, "vendor");
|
112 |
113 |
|
113 |
|
#quote all_vendor Bug 133
|
114 |
|
foreach my $ref (@{ $form->{all_vendor} }) {
|
115 |
|
$ref->{name} = $form->quote($ref->{name});
|
116 |
|
}
|
117 |
|
|
118 |
|
if ($form->{all_vendor}) {
|
119 |
|
unless ($form->{vendor_id}) {
|
120 |
|
$form->{vendor_id} = $form->{all_vendor}->[0]->{id};
|
121 |
|
}
|
122 |
|
}
|
123 |
|
|
124 |
114 |
$form->backup_vars(qw(payment_id language_id taxzone_id
|
125 |
115 |
currency delivery_term_id intnotes cp_id));
|
126 |
116 |
|
... | ... | |
133 |
123 |
my @curr = $form->get_all_currencies();
|
134 |
124 |
map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
|
135 |
125 |
|
136 |
|
$form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
|
137 |
|
|
138 |
|
# build vendor/customer drop down comatibility... don't ask
|
139 |
|
if (@{ $form->{"all_vendor"} || [] }) {
|
140 |
|
$form->{"selectvendor"} = 1;
|
141 |
|
$form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
|
142 |
|
}
|
143 |
|
|
144 |
126 |
# forex
|
145 |
127 |
$form->{forex} = $form->{exchangerate};
|
146 |
128 |
my $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
|
... | ... | |
248 |
230 |
my %TMPL_VAR = ();
|
249 |
231 |
my @custom_hiddens;
|
250 |
232 |
|
251 |
|
$TMPL_VAR{invoice_obj} = SL::DB::PurchaseInvoice->new(id => $form->{id})->load if $form->{id};
|
|
233 |
$TMPL_VAR{invoice_obj} = SL::DB::PurchaseInvoice->load_cached($form->{id}) if $form->{id};
|
|
234 |
$TMPL_VAR{vendor_obj} = SL::DB::Vendor->load_cached($form->{vendor_id}) if $form->{vendor_id};
|
252 |
235 |
$form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
|
253 |
236 |
$form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
|
254 |
237 |
|
... | ... | |
259 |
242 |
|
260 |
243 |
$form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
|
261 |
244 |
"currencies" => "ALL_CURRENCIES",
|
262 |
|
"vendors" => "ALL_VENDORS",
|
263 |
245 |
"price_factors" => "ALL_PRICE_FACTORS");
|
264 |
246 |
|
265 |
247 |
$TMPL_VAR{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted;
|
... | ... | |
274 |
256 |
]
|
275 |
257 |
]);
|
276 |
258 |
|
277 |
|
# customer
|
278 |
|
$TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
|
279 |
|
$TMPL_VAR{vclimit} = $myconfig{vclimit};
|
280 |
|
$TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('vendor', '', 1, 0)";
|
281 |
|
push @custom_hiddens, "vendor_id";
|
282 |
|
push @custom_hiddens, "oldvendor";
|
283 |
|
push @custom_hiddens, "selectvendor";
|
284 |
|
|
285 |
259 |
# currencies and exchangerate
|
286 |
260 |
my @values = map { $_ } @{ $form->{ALL_CURRENCIES} };
|
287 |
261 |
my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
|
... | ... | |
298 |
272 |
$TMPL_VAR{creditwarning} = ($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update};
|
299 |
273 |
$TMPL_VAR{is_credit_remaining_negativ} = $form->{creditremaining} =~ /-/;
|
300 |
274 |
|
301 |
|
my $follow_up_vc = $form->{vendor};
|
302 |
|
$follow_up_vc =~ s/--\d*\s*$//;
|
303 |
|
$TMPL_VAR{vendor_name} = $follow_up_vc;
|
304 |
|
|
305 |
275 |
# set option selected
|
306 |
276 |
foreach my $item (qw(AP)) {
|
307 |
277 |
$form->{"select$item"} =~ s/ selected//;
|
... | ... | |
473 |
443 |
|
474 |
444 |
$main::auth->assert('vendor_invoice_edit');
|
475 |
445 |
|
476 |
|
&check_name('vendor');
|
|
446 |
if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) {
|
|
447 |
IR->get_vendor(\%myconfig, $form);
|
|
448 |
}
|
477 |
449 |
|
478 |
450 |
if (!$form->{forex}) { # read exchangerate from input field (not hidden)
|
479 |
451 |
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate});
|
... | ... | |
735 |
707 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
|
736 |
708 |
|
737 |
709 |
$form->isblank("invdate", $locale->text('Invoice Date missing!'));
|
738 |
|
$form->isblank("vendor", $locale->text('Vendor missing!'));
|
|
710 |
$form->isblank("vendor_id", $locale->text('Vendor missing!'));
|
739 |
711 |
$form->isblank("invnumber", $locale->text('Invnumber missing!'));
|
740 |
712 |
|
741 |
713 |
$form->{invnumber} =~ s/^\s*//g;
|
742 |
714 |
$form->{invnumber} =~ s/\s*$//g;
|
743 |
715 |
|
744 |
716 |
# if the vendor changed get new values
|
745 |
|
if (&check_name('vendor')) {
|
|
717 |
if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) {
|
746 |
718 |
&update;
|
747 |
719 |
$::dispatcher->end_request;
|
748 |
720 |
}
|
Einkaufsrechnungen: Lieferantenwahl über Picker und nicht Multibox