Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision da784064

Von Tamino Steinert vor fast 2 Jahren hinzugefügt

  • ID da7840645490175df18da4908a6a9e1fe8b0b5c2
  • Vorgänger fc3b49d6
  • Nachfolger cfda5e71

InvoiceItem: Lade überlagerte Konten und Steuern

Wenn nichts hinterlegt ist, dann verwende die Defaultwerte.

Unterschiede anzeigen:

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

  
1058 1059
        FROM invoice i
1059 1060
        JOIN parts p ON (i.parts_id = p.id)
1060 1061
        LEFT JOIN chart c1 ON ((SELECT inventory_accno_id             FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id)
1061 1062
        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)
1062 1063
        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)
1064
        LEFT JOIN chart ec ON (expense_chart_id = ec.id)
1063 1065
        LEFT JOIN project pr    ON (i.project_id = pr.id)
1064 1066
        LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
1065 1067

  
......
1087 1089
    }
1088 1090

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

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

  
1119
      $stw = prepare_execute_query($form, $dbh, $query, $ref->{tax_id});
1120
    }
1105 1121

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

  
1113 1128
      $ref->{taxaccounts} .= "$ptr->{accno} ";

Auch abrufbar als: Unified diff