60 |
60 |
$form->{ARAP} = ($form->{type} eq 'receipt') ? "AR" : "AP";
|
61 |
61 |
$form->{arap} = lc $form->{ARAP};
|
62 |
62 |
|
63 |
|
# setup customer/vendor selection for open invoices
|
64 |
|
if ($form->{all_vc}) {
|
65 |
|
# Dieser Zweig funktioniert derzeit NIE. Ggf. ganz raus oder
|
66 |
|
# alle offenen Zahlungen wieder korrekt anzeigen. jb 12.10.2010
|
67 |
|
$form->all_vc(\%myconfig, $form->{vc}, $form->{ARAP});
|
68 |
|
} else {
|
69 |
|
CP->get_openvc(\%myconfig, \%$form);
|
70 |
|
}
|
71 |
|
# Auswahlliste für vc zusammenbauen
|
72 |
|
# Erweiterung für schliessende option und erweiterung um value
|
73 |
|
# für bugfix 1771 (doppelte Leerzeichen werden nicht 'gepostet')
|
74 |
|
$form->{"select$form->{vc}"} = "";
|
75 |
|
|
76 |
|
if ($form->{"all_$form->{vc}"}) {
|
77 |
|
$form->{"select$form->{vc}"} .= "<option value=\"\"></option>\n";
|
78 |
|
# s.o. jb 12.10.2010
|
79 |
|
$form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
|
80 |
|
# hotfix for 2450. TODO remove legacy code and use L
|
81 |
|
map { $form->{"select$form->{vc}"} .= "<option value=\"" . H($_->{name}) . "--$_->{id}\">" . H($_->{name}) . "--$_->{id}</option>\n" }
|
82 |
|
@{ $form->{"all_$form->{vc}"} };
|
83 |
|
}
|
84 |
63 |
CP->paymentaccounts(\%myconfig, \%$form);
|
85 |
64 |
|
86 |
65 |
# Standard Konto für Umlaufvermögen
|
... | ... | |
124 |
103 |
|
125 |
104 |
$auth->assert('cash');
|
126 |
105 |
|
127 |
|
my ($vc, $arap, $exchangerate);
|
|
106 |
$::request->layout->add_javascripts("autocomplete_customer.js");
|
|
107 |
|
|
108 |
my ($arap, $exchangerate);
|
128 |
109 |
|
129 |
|
if ($form->{ $form->{vc} } eq "") {
|
|
110 |
if (!$form->{ $form->{vc} . '_id' }) {
|
130 |
111 |
map { $form->{"addr$_"} = "" } (1 .. 4);
|
131 |
112 |
}
|
132 |
113 |
|
133 |
|
# sometimes it happens that values in customer arrive without the signs '--'
|
134 |
|
# but in order to select the right option field we need values with '--'
|
135 |
|
if ($form->{vc} eq "customer" && $form->{"all_$form->{vc}"}){
|
136 |
|
my ($customername) = split /--/, $form->{ $form->{vc} };
|
137 |
|
$form->{ $form->{vc} } = $customername . "--" . $form->{customer_id};
|
138 |
|
}
|
139 |
114 |
# bugfix 1771
|
140 |
115 |
# geändert von <option>asdf--2929
|
141 |
116 |
# nach:
|
142 |
117 |
# <option value="asdf--2929">asdf--2929</option>
|
143 |
118 |
# offen: $form->{ARAP} kann raus?
|
144 |
|
for my $item ($form->{vc}, "account", "currency", $form->{ARAP}) {
|
|
119 |
for my $item ("account", "currency", $form->{ARAP}) {
|
145 |
120 |
$form->{$item} = H($form->{$item});
|
146 |
121 |
$form->{"select$item"} =~ s/ selected//;
|
147 |
122 |
$form->{"select$item"} =~ s/option value="\Q$form->{$item}\E">\Q$form->{$item}\E/option selected value="$form->{$item}">$form->{$item}/;
|
148 |
123 |
}
|
149 |
124 |
|
150 |
|
$vc =
|
151 |
|
($form->{"select$form->{vc}"})
|
152 |
|
? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}\n</select>|
|
153 |
|
: qq|<input name=$form->{vc} size=35 value="$form->{$form->{vc}}">|;
|
154 |
|
|
155 |
|
$form->{openinvoices} = $form->{all_vc} ? "" : 1;
|
|
125 |
$form->{openinvoices} = 1;
|
156 |
126 |
|
157 |
127 |
# $locale->text('AR')
|
158 |
128 |
# $locale->text('AP')
|
... | ... | |
165 |
135 |
is_customer => $form->{vc} eq 'customer',
|
166 |
136 |
is_receipt => $form->{type} eq 'receipt',
|
167 |
137 |
arap => $arap,
|
168 |
|
vccontent => $vc,
|
169 |
138 |
});
|
170 |
139 |
|
171 |
140 |
$lxdebug->leave_sub;
|
... | ... | |
204 |
173 |
|
205 |
174 |
$auth->assert('cash');
|
206 |
175 |
|
207 |
|
my ($new_name_selected) = @_;
|
208 |
|
|
209 |
|
my ($buysell, $newvc, $updated, $exchangerate, $amount);
|
|
176 |
my ($buysell, $updated, $exchangerate, $amount);
|
210 |
177 |
|
211 |
178 |
if ($form->{vc} eq 'customer') {
|
212 |
179 |
$buysell = "buy";
|
... | ... | |
214 |
181 |
$buysell = "sell";
|
215 |
182 |
}
|
216 |
183 |
|
217 |
|
# if we switched to all_vc
|
218 |
|
# funktioniert derzeit nicht 12.10.2010 jb
|
219 |
|
if ($form->{all_vc} ne $form->{oldall_vc}) {
|
220 |
|
|
221 |
|
$form->{openinvoices} = ($form->{all_vc}) ? 0 : 1;
|
222 |
|
|
223 |
|
$form->{"select$form->{vc}"} = "";
|
224 |
|
|
225 |
|
if ($form->{all_vc}) {
|
226 |
|
$form->all_vc(\%myconfig, $form->{vc}, $form->{ARAP});
|
227 |
|
|
228 |
|
if ($form->{"all_$form->{vc}"}) {
|
229 |
|
map {
|
230 |
|
$form->{"select$form->{vc}"} .=
|
231 |
|
"<option>$_->{name}--$_->{id}\n"
|
232 |
|
} @{ $form->{"all_$form->{vc}"} };
|
233 |
|
}
|
234 |
|
} else { # ab hier wieder ausgeführter code (s.o.):
|
235 |
|
CP->get_openvc(\%myconfig, \%$form);
|
236 |
|
|
237 |
|
if ($form->{"all_$form->{vc}"}) {
|
238 |
|
$newvc =
|
239 |
|
qq|$form->{"all_$form->{vc}"}[0]->{name}--$form->{"all_$form->{vc}"}[0]->{id}|;
|
240 |
|
map {
|
241 |
|
$form->{"select$form->{vc}"} .=
|
242 |
|
"<option>$_->{name}--$_->{id}\n"
|
243 |
|
} @{ $form->{"all_$form->{vc}"} };
|
244 |
|
}
|
245 |
|
|
246 |
|
# if the name is not the same
|
247 |
|
if ($form->{"select$form->{vc}"} !~ /$form->{$form->{vc}}/) {
|
248 |
|
$form->{ $form->{vc} } = $newvc;
|
249 |
|
}
|
250 |
|
}
|
251 |
|
}
|
252 |
|
|
253 |
|
# search by customernumber
|
254 |
|
# the customernumber has to be correct otherwise nothing is found
|
255 |
|
if ($form->{vc} eq 'customer' and $form->{customernumber} and $form->{ARAP} eq 'AR') {
|
256 |
|
$form->{open} ='Y'; # only open invoices
|
257 |
|
# ar_transactions automatically searches by $form->{customer_id} or else
|
258 |
|
# $form->{customer} if available, and these variables will always be set
|
259 |
|
# so we have to empty these values first
|
260 |
|
$form->{customer_id} = '';
|
261 |
|
$form->{customer} = '';
|
262 |
|
AR->ar_transactions(\%myconfig, \%$form);
|
263 |
|
|
264 |
|
# Here we just take the first returned value even if the custumernumber
|
265 |
|
# may not be unique
|
266 |
|
$form->{customer} = $form->{AR}[0]{name};
|
267 |
|
$form->{customer_id} = $form->{AR}[0]{customer_id};
|
268 |
|
}
|
269 |
|
|
270 |
184 |
# search by invoicenumber,
|
271 |
185 |
if ($form->{invnumber}) {
|
272 |
186 |
$form->{open} ='Y'; # only open invoices
|
... | ... | |
289 |
203 |
foreach my $i ( @{ $form->{AR} } ) {
|
290 |
204 |
next unless $i->{invnumber} eq $form->{invnumber};
|
291 |
205 |
# found exactly matching invnumber
|
292 |
|
$form->{$form->{vc}} = $i->{name};
|
293 |
206 |
$form->{customer_id} = $i->{customer_id};
|
294 |
|
#$form->{"old${form->{vc}"} = $i->{customer_id};
|
295 |
207 |
$found_exact_invnumber_match = 1;
|
296 |
208 |
};
|
297 |
209 |
|
298 |
210 |
unless ( $found_exact_invnumber_match ) {
|
299 |
211 |
# use first returned entry, may not be the correct one if invnumber doesn't
|
300 |
212 |
# match uniquely
|
301 |
|
$form->{$form->{vc}} = $form->{AR}[0]{name};
|
302 |
213 |
$form->{customer_id} = $form->{AR}[0]{customer_id};
|
303 |
214 |
};
|
304 |
215 |
} else {
|
305 |
216 |
# s.o. nur für zahlungsausgang
|
306 |
217 |
AP->ap_transactions(\%myconfig, \%$form);
|
307 |
|
$form->{$form->{vc}} = $form->{AP}[0]{name};
|
|
218 |
$form->{vendor_id} = $form->{AP}[0]{vendor_id};
|
308 |
219 |
}
|
309 |
220 |
}
|
310 |
221 |
|
311 |
222 |
# determine customer/vendor
|
312 |
|
if ( $form->{customer_id} and ($form->{invnumber} or $form->{customernumber}) ) {
|
313 |
|
# we already know the exact customer_id, so fill $form with customer data
|
|
223 |
my $vc = $form->{vc};
|
|
224 |
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
|
314 |
225 |
IS->get_customer(\%myconfig, \%$form);
|
315 |
|
$updated = 1;
|
316 |
|
} else {
|
317 |
|
# check_name is called with "customer" or "vendor" and otherwise uses contents of $form
|
318 |
|
# check_name also runs get_customer/get_vendor
|
319 |
|
$updated = &check_name($form->{vc});
|
320 |
|
};
|
321 |
|
|
322 |
|
if ($new_name_selected || $updated) {
|
323 |
|
# get open invoices from ar/ap using $form->{vc} and a.${vc}_id, i.e. customer_id
|
324 |
|
CP->get_openinvoices(\%myconfig, \%$form);
|
325 |
|
($newvc) = split /--/, $form->{ $form->{vc} };
|
326 |
|
$form->{"old$form->{vc}"} = qq|$newvc--$form->{"$form->{vc}_id"}|;
|
327 |
|
$updated = 1;
|
328 |
226 |
}
|
329 |
227 |
|
330 |
|
if ($form->{currency} ne $form->{oldcurrency}) {
|
331 |
|
$form->{oldcurrency} = $form->{currency};
|
332 |
|
if (!$updated) {
|
333 |
|
CP->get_openinvoices(\%myconfig, \%$form);
|
334 |
|
$updated = 1;
|
335 |
|
}
|
336 |
|
}
|
|
228 |
$form->{oldcurrency} = $form->{currency};
|
|
229 |
|
|
230 |
# get open invoices from ar/ap using a.${vc}_id, i.e. customer_id
|
|
231 |
CP->get_openinvoices(\%myconfig, \%$form) if $form->{"${vc}_id"};
|
337 |
232 |
|
338 |
233 |
if (!$form->{forex}) { # read exchangerate from input field (not hidden)
|
339 |
234 |
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate});
|
... | ... | |
343 |
238 |
|
344 |
239 |
$amount = $form->{amount} = $form->parse_amount(\%myconfig, $form->{amount});
|
345 |
240 |
|
346 |
|
if ($updated) {
|
|
241 |
if ($form->{"${vc}_id"}) {
|
347 |
242 |
$form->{rowcount} = 0;
|
348 |
243 |
|
349 |
244 |
$form->{queued} = "";
|
... | ... | |
408 |
303 |
$form->{amount}=$amount;
|
409 |
304 |
|
410 |
305 |
&form_header;
|
411 |
|
&list_invoices;
|
|
306 |
list_invoices() if $form->{"${vc}_id"};
|
412 |
307 |
&form_footer;
|
413 |
308 |
|
414 |
309 |
$lxdebug->leave_sub();
|
... | ... | |
449 |
344 |
|
450 |
345 |
my ($closedto, $datepaid, $amount);
|
451 |
346 |
|
452 |
|
&check_name($form->{vc});
|
|
347 |
my $vc = $form->{vc};
|
|
348 |
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
|
|
349 |
IS->get_customer(\%myconfig, $form) if $vc eq 'customer';
|
|
350 |
IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor';
|
|
351 |
}
|
453 |
352 |
|
454 |
353 |
if ($form->{currency} ne $form->{oldcurrency}) {
|
455 |
354 |
&update;
|
Zahlungsein-/-ausgänge: Kunden-/Lieferantenpicker verwenden