Revision 357d134d
Von Niclas Zimmermann vor fast 12 Jahren hinzugefügt
SL/AP.pm | ||
---|---|---|
209 | 209 |
# insert detail records in acc_trans |
210 | 210 |
$query = |
211 | 211 |
qq|INSERT INTO acc_trans | . |
212 |
qq| (trans_id, chart_id, amount, transdate, project_id, taxkey)| . |
|
212 |
qq| (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id)| .
|
|
213 | 213 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), | . |
214 |
qq| ?, ?, ?, ?)|; |
|
214 |
qq| ?, ?, ?, ?, (SELECT tax_id FROM taxkeys WHERE taxkey_id= (SELECT taxkey_id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|;
|
|
215 | 215 |
@values = ($form->{id}, $form->{AP_amounts}{"amount_$i"}, |
216 | 216 |
$form->{"amount_$i"}, conv_date($form->{transdate}), |
217 |
$project_id, $form->{"taxkey_$i"}); |
|
217 |
$project_id, $form->{"taxkey_$i"}, $form->{AP_amounts}{"amount_$i"}, conv_date($form->{transdate}));
|
|
218 | 218 |
do_query($form, $dbh, $query, @values); |
219 | 219 |
|
220 | 220 |
if ($form->{"tax_$i"} != 0) { |
221 | 221 |
# insert detail records in acc_trans |
222 | 222 |
$query = |
223 | 223 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, | . |
224 |
qq| project_id, taxkey) | . |
|
224 |
qq| project_id, taxkey, tax_id) | .
|
|
225 | 225 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), | . |
226 |
qq| ?, ?, ?, ?)|; |
|
226 |
qq| ?, ?, ?, ?, (SELECT tax_id FROM taxkeys WHERE taxkey_id= (SELECT taxkey_id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|;
|
|
227 | 227 |
@values = ($form->{id}, $form->{AP_amounts}{"tax_$i"}, |
228 | 228 |
$form->{"tax_$i"}, conv_date($form->{transdate}), |
229 |
$project_id, $form->{"taxkey_$i"}); |
|
229 |
$project_id, $form->{"taxkey_$i"}, $form->{AP_amounts}{"tax_$i"}, conv_date($form->{transdate}));
|
|
230 | 230 |
do_query($form, $dbh, $query, @values); |
231 | 231 |
} |
232 | 232 |
|
... | ... | |
235 | 235 |
|
236 | 236 |
# add payables |
237 | 237 |
$query = |
238 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) | . |
|
238 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) | .
|
|
239 | 239 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, | . |
240 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
240 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?),| . |
|
241 |
qq| (SELECT tax_id FROM taxkeys WHERE taxkey_id= (SELECT taxkey_id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
241 | 242 |
@values = ($form->{id}, $form->{AP_amounts}{payables}, $form->{payables}, |
242 |
conv_date($form->{transdate}), $form->{AP_amounts}{payables}); |
|
243 |
conv_date($form->{transdate}), $form->{AP_amounts}{payables}, $form->{AP_amounts}{payables}, conv_date($form->{transdate}));
|
|
243 | 244 |
do_query($form, $dbh, $query, @values); |
244 | 245 |
} |
245 | 246 |
|
... | ... | |
283 | 284 |
2); |
284 | 285 |
if ($form->{payables}) { |
285 | 286 |
$query = |
286 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . |
|
287 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id) | .
|
|
287 | 288 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . |
288 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
289 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?),| . |
|
290 |
qq| (SELECT tax_id FROM taxkeys WHERE taxkey_id= (SELECT taxkey_id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
289 | 291 |
@values = ($form->{id}, $form->{AP_payables}, $amount, |
290 | 292 |
conv_date($form->{"datepaid_$i"}), $project_id, |
291 |
$form->{AP_payables}); |
|
293 |
$form->{AP_payables}, $form->{AP_payables}, conv_date($form->{"datepaid_$i"}));
|
|
292 | 294 |
do_query($form, $dbh, $query, @values); |
293 | 295 |
} |
294 | 296 |
$form->{payables} = $amount; |
... | ... | |
296 | 298 |
# add payment |
297 | 299 |
my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig)); |
298 | 300 |
$query = |
299 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey) | . |
|
301 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey, tax_id) | .
|
|
300 | 302 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, ?, | . |
301 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
303 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?), | . |
|
304 |
qq| (SELECT tax_id FROM taxkeys WHERE taxkey_id= (SELECT taxkey_id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
302 | 305 |
@values = ($form->{id}, $form->{"AP_paid_account_$i"}, $form->{"paid_$i"}, |
303 | 306 |
conv_date($form->{"datepaid_$i"}), $gldate, $form->{"source_$i"}, |
304 |
$form->{"memo_$i"}, $project_id, $form->{"AP_paid_account_$i"}); |
|
307 |
$form->{"memo_$i"}, $project_id, $form->{"AP_paid_account_$i"}, |
|
308 |
$form->{"AP_paid_account_$i"}, conv_date($form->{"datepaid_$i"})); |
|
305 | 309 |
do_query($form, $dbh, $query, @values); |
306 | 310 |
|
307 | 311 |
# add exchange rate difference |
... | ... | |
310 | 314 |
($form->{"exchangerate_$i"} - 1), 2); |
311 | 315 |
if ($amount != 0) { |
312 | 316 |
$query = |
313 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . |
|
317 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id) | .
|
|
314 | 318 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . |
315 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
319 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?), | . |
|
320 |
qq| (SELECT tax_id FROM taxkeys WHERE taxkey_id= (SELECT taxkey_id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
316 | 321 |
@values = ($form->{id}, $form->{"AP_paid_account_$i"}, $amount, |
317 | 322 |
conv_date($form->{"datepaid_$i"}), $project_id, |
318 |
$form->{"AP_paid_account_$i"}); |
|
323 |
$form->{"AP_paid_account_$i"}, |
|
324 |
$form->{"AP_paid_account_$i"}, conv_date($form->{"datepaid_$i"})); |
|
319 | 325 |
do_query($form, $dbh, $query, @values); |
320 | 326 |
} |
321 | 327 |
|
... | ... | |
327 | 333 |
|
328 | 334 |
if ($amount != 0) { |
329 | 335 |
$query = |
330 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . |
|
336 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id) | .
|
|
331 | 337 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . |
332 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
338 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?)| . |
|
339 |
qq| (SELECT tax_id FROM taxkeys WHERE taxkey_id= (SELECT taxkey_id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
333 | 340 |
@values = ($form->{id}, ($amount > 0) ? |
334 | 341 |
$form->{fxgain_accno} : $form->{fxloss_accno}, |
335 | 342 |
$amount, conv_date($form->{"datepaid_$i"}), $project_id, |
336 | 343 |
($amount > 0) ? |
337 |
$form->{fxgain_accno} : $form->{fxloss_accno}); |
|
344 |
$form->{fxgain_accno} : $form->{fxloss_accno}, |
|
345 |
($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}, conv_date($form->{"datepaid_$i"})); |
|
338 | 346 |
do_query($form, $dbh, $query, @values); |
339 | 347 |
} |
340 | 348 |
|
Auch abrufbar als: Unified diff
tax_id in acc_trans
Dieser Commit enthält das Update-Script um eine neue Spalte Namens
'tax_id' in die Tabelle 'acc_trans' einzufügen. Diese Spalte ist
ein Pflichtfeld.
Das Pflichtfeld wird jetzt immer geschrieben bei:
-VK-Rechnungen (auch automatisch erzeugten)
-EK-Rechnungen
-Kreditorenbuchungen
-Debitorenbuchungen
-Dialogbuchungen
Durch das Feld 'tax_id' können in der Tabelle tax der
Steuerschlüssel und der Steuersatz ausgelesen werden.
In diesem Commit wird allerdings der Wert in tax_id nur geschrieben,
im Moment wird er noch nirgendwo ausgelesen.