Revision a851fde7
Von Moritz Bunkus vor fast 18 Jahren hinzugefügt
SL/AP.pm | ||
---|---|---|
254 | 254 |
|
255 | 255 |
# add payables |
256 | 256 |
$query = |
257 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate) | . |
|
258 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?)|; |
|
257 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) | . |
|
258 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, | . |
|
259 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
259 | 260 |
@values = ($form->{id}, $form->{AP_amounts}{payables}, $form->{payables}, |
260 |
conv_date($form->{transdate})); |
|
261 |
conv_date($form->{transdate}), $form->{AP_amounts}{payables});
|
|
261 | 262 |
do_query($form, $dbh, $query, @values); |
262 | 263 |
|
263 | 264 |
# if there is no amount but a payment record a payable |
... | ... | |
301 | 302 |
2); |
302 | 303 |
if ($form->{payables}) { |
303 | 304 |
$query = |
304 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id) | . |
|
305 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?)|; |
|
305 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . |
|
306 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . |
|
307 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
306 | 308 |
@values = ($form->{id}, $form->{AP}{payables}, $amount, |
307 |
conv_date($form->{"datepaid_$i"}), $project_id); |
|
309 |
conv_date($form->{"datepaid_$i"}), $project_id, |
|
310 |
$form->{AP}{payables}); |
|
308 | 311 |
do_query($form, $dbh, $query, @values); |
309 | 312 |
} |
310 | 313 |
$form->{payables} = $amount; |
311 | 314 |
|
312 | 315 |
# add payment |
313 | 316 |
$query = |
314 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id) | . |
|
315 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|; |
|
317 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | . |
|
318 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | . |
|
319 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
316 | 320 |
@values = ($form->{id}, $form->{AP}{"paid_$i"}, $form->{"paid_$i"}, |
317 | 321 |
conv_date($form->{"datepaid_$i"}), $form->{"source_$i"}, |
318 |
$form->{"memo_$i"}, $project_id); |
|
322 |
$form->{"memo_$i"}, $project_id, $form->{AP}{"paid_$i"});
|
|
319 | 323 |
do_query($form, $dbh, $query, @values); |
320 | 324 |
|
321 | 325 |
# add exchange rate difference |
... | ... | |
324 | 328 |
($form->{"exchangerate_$i"} - 1), 2); |
325 | 329 |
if ($amount != 0) { |
326 | 330 |
$query = |
327 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id) | . |
|
328 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 't', 'f', ?)|; |
|
331 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . |
|
332 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . |
|
333 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
329 | 334 |
@values = ($form->{id}, $form->{AP}{"paid_$i"}, $amount, |
330 |
conv_date($form->{"datepaid_$i"}), $project_id); |
|
335 |
conv_date($form->{"datepaid_$i"}), $project_id, |
|
336 |
$form->{AP}{"paid_$i"}); |
|
331 | 337 |
do_query($form, $dbh, $query, @values); |
332 | 338 |
} |
333 | 339 |
|
... | ... | |
339 | 345 |
|
340 | 346 |
if ($amount != 0) { |
341 | 347 |
$query = |
342 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id) | . |
|
343 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 't', 'f', ?)|; |
|
348 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . |
|
349 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . |
|
350 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
344 | 351 |
@values = ($form->{id}, ($amount > 0) ? |
345 | 352 |
$form->{fxgain_accno} : $form->{fxloss_accno}, |
346 |
$amount, conv_date($form->{"datepaid_$i"}), $project_id); |
|
353 |
$amount, conv_date($form->{"datepaid_$i"}), $project_id, |
|
354 |
($amount > 0) ? |
|
355 |
$form->{fxgain_accno} : $form->{fxloss_accno}); |
|
347 | 356 |
do_query($form, $dbh, $query, @values); |
348 | 357 |
} |
349 | 358 |
|
... | ... | |
572 | 581 |
do_query($form, $dbh, $query, @values); |
573 | 582 |
|
574 | 583 |
$query = |
575 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id) | . |
|
576 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?)|; |
|
584 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . |
|
585 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . |
|
586 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
577 | 587 |
@values = ($form->{id}, $accno_ap, $amount, |
578 | 588 |
conv_date($form->{"datepaid_$i"}), |
579 |
conv_i($form->{"paid_project_id_$i"})); |
|
589 |
conv_i($form->{"paid_project_id_$i"}), $accno_ap);
|
|
580 | 590 |
do_query($form, $dbh, $query, @values); |
581 | 591 |
|
582 | 592 |
$query = |
... | ... | |
590 | 600 |
do_query($form, $dbh, $query, @values); |
591 | 601 |
|
592 | 602 |
$query = |
593 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id) | . |
|
594 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|; |
|
603 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | . |
|
604 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | . |
|
605 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
595 | 606 |
@values = ($form->{id}, $accno, $form->{"paid_$i"}, |
596 | 607 |
$form->{"datepaid_$i"}, |
597 | 608 |
$form->{"source_$i"}, $form->{"memo_$i"}, |
598 |
conv_i($form->{"paid_project_id_$i"})); |
|
609 |
conv_i($form->{"paid_project_id_$i"}), $accno);
|
|
599 | 610 |
do_query($form, $dbh, $query, @values); |
600 | 611 |
|
601 | 612 |
# gain/loss |
... | ... | |
639 | 650 |
do_query($form, $dbh, $query, @values); |
640 | 651 |
|
641 | 652 |
$query = |
642 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction) | . |
|
643 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 'f', 't')|; |
|
653 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey) | . |
|
654 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 'f', 't', | . |
|
655 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
644 | 656 |
@values = ($form->{id}, $accno, $form->{fx}{$accno}{$transdate}, |
645 |
conv_date($transdate)); |
|
657 |
conv_date($transdate), $accno);
|
|
646 | 658 |
do_query($form, $dbh, $query, @values); |
647 | 659 |
} |
648 | 660 |
} |
SL/AR.pm | ||
---|---|---|
244 | 244 |
|
245 | 245 |
# add recievables |
246 | 246 |
$query = |
247 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate) | . |
|
248 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?)|; |
|
249 |
@values = (conv_i($form->{id}), conv_i($form->{AR_amounts}{receivables}), |
|
250 |
conv_i($form->{receivables}), conv_date($form->{transdate})); |
|
247 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) | . |
|
248 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, | . |
|
249 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
250 |
@values = (conv_i($form->{id}), $form->{AR_amounts}{receivables}, |
|
251 |
conv_i($form->{receivables}), conv_date($form->{transdate}), |
|
252 |
$form->{AR_amounts}{receivables}); |
|
251 | 253 |
do_query($form, $dbh, $query, @values); |
252 | 254 |
|
253 | 255 |
# add paid transactions |
... | ... | |
286 | 288 |
if ($form->{receivables} != 0) { |
287 | 289 |
# add receivable |
288 | 290 |
$query = |
289 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id) | . |
|
290 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?)|; |
|
291 |
@values = (conv_i($form->{id}), conv_i($form->{AR}{receivables}), |
|
292 |
$amount, conv_date($form->{"datepaid_$i"}), $project_id); |
|
291 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . |
|
292 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . |
|
293 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
294 |
@values = (conv_i($form->{id}), $form->{AR}{receivables}, |
|
295 |
$amount, conv_date($form->{"datepaid_$i"}), $project_id, |
|
296 |
$form->{AR}{receivables}); |
|
293 | 297 |
do_query($form, $dbh, $query, @values); |
294 | 298 |
} |
295 | 299 |
$form->{receivables} = $amount; |
... | ... | |
299 | 303 |
# add payment |
300 | 304 |
$amount = $form->{"paid_$i"} * -1; |
301 | 305 |
$query = |
302 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id) | . |
|
303 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|; |
|
304 |
@values = (conv_i($form->{id}), conv_i($form->{AR}{"paid_$i"}), $amount, |
|
306 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | . |
|
307 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | . |
|
308 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
309 |
@values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, |
|
305 | 310 |
conv_date($form->{"datepaid_$i"}), $form->{"source_$i"}, |
306 |
$form->{"memo_$i"}, $project_id); |
|
311 |
$form->{"memo_$i"}, $project_id, $form->{AR}{"paid_$i"});
|
|
307 | 312 |
do_query($form, $dbh, $query, @values); |
308 | 313 |
|
309 | 314 |
# exchangerate difference for payment |
... | ... | |
314 | 319 |
|
315 | 320 |
if ($amount != 0) { |
316 | 321 |
$query = |
317 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id) | . |
|
318 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 't', 'f', ?)|; |
|
319 |
@values = (conv_i($form->{id}), conv_i($form->{AR}{"paid_$i"}), |
|
320 |
$amount, conv_date($form->{"datepaid_$i"}), $project_id); |
|
322 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . |
|
323 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . |
|
324 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
325 |
@values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, |
|
326 |
$amount, conv_date($form->{"datepaid_$i"}), $project_id, |
|
327 |
$form->{AR}{"paid_$i"}); |
|
321 | 328 |
do_query($form, $dbh, $query, @values); |
322 | 329 |
} |
323 | 330 |
|
... | ... | |
332 | 339 |
$accno = |
333 | 340 |
($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}; |
334 | 341 |
$query = |
335 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id) | . |
|
336 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 't', 'f', ?)|; |
|
342 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . |
|
343 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . |
|
344 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
337 | 345 |
@values = (conv_i($form->{id}), $accno, $amount, |
338 |
conv_date($form->{"datepaid_$i"}), $project_id); |
|
346 |
conv_date($form->{"datepaid_$i"}), $project_id, $accno);
|
|
339 | 347 |
do_query($form, $dbh, $query, @values); |
340 | 348 |
} |
341 | 349 |
} |
... | ... | |
424 | 432 |
do_query($form, $dbh, $query, @values); |
425 | 433 |
|
426 | 434 |
$query = |
427 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id) | . |
|
428 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?)|; |
|
435 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . |
|
436 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . |
|
437 |
qq| (SELECT taxkey_ FROM chart WHERE accno = ?))|; |
|
429 | 438 |
@values = (conv_i($form->{id}), $accno_ar, conv_i($amount), |
430 | 439 |
conv_date($form->{"datepaid_$i"}), $project_id); |
431 | 440 |
do_query($form, $dbh, $query, @values); |
... | ... | |
444 | 453 |
do_query($form, $dbh, $query, @values); |
445 | 454 |
|
446 | 455 |
$query = |
447 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id) | . |
|
448 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|; |
|
456 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | . |
|
457 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | . |
|
458 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
449 | 459 |
@values = (conv_i($form->{id}), $accno, conv_i($form->{"paid_$i"}), |
450 | 460 |
conv_date($form->{"datepaid_$i"}), |
451 | 461 |
$form->{"source_$i"}, $form->{"memo_$i"}, $project_id); |
... | ... | |
493 | 503 |
do_query($form, $dbh, $query, @values); |
494 | 504 |
|
495 | 505 |
$query = |
496 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, project_id) | . |
|
497 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, 'f', 't', ?)|; |
|
506 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, project_id, taxkey) | . |
|
507 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 'f', 't', ?, | . |
|
508 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; |
|
498 | 509 |
@values = (conv_i($form->{id}), $accno, |
499 |
conv_i($form->{fx}{$accno}{$transdate}), |
|
500 |
conv_date($transdate), $project_id); |
|
510 |
$form->{fx}{$accno}{$transdate}, |
|
511 |
conv_date($transdate), $project_id, |
|
512 |
$form->{fx}{$accno}{$transdate}); |
|
501 | 513 |
do_query($form, $dbh, $query, @values); |
502 | 514 |
} |
503 | 515 |
} |
Auch abrufbar als: Unified diff
Debitoren- und Kreditorenrechnungen: Beim Erstellen der Einträge in acc_trans keine leeren Felder für taxkey erzeugen.