Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 35efaa4a

Von Tamino Steinert vor fast 2 Jahren hinzugefügt

  • ID 35efaa4a63f15322a98dd99b1c255972e5cdefc6
  • Vorgänger 92e904d1
  • Nachfolger 75cb7791

InvoiceItem: Lade überlagerte Konten und Steuern

Wenn nichts hinterlegt ist, dann verwende die Defaultwerte.

Unterschiede anzeigen:

SL/IR.pm
1056 1056
        i.price_factor_id, i.price_factor, i.marge_price_factor, i.discount, i.active_price_source, i.active_discount_source,
1057 1057
        p.partnumber, p.part_type, pr.projectnumber, pg.partsgroup
1058 1058
        ,p.classification_id
1059
        ,i.expense_chart_id, ec.accno AS expense_chart_accno, i.tax_id, i.inventory_chart_id
1059 1060

  
1060 1061
        FROM invoice i
1061 1062
        JOIN parts p ON (i.parts_id = p.id)
1062 1063
        LEFT JOIN chart c1 ON ((SELECT inventory_accno_id             FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id)
1063 1064
        LEFT JOIN chart c2 ON ((SELECT tc.income_accno_id FROM taxzone_charts tc where tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c2.id)
1064 1065
        LEFT JOIN chart c3 ON ((SELECT tc.expense_accno_id FROM taxzone_charts tc where tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c3.id)
1066
        LEFT JOIN chart ec ON (expense_chart_id = ec.id)
1065 1067
        LEFT JOIN project pr    ON (i.project_id = pr.id)
1066 1068
        LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
1067 1069

  
......
1089 1091
    }
1090 1092

  
1091 1093
    # get tax rates and description
1092
    my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
1093
    $query =
1094
      qq|SELECT c.accno, t.taxdescription, t.rate, t.id as tax_id,
1095
                c.accno as taxnumber   -- taxnumber is same as accno, but still accessed as taxnumber in code
1096
         FROM tax t
1097
         LEFT JOIN chart c ON (c.id = t.chart_id)
1098
         WHERE t.id in
1099
           (SELECT tk.tax_id FROM taxkeys tk
1100
            WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?)
1101
              AND (startdate <= $transdate)
1102
            ORDER BY startdate DESC
1103
            LIMIT 1)
1104
         ORDER BY c.accno|;
1105
    my $stw = prepare_execute_query($form, $dbh, $query, $accno_id);
1106
    $ref->{taxaccounts} = "";
1094
    my $get_default_tax = $ref->{tax_id} eq '' ? 1 : 0;
1095
    my $stw;
1096
    if ($get_default_tax) {
1097
      my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
1098
      my $query =
1099
        qq|SELECT c.accno, t.taxdescription, t.rate, t.id as tax_id,
1100
                  c.accno as taxnumber   -- taxnumber is same as accno, but still accessed as taxnumber in code
1101
           FROM tax t
1102
           LEFT JOIN chart c ON (c.id = t.chart_id)
1103
           WHERE t.id in
1104
             (SELECT tk.tax_id FROM taxkeys tk
1105
              WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?)
1106
                AND (startdate <= $transdate)
1107
              ORDER BY startdate DESC
1108
              LIMIT 1)
1109
           ORDER BY c.accno|;
1110
      $stw = prepare_execute_query($form, $dbh, $query, $accno_id);
1111

  
1112
    } else { # use saved tax_id
1113
      my $query =
1114
        qq|SELECT c.accno, t.taxdescription, t.rate, t.id as tax_id,
1115
                  c.accno as taxnumber   -- taxnumber is same as accno, but still accessed as taxnumber in code
1116
           FROM tax t
1117
           LEFT JOIN chart c ON (c.id = t.chart_id)
1118
           WHERE t.id = ?
1119
           ORDER BY c.accno|;
1120

  
1121
      $stw = prepare_execute_query($form, $dbh, $query, $ref->{tax_id});
1122
    }
1107 1123

  
1108
    my $i = 0;
1124
    $ref->{taxaccounts} = "";
1109 1125
    while (my $ptr = $stw->fetchrow_hashref("NAME_lc")) {
1110 1126
      if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) {
1111
        $i++;
1112
        $ptr->{accno} = $i;
1127
        $ptr->{accno} = "NO_ACCNO_" . $ptr->{tax_id};
1113 1128
      }
1114 1129

  
1115 1130
      $ref->{taxaccounts} .= "$ptr->{accno} ";

Auch abrufbar als: Unified diff