Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f36eb9fc

Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt

  • ID f36eb9fca78c4940b486b7dafa4ab636cdaf99cd
  • Vorgänger 9c5108ec
  • Nachfolger e70d4cf2

Die Funktion "Zahlung buchen" bei Debitorenrechnungen komplett umgeschrieben. Sie verlässt sich nun nicht mehr auf die aktuellen Daten in $form, um die alten Einträge in acc_trans zu löschen, sondern lädt den vorherigen Stand aus der Datenbank, entfernt darauf basierend die Einträge in acc_trans und lässt AR->post_transaction() selber die Zahlungen eintragen.

Unterschiede anzeigen:

bin/mozilla/ar.pl
177 177
  # build the popup menus
178 178
  $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
179 179

  
180
  # forex
181
  $form->{forex} = $form->{exchangerate};
182
  $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
183
  foreach $key (keys %{ $form->{AR_links} }) {
184
    # if there is a value we have an old entry
185
    my $j = 0;
186
    my $k = 0;
187

  
188
    for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
189
      if ($key eq "AR_paid") {
190
        $j++;
191
        $form->{"AR_paid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{accno};
192

  
193
        # reverse paid
194
        $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
195
        $form->{"datepaid_$j"} =
196
          $form->{acc_trans}{$key}->[$i - 1]->{transdate};
197
        $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
198
        $form->{"memo_$j"}   = $form->{acc_trans}{$key}->[$i - 1]->{memo};
199

  
200
        $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
201
          $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
202
        $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
203
        $form->{paidaccounts}++;
204

  
205
      } else {
206

  
207
        $akey = $key;
208
        $akey =~ s/AR_//;
209

  
210
        if ($key eq "AR_tax" || $key eq "AP_tax") {
211
          $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
212
            "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
213
          $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
214
            $form->round_amount(
215
                  $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
216
                  2);
217

  
218
          if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
219
            $totaltax +=
220
              $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
221
            $taxrate +=
222
              $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
223
          } else {
224
            $totalwithholding +=
225
              $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
226
            $withholdingrate +=
227
              $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
228
          }
229
          $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
230
          $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
231
          $totaltax += $form->{"tax_$index"};
232

  
233
        } else {
234
          $k++;
235
          $form->{"${akey}_$k"} =
236
            $form->round_amount(
237
                  $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
238
                  2);
239
          if ($akey eq 'amount') {
240
            $form->{rowcount}++;
241
            $totalamount += $form->{"${akey}_$i"};
242

  
243
            $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
244
              "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
245
            $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
246
            $form->{"project_id_$k"} =
247
              "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
248
          }
249
          $form->{"${key}_$i"} =
250
            "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
251

  
252
          if ($akey eq "AR") {
253
            $form->{ARselected} = $form->{acc_trans}{$key}->[$i-1]->{accno};
254

  
255
          } elsif ($akey eq "amount") {
256
            $form->{"${key}_$k"} = $form->{acc_trans}{$key}->[$i-1]->{accno} .
257
              "--" . $form->{acc_trans}{$key}->[$i-1]->{id};
258
            $form->{"taxchart_$k"} = $form->{acc_trans}{$key}->[$i-1]->{id} .
259
              "--" . $form->{acc_trans}{$key}->[$i-1]->{rate};
260
          }
261
        }
262
      }
263
    }
264
  }
265

  
266
  $form->{taxincluded}  = $taxincluded if ($form->{id});
267
  $form->{paidaccounts} = 1            if not defined $form->{paidaccounts};
268

  
269
  if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
270

  
271
    # add tax to amounts and invtotal
272
    for $i (1 .. $form->{rowcount}) {
273
      $taxamount =
274
        ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
275
      $tax = $form->round_amount($taxamount, 2);
276
      $diff                += ($taxamount - $tax);
277
      $form->{"amount_$i"} += $form->{"tax_$i"};
278
    }
279
    $form->{amount_1} += $form->round_amount($diff, 2);
280
  }
281

  
282
  $taxamount = $form->round_amount($taxamount, 2);
283
  $form->{tax} = $taxamount;
284

  
285
  $form->{invtotal} = $totalamount + $totaltax;
180
  AR->setup_form($form);
286 181

  
287 182
  $form->{locked} =
288 183
    ($form->datetonum($form->{transdate}, \%myconfig) <=

Auch abrufbar als: Unified diff