276 |
276 |
# add entry for inventory, this one is for the sold item
|
277 |
277 |
if ($linetotal != 0) {
|
278 |
278 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
|
279 |
|
transdate)
|
|
279 |
transdate, taxkey)
|
280 |
280 |
VALUES ($ref->{trans_id}, $ref->{inventory_accno_id},
|
281 |
|
$linetotal, '$ref->{transdate}')|;
|
|
281 |
$linetotal, '$ref->{transdate}', (SELECT taxkey_id FROM chart WHERE id = $ref->{inventory_accno_id}))|;
|
282 |
282 |
$dbh->do($query) || $form->dberror($query);
|
283 |
283 |
|
284 |
284 |
# add expense
|
... | ... | |
522 |
522 |
|
523 |
523 |
if ($form->{amount}{ $form->{id} }{ $form->{AP} } != 0) {
|
524 |
524 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
|
525 |
|
transdate, project_id)
|
|
525 |
transdate, taxkey, project_id)
|
526 |
526 |
VALUES ($form->{id}, (SELECT c.id FROM chart c
|
527 |
|
WHERE c.accno = '$form->{AP}'),
|
528 |
|
$amount, '$form->{"datepaid_$i"}', ?)|;
|
529 |
|
do_query($form, $dbh, $query, $project_id);
|
|
527 |
WHERE c.accno = ?),
|
|
528 |
$amount, '$form->{"datepaid_$i"}',
|
|
529 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
|
|
530 |
do_query($form, $dbh, $query, $form->{AP}, $form->{AP}, $project_id);
|
530 |
531 |
}
|
531 |
532 |
|
532 |
533 |
# record payment
|
533 |
534 |
|
534 |
535 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
|
535 |
|
source, memo, project_id)
|
|
536 |
source, memo, taxkey, project_id)
|
536 |
537 |
VALUES ($form->{id}, (SELECT c.id FROM chart c
|
537 |
|
WHERE c.accno = '$accno'),
|
|
538 |
WHERE c.accno = ?),
|
538 |
539 |
$form->{"paid_$i"}, '$form->{"datepaid_$i"}',
|
539 |
|
'$form->{"source_$i"}', '$form->{"memo_$i"}', ?)|;
|
540 |
|
do_query($form, $dbh, $query, $project_id);
|
|
540 |
'$form->{"source_$i"}', '$form->{"memo_$i"}',
|
|
541 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
|
|
542 |
do_query($form, $dbh, $query, $accno, $accno, $project_id);
|
541 |
543 |
|
542 |
544 |
$exchangerate = 0;
|
543 |
545 |
|
... | ... | |
591 |
593 |
) {
|
592 |
594 |
|
593 |
595 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
|
594 |
|
transdate, cleared, fx_transaction, project_id)
|
|
596 |
transdate, cleared, fx_transaction, taxkey, project_id)
|
595 |
597 |
VALUES ($form->{id}, (SELECT c.id FROM chart c
|
596 |
598 |
WHERE c.accno = '$accno'),
|
597 |
|
$form->{fx}{$accno}{$transdate}, '$transdate', '0', '1', ?)|;
|
|
599 |
$form->{fx}{$accno}{$transdate}, '$transdate', '0', '1', 0, ?)|;
|
598 |
600 |
do_query($form, $dbh, $query, $project_id);
|
599 |
601 |
}
|
600 |
602 |
}
|
... | ... | |
1355 |
1357 |
$dbh->do($query) || $form->dberror($query);
|
1356 |
1358 |
|
1357 |
1359 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
|
1358 |
|
transdate, project_id)
|
|
1360 |
transdate, taxkey, project_id)
|
1359 |
1361 |
VALUES ($form->{id}, (SELECT c.id FROM chart c
|
1360 |
|
WHERE c.accno = '$form->{AP}'),
|
1361 |
|
$amount, '$form->{"datepaid_$i"}', ?)|;
|
1362 |
|
do_query($form, $dbh, $query, $project_id);
|
|
1362 |
WHERE c.accno = ?),
|
|
1363 |
$amount, '$form->{"datepaid_$i"}',
|
|
1364 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
|
|
1365 |
do_query($form, $dbh, $query, $form->{AP}, $form->{AP}, $project_id);
|
1363 |
1366 |
|
1364 |
1367 |
|
1365 |
1368 |
|
... | ... | |
1368 |
1371 |
$dbh->do($query) || $form->dberror($query);
|
1369 |
1372 |
|
1370 |
1373 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
|
1371 |
|
source, memo, project_id)
|
|
1374 |
source, memo, taxkey, project_id)
|
1372 |
1375 |
VALUES ($form->{id}, (SELECT c.id FROM chart c
|
1373 |
|
WHERE c.accno = '$accno'),
|
|
1376 |
WHERE c.accno = ?),
|
1374 |
1377 |
$form->{"paid_$i"}, '$form->{"datepaid_$i"}',
|
1375 |
|
'$form->{"source_$i"}', '$form->{"memo_$i"}', ?)|;
|
1376 |
|
do_query($form, $dbh, $query, $project_id);
|
|
1378 |
'$form->{"source_$i"}', '$form->{"memo_$i"}',
|
|
1379 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
|
|
1380 |
do_query($form, $dbh, $query, $accno, $accno, $project_id);
|
1377 |
1381 |
|
1378 |
1382 |
|
1379 |
1383 |
# gain/loss
|
... | ... | |
1411 |
1415 |
WHERE c.accno = '$accno') AND amount=$form->{fx}{$accno}{$transdate} AND transdate='$transdate' AND cleared='0' AND fx_transaction='1'|;
|
1412 |
1416 |
$dbh->do($query) || $form->dberror($query);
|
1413 |
1417 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
|
1414 |
|
transdate, cleared, fx_transaction, project_id)
|
|
1418 |
transdate, cleared, fx_transaction, taxkey, project_id)
|
1415 |
1419 |
VALUES ($form->{id},
|
1416 |
1420 |
(SELECT c.id FROM chart c
|
1417 |
|
WHERE c.accno = '$accno'),
|
1418 |
|
$form->{fx}{$accno}{$transdate}, '$transdate', '0', '1', ?)|;
|
1419 |
|
do_query($form, $dbh, $query, $project_id);
|
|
1421 |
WHERE c.accno = ?),
|
|
1422 |
$form->{fx}{$accno}{$transdate}, '$transdate', '0', '1',
|
|
1423 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
|
|
1424 |
do_query($form, $dbh, $query, $accno, $accno, $project_id);
|
1420 |
1425 |
}
|
1421 |
1426 |
}
|
1422 |
1427 |
}
|
Einkaufs- und Verkaufsrechnungen: Beim Erstellen der Einträge in acc_trans keine leeren Felder für taxkey erzeugen.