Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1ae70a98

Von Sven Schöling vor mehr als 17 Jahren hinzugefügt

  • ID 1ae70a98a8bcff7609e7fff67fb24015d462da23
  • Vorgänger cae6316e
  • Nachfolger 3a4e1d5e

bin/mozilla/ar.pl auf use strict standard gebracht.

Debitoren storno umgeschrieben und Bug gefixt.

Unterschiede anzeigen:

SL/AR.pm
38 38
use SL::DBUtils;
39 39
use SL::MoreCommon;
40 40

  
41
our (%myconfig, $form);
42

  
41 43
sub post_transaction {
42 44
  $main::lxdebug->enter_sub();
43 45

  
......
102 104
  }
103 105

  
104 106
  # adjust paidaccounts if there is no date in the last row
105
  $form->{paidaccounts}-- unless $form->{"datepaid_$form->{paidaccounts}"};
106
  $form->{paid} = 0;
107

  
108
  # add payments
109
  for $i (1 .. $form->{paidaccounts}) {
110
    $form->{"paid_$i"} = $form->round_amount($form->parse_amount($myconfig, $form->{"paid_$i"}), 2);
111
    $form->{paid}     += $form->{"paid_$i"};
112
    $form->{datepaid}  = $form->{"datepaid_$i"};
113
  }
107
  # this does not apply to stornos, where the paid field is set manually
108
  unless ($form->{storno}) {
109
    $form->{paidaccounts}-- unless $form->{"datepaid_$form->{paidaccounts}"};
110
    $form->{paid} = 0;
111

  
112
    # add payments
113
    for $i (1 .. $form->{paidaccounts}) {
114
      $form->{"paid_$i"} = $form->round_amount($form->parse_amount($myconfig, $form->{"paid_$i"}), 2);
115
      $form->{paid}     += $form->{"paid_$i"};
116
      $form->{datepaid}  = $form->{"datepaid_$i"};
117
    }
114 118

  
115
  $form->{amount} = $form->{netamount} + $form->{total_tax};
116
  $form->{paid}   = $form->round_amount($form->{paid} * $form->{exchangerate}, 2);
119
    $form->{amount} = $form->{netamount} + $form->{total_tax};
120
  }
121
  $form->{paid}   = $form->round_amount($form->{paid} * ($form->{exchangerate} || 1), 2);
117 122

  
118 123
  ($null, $form->{employee_id}) = split /--/, $form->{employee};
119 124

  
......
605 610
  $form->{tax} = $taxamount;
606 611

  
607 612
  $form->{invtotal} = $totalamount + $totaltax;
613

  
614
  $main::lxdebug->leave_sub();
608 615
}
609 616

  
617
sub storno {
618
  $main::lxdebug->enter_sub();
619

  
620
  my ($self, $form, $myconfig, $id) = @_;
621

  
622
  my ($query, $new_id, $storno_row, $acc_trans_rows);
623
  my $dbh = $form->get_standard_dbh($myconfig);
624

  
625
  $query = qq|SELECT nextval('glid')|;
626
  ($new_id) = selectrow_query($form, $dbh, $query);
627

  
628
  $query = qq|SELECT * FROM ar WHERE id = ?|;
629
  $storno_row = selectfirst_hashref_query($form, $dbh, $query, $id);
630

  
631
  $storno_row->{id}         = $new_id;
632
  $storno_row->{storno_id}  = $id;
633
  $storno_row->{storno}     = 't';
634
  $storno_row->{invnumber}  = 'Storno-' . $storno_row->{invnumber};
635
  $storno_row->{amount}    *= -1;
636
  $storno_row->{netamount} *= -1;
637
  $storno_row->{paid}       = $storno_amount->{amount};
638

  
639
  delete @$storno_row{qw(itime mtime)};
640

  
641
  $query = sprintf 'INSERT INTO ar (%s) VALUES (%s)', join(', ', keys %$storno_row), join(', ', map '?', values %$storno_row);
642
  do_query($form, $dbh, $query, (values %$storno_row));
643

  
644
  $query = qq|UPDATE ar SET paid = amount + paid, storno = 't' WHERE id = ?|;
645
  do_query($form, $dbh, $query, $id);
646

  
647
  # now copy acc_trans entries
648
  $query = qq|SELECT * FROM acc_trans WHERE trans_id = ?|;
649
  for my $row (@{ selectall_hashref_query($form, $dbh, $query, $id) }) {
650
    delete @$row{qw(itime mtime)};
651
    $query = sprintf 'INSERT INTO acc_trans (%s) VALUES (%s)', join(', ', keys %$row), join(', ', map '?', values %$row);
652
    $row->{trans_id}   = $new_id;
653
    $row->{amount}    *= -1;
654
    do_query($form, $dbh, $query, (values %$row));
655
  }
656

  
657
  $dbh->commit;
658

  
659
  $main::lxdebug->leave_sub();
660
}
661

  
662

  
610 663
1;
611 664

  

Auch abrufbar als: Unified diff