Revision 1118dab9
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
bin/mozilla/ap.pl | ||
---|---|---|
158 | 158 |
|
159 | 159 |
$form->{employee} = "$form->{employee}--$form->{employee_id}"; |
160 | 160 |
|
161 |
# forex |
|
162 |
$form->{forex} = $form->{exchangerate}; |
|
163 |
$exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1; |
|
164 |
|
|
165 |
foreach $key (keys %{ $form->{AP_links} }) { |
|
166 |
foreach $ref (@{ $form->{AP_links}{$key} }) { |
|
167 |
if ($key eq "AP_paid") { |
|
168 |
$form->{"select$key"} .= |
|
169 |
"<option value=\"$ref->{accno}\">$ref->{accno}--$ref->{description}</option>\n"; |
|
170 |
} else { |
|
171 |
$form->{"select$key"} .= |
|
172 |
"<option value=\"$ref->{accno}--$ref->{tax_id}\">$ref->{accno}--$ref->{description}</option>\n"; |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
$form->{$key} = $form->{"select$key"}; |
|
177 |
|
|
178 |
# if there is a value we have an old entry |
|
179 |
my $j = 0; |
|
180 |
my $k = 0; |
|
181 |
|
|
182 |
for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) { |
|
183 |
|
|
184 |
if ($key eq "AP_paid") { |
|
185 |
$j++; |
|
186 |
$form->{"AP_paid_$j"} = |
|
187 |
"$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; |
|
188 |
$form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount}; |
|
189 |
$form->{"datepaid_$j"} = |
|
190 |
$form->{acc_trans}{$key}->[$i - 1]->{transdate}; |
|
191 |
$form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source}; |
|
192 |
$form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo}; |
|
193 |
|
|
194 |
$form->{"forex_$j"} = $form->{"exchangerate_$i"} = |
|
195 |
$form->{acc_trans}{$key}->[$i - 1]->{exchangerate}; |
|
196 |
$form->{"AP_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}"; |
|
197 |
$form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id}; |
|
198 |
$form->{paidaccounts}++; |
|
199 |
} else { |
|
200 |
|
|
201 |
$akey = $key; |
|
202 |
$akey =~ s/AP_//; |
|
203 |
|
|
204 |
if (($key eq "AP_tax") || ($key eq "AR_tax")) { |
|
205 |
$form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} = |
|
206 |
"$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; |
|
207 |
$form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} = |
|
208 |
$form->round_amount( |
|
209 |
$form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate, |
|
210 |
2); |
|
211 |
|
|
212 |
if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) { |
|
213 |
$totaltax += |
|
214 |
$form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"}; |
|
215 |
} else { |
|
216 |
$totalwithholding += |
|
217 |
$form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"}; |
|
218 |
$withholdingrate += |
|
219 |
$form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"}; |
|
220 |
} |
|
221 |
$index = $form->{acc_trans}{$key}->[$i - 1]->{index}; |
|
222 |
$form->{"tax_$index"} = |
|
223 |
$form->{acc_trans}{$key}->[$i - 1]->{amount} * -1; |
|
224 |
$totaltax += $form->{"tax_$index"}; |
|
225 |
|
|
226 |
} else { |
|
227 |
$k++; |
|
228 |
$form->{"${akey}_$k"} = |
|
229 |
$form->round_amount( |
|
230 |
$form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate, |
|
231 |
2); |
|
232 |
if ($akey eq 'amount') { |
|
233 |
$form->{rowcount}++; |
|
234 |
$form->{"${akey}_$i"} *= -1; |
|
235 |
$totalamount += $form->{"${akey}_$i"}; |
|
236 |
$form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate}; |
|
237 |
$form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} = |
|
238 |
"$form->{acc_trans}{$key}->[$i-1]->{projectnumber}"; |
|
239 |
$form->{"project_id_$k"} = |
|
240 |
"$form->{acc_trans}{$key}->[$i-1]->{project_id}"; |
|
241 |
} |
|
242 |
$form->{"${key}_$k"} = |
|
243 |
"$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; |
|
244 |
my $q_description = quotemeta($form->{acc_trans}{$key}->[$i-1]->{description}); |
|
245 |
$form->{"select${key}"} =~ |
|
246 |
/<option value=\"($form->{acc_trans}{$key}->[$i-1]->{accno}--[^\"]*)\">$form->{acc_trans}{$key}->[$i-1]->{accno}--${q_description}<\/option>\n/; |
|
247 |
$form->{"${key}_$k"} = $1; |
|
248 |
|
|
249 |
if ($akey eq "AP") { |
|
250 |
$form->{APselected} = $form->{acc_trans}{$key}->[$i-1]->{accno}; |
|
251 |
|
|
252 |
} elsif ($akey eq 'amount') { |
|
253 |
$form->{"${key}_$k"} = $form->{acc_trans}{$key}->[$i-1]->{accno} . |
|
254 |
"--" . $form->{acc_trans}{$key}->[$i-1]->{id}; |
|
255 |
$form->{"taxchart_$k"} = $form->{acc_trans}{$key}->[$i-1]->{id} . |
|
256 |
"--" . $form->{acc_trans}{$key}->[$i-1]->{rate}; |
|
257 |
} |
|
258 |
} |
|
259 |
} |
|
260 |
} |
|
261 |
} |
|
262 |
|
|
263 |
$form->{taxincluded} = $taxincluded if ($form->{id}); |
|
264 |
$form->{paidaccounts} = 1 if not defined $form->{paidaccounts}; |
|
265 |
|
|
266 |
if ($form->{taxincluded} && $form->{taxrate} && $totalamount) { |
|
267 |
|
|
268 |
# add tax to amounts and invtotal |
|
269 |
for $i (1 .. $form->{rowcount}) { |
|
270 |
$taxamount = |
|
271 |
($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount; |
|
272 |
$tax = $form->round_amount($taxamount, 2); |
|
273 |
$diff += ($taxamount - $tax); |
|
274 |
$form->{"amount_$i"} += $form->{"tax_$i"}; |
|
275 |
} |
|
276 |
$form->{amount_1} += $form->round_amount($diff, 2); |
|
277 |
} |
|
278 |
|
|
279 |
$taxamount = $form->round_amount($taxamount, 2); |
|
280 |
|
|
281 |
$form->{invtotal} = $totalamount + $totaltax; |
|
161 |
AP->setup_form($form); |
|
282 | 162 |
|
283 | 163 |
$form->{locked} = |
284 | 164 |
($form->datetonum($form->{transdate}, \%myconfig) <= |
... | ... | |
872 | 752 |
$transdate = $form->datetonum($form->{transdate}, \%myconfig); |
873 | 753 |
$closedto = $form->datetonum($form->{closedto}, \%myconfig); |
874 | 754 |
|
875 |
# ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it |
|
876 |
print qq|<input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|">| |
|
877 |
if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap') && !$form->{paid_1}); |
|
878 |
|
|
879 | 755 |
print qq|<input class="submit" type="submit" name="action" id="update_button" value="| . $locale->text('Update') . qq|">|; |
880 | 756 |
|
881 | 757 |
if ($form->{id}) { |
... | ... | |
885 | 761 |
|; |
886 | 762 |
} |
887 | 763 |
|
888 |
print qq| <input class=submit type=submit name=action value="| . $locale->text('Use As Template') . qq|"> |
|
889 |
<input class=submit type=submit name=action value="| . $locale->text('Post Payment') . qq|"> |
|
764 |
# ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it |
|
765 |
print qq|<input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|"> | |
|
766 |
if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap') && !$form->{paid_1}); |
|
767 |
|
|
768 |
print qq| <input class=submit type=submit name=action value="| . $locale->text('Post Payment') . qq|"> |
|
769 |
<input class=submit type=submit name=action value="| . $locale->text('Use As Template') . qq|"> |
|
890 | 770 |
|; |
891 | 771 |
} elsif (($transdate > $closedto) && !$form->{id}) { |
892 | 772 |
print qq| |
Auch abrufbar als: Unified diff
Die Funktion "Zahlung buchen" bei Kreditorenrechnungen komplett umgeschrieben. Sie verlässt sich nun nicht mehr auf die aktuellen Daten in $form, um die alten Einträge in acc_trans zu löschen, sondern lädt den vorherigen Stand aus der Datenbank, entfernt darauf basierend die Einträge in acc_trans und lässt AP->post_transaction() selber die Zahlungen eintragen.
Zusätzlich den Button "Storno" in der Buttonleiste weiter nach rechts verschoben, sodass wie überall der "Erneuern"-Button der Standardbutton ist.