From fe3df36071968d9f22c33f40adfc87717a578b1b Mon Sep 17 00:00:00 2001
From: Philip Reetz
Date: Mon, 15 Jan 2007 14:34:50 +0000
Subject: [PATCH] Fehler beim Buchen. Wenn EUR gesetzt war, wurde bei
Eingangsrechnungen das Bestandskonto angesprochen. Wenn EUR nicht gesetzt
war, wurden beim Verkauf die Kosten nicht vom Bestands- auf Kostenkonto
umgebucht
---
SL/IR.pm | 4 ++++
SL/IS.pm | 23 +++++++++++++----------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/SL/IR.pm b/SL/IR.pm
index 56207bf1b..5a4a2d7f9 100644
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -107,6 +107,10 @@ sub post_invoice {
if ($form->{storno}) {
$form->{"qty_$i"} *= -1;
}
+
+ if ($main::eur) {
+ $form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"};
+ }
if ($form->{"qty_$i"} != 0) {
diff --git a/SL/IS.pm b/SL/IS.pm
index 7df695efb..24f8f0f17 100644
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -672,7 +672,7 @@ sub post_invoice {
$baseqty * -1)
unless $form->{shipped};
- $allocated = &cogs($dbh, $form, $form->{"id_$i"}, $baseqty, $basefactor);
+ $allocated = &cogs($dbh, $form, $form->{"id_$i"}, $baseqty, $basefactor, $i);
}
}
@@ -1239,14 +1239,17 @@ sub process_assembly {
sub cogs {
$main::lxdebug->enter_sub();
- my ($dbh, $form, $id, $totalqty, $basefactor) = @_;
-
+ my ($dbh, $form, $id, $totalqty, $basefactor, $row) = @_;
+ $form->{taxzone_id} *=1;
+ my $transdate = ($form->{invdate}) ? "'$form->{invdate}'" : "current_date";
my $query = qq|SELECT i.id, i.trans_id, i.base_qty, i.allocated, i.sellprice,
- (SELECT c.accno FROM chart c
- WHERE p.inventory_accno_id = c.id) AS inventory_accno,
- (SELECT c.accno FROM chart c
- WHERE p.expense_accno_id = c.id) AS expense_accno
+ c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, date($transdate) - c1.valid_from as inventory_valid,
+ c2.accno AS income_accno, c2.new_chart_id AS income_new_chart, date($transdate) - c2.valid_from as income_valid,
+ c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from as expense_valid
FROM invoice i, parts p
+ LEFT JOIN chart c1 ON ((select inventory_accno_id from buchungsgruppen where id=p.buchungsgruppen_id) = c1.id)
+ LEFT JOIN chart c2 ON ((select income_accno_id_$form->{taxzone_id} from buchungsgruppen where id=p.buchungsgruppen_id) = c2.id)
+ LEFT JOIN chart c3 ON ((select expense_accno_id_$form->{taxzone_id} from buchungsgruppen where id=p.buchungsgruppen_id) = c3.id)
WHERE i.parts_id = p.id
AND i.parts_id = $id
AND (i.base_qty + i.allocated) < 0
@@ -1269,12 +1272,12 @@ sub cogs {
# sellprice is the cost of the item
$linetotal = $form->round_amount(($ref->{sellprice} * $qty) / $basefactor, 2);
- if (!$eur) {
-
+ if (!$main::eur) {
+ $ref->{expense_accno} = ($form->{"expense_accno_$row"}) ? $form->{"expense_accno_$row"} : $ref->{expense_accno};
# add to expense
$form->{amount}{ $form->{id} }{ $ref->{expense_accno} } += -$linetotal;
$form->{expense_inventory} .= " " . $ref->{expense_accno};
-
+ $ref->{inventory_accno} = ($form->{"inventory_accno_$row"}) ? $form->{"inventory_accno_$row"} : $ref->{inventory_accno};
# deduct inventory
$form->{amount}{ $form->{id} }{ $ref->{inventory_accno} } -= -$linetotal;
$form->{expense_inventory} .= " " . $ref->{inventory_accno};
--
2.20.1