Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision bdaa8c2f

Von Philip Reetz vor fast 18 Jahren hinzugefügt

  • ID bdaa8c2f669c9ddcc2f0c8989fed52559d59be43
  • Vorgänger 01b3feeb
  • Nachfolger cb0d3042

Bei Kreditoren- und Debitorenbuchungen eine Funktion zum spaeteren Buchen eines Zahlungseingangs
hinzugefuegt

Unterschiede anzeigen:

SL/AP.pm
490 490
  $main::lxdebug->leave_sub();
491 491
}
492 492

  
493

  
494
sub post_payment {
495
  $main::lxdebug->enter_sub();
496

  
497
  my ($self, $myconfig, $form, $locale) = @_;
498

  
499
  # connect to database, turn off autocommit
500
  my $dbh = $form->dbconnect_noauto($myconfig);
501

  
502
  $form->{datepaid} = $form->{invdate};
503

  
504
  # total payments, don't move we need it here
505
  for my $i (1 .. $form->{paidaccounts}) {
506
    $form->{"paid_$i"} = $form->parse_amount($myconfig, $form->{"paid_$i"});
507
    $form->{paid} += $form->{"paid_$i"};
508
    $form->{datepaid} = $form->{"datepaid_$i"} if ($form->{"datepaid_$i"});
509
  }
510

  
511
  $form->{exchangerate} =
512
      $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate},
513
                              "buy");
514

  
515
  # record payments and offsetting AP
516
  for my $i (1 .. $form->{paidaccounts}) {
517

  
518
    if ($form->{"paid_$i"} != 0) {
519
      my ($accno) = split /--/, $form->{"AP_paid_$i"};
520
      $form->{"datepaid_$i"} = $form->{invdate}
521
        unless ($form->{"datepaid_$i"});
522
      $form->{datepaid} = $form->{"datepaid_$i"};
523

  
524
      $exchangerate = 0;
525
      if (($form->{currency} eq $form->{defaultcurrency}) || ($form->{defaultcurrency} eq "")) {
526
        $form->{"exchangerate_$i"} = 1;
527
      } else {
528
        $exchangerate =
529
          $form->check_exchangerate($myconfig, $form->{currency},
530
                                    $form->{"datepaid_$i"}, 'buy');
531

  
532
        $form->{"exchangerate_$i"} =
533
          ($exchangerate)
534
          ? $exchangerate
535
          : $form->parse_amount($myconfig, $form->{"exchangerate_$i"});
536
      }
537

  
538
      # record AP
539
      $amount =
540
        $form->round_amount($form->{"paid_$i"} * $form->{"exchangerate"},
541
                            2) * -1;
542

  
543

  
544
      $query = qq|DELETE FROM acc_trans WHERE trans_id=$form->{id} AND chart_id=(SELECT c.id FROM chart c
545
                                      WHERE c.accno = '$form->{AP}') AND amount=$amount AND transdate='$form->{"datepaid_$i"}'|;
546
      $dbh->do($query) || $form->dberror($query);
547

  
548
      $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
549
                  transdate)
550
                  VALUES ($form->{id}, (SELECT c.id FROM chart c
551
                                      WHERE c.accno = '$form->{AP}'),
552
                  $amount, '$form->{"datepaid_$i"}')|;
553
      $dbh->do($query) || $form->dberror($query);
554

  
555

  
556

  
557
      $query = qq|DELETE FROM acc_trans WHERE trans_id=$form->{id} AND chart_id=(SELECT c.id FROM chart c
558
                                      WHERE c.accno = '$accno') AND amount=$form->{"paid_$i"} AND transdate='$form->{"datepaid_$i"}' AND source='$form->{"source_$i"}' AND memo='$form->{"memo_$i"}'|;
559
      $dbh->do($query) || $form->dberror($query);
560

  
561
      $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
562
                  source, memo)
563
                  VALUES ($form->{id}, (SELECT c.id FROM chart c
564
		                      WHERE c.accno = '$accno'),
565
		  $form->{"paid_$i"}, '$form->{"datepaid_$i"}',
566
		  '$form->{"source_$i"}', '$form->{"memo_$i"}')|;
567
      $dbh->do($query) || $form->dberror($query);
568

  
569

  
570
      # gain/loss
571
      $amount =
572
        $form->{"paid_$i"} * $form->{exchangerate} - $form->{"paid_$i"} *
573
        $form->{"exchangerate_$i"};
574
      if ($amount > 0) {
575
        $form->{fx}{ $form->{fxgain_accno} }{ $form->{"datepaid_$i"} } +=
576
          $amount;
577
      } else {
578
        $form->{fx}{ $form->{fxloss_accno} }{ $form->{"datepaid_$i"} } +=
579
          $amount;
580
      }
581

  
582
      $diff = 0;
583

  
584
      # update exchange rate
585
      if (($form->{currency} ne $form->{defaultcurrency}) && !$exchangerate) {
586
        $form->update_exchangerate($dbh, $form->{currency},
587
                                   $form->{"datepaid_$i"},
588
                                   $form->{"exchangerate_$i"}, 0);
589
      }
590
    }
591
  }
592

  
593
  # record exchange rate differences and gains/losses
594
  foreach my $accno (keys %{ $form->{fx} }) {
595
    foreach my $transdate (keys %{ $form->{fx}{$accno} }) {
596
      if (
597
          ($form->{fx}{$accno}{$transdate} =
598
           $form->round_amount($form->{fx}{$accno}{$transdate}, 2)
599
          ) != 0
600
        ) {
601
        $query = qq|DELETE FROM acc_trans WHERE trans_id=$form->{id} AND chart_id=(SELECT c.id FROM chart c
602
                                        WHERE c.accno = '$accno') AND amount=$form->{fx}{$accno}{$transdate} AND transdate='$transdate' AND cleared='0' AND fx_transaction='1'|;
603
        $dbh->do($query) || $form->dberror($query);
604
        $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
605
	            transdate, cleared, fx_transaction)
606
		    VALUES ($form->{id},
607
		           (SELECT c.id FROM chart c
608
		            WHERE c.accno = '$accno'),
609
		    $form->{fx}{$accno}{$transdate}, '$transdate', '0', '1')|;
610
        $dbh->do($query) || $form->dberror($query);
611
      }
612
    }
613
  }
614
  my $datepaid = ($form->{paid})    ? qq|'$form->{datepaid}'| : "NULL";
615

  
616
  # save AP record
617
  my $query = qq|UPDATE ap set
618
              paid = $form->{paid},
619
	      datepaid = $datepaid
620
              WHERE id=$form->{id}|;
621

  
622
  $dbh->do($query) || $form->dberror($query);
623

  
624
  my $rc = $dbh->commit;
625
  $dbh->disconnect;
626

  
627
  $main::lxdebug->leave_sub();
628

  
629
  return $rc;
630
}
631

  
493 632
1;
494 633

  
SL/AR.pm
377 377
  return $rc;
378 378
}
379 379

  
380
sub post_payment {
381
  $main::lxdebug->enter_sub();
382

  
383
  my ($self, $myconfig, $form, $locale) = @_;
384

  
385
  # connect to database, turn off autocommit
386
  my $dbh = $form->dbconnect_noauto($myconfig);
387

  
388
  $form->{datepaid} = $form->{invdate};
389

  
390
  # total payments, don't move we need it here
391
  for my $i (1 .. $form->{paidaccounts}) {
392
    if ($form->{type} eq "credit_note") {
393
      $form->{"paid_$i"} = $form->parse_amount($myconfig, $form->{"paid_$i"}) * -1;
394
    } else {
395
      $form->{"paid_$i"} = $form->parse_amount($myconfig, $form->{"paid_$i"});
396
    } 
397
    $form->{paid} += $form->{"paid_$i"};
398
    $form->{datepaid} = $form->{"datepaid_$i"} if ($form->{"datepaid_$i"});
399
  }
400

  
401
  $form->{exchangerate} =
402
      $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate},
403
                              "buy");
404

  
405
  # record payments and offsetting AR
406
  for my $i (1 .. $form->{paidaccounts}) {
407

  
408
    if ($form->{"paid_$i"} != 0) {
409
      my ($accno) = split /--/, $form->{"AR_paid_$i"};
410
      $form->{"datepaid_$i"} = $form->{invdate}
411
        unless ($form->{"datepaid_$i"});
412
      $form->{datepaid} = $form->{"datepaid_$i"};
413

  
414
      $exchangerate = 0;
415
      if (($form->{currency} eq $form->{defaultcurrency}) || ($form->{defaultcurrency} eq "")) {
416
        $form->{"exchangerate_$i"} = 1;
417
      } else {
418
        $exchangerate =
419
          $form->check_exchangerate($myconfig, $form->{currency},
420
                                    $form->{"datepaid_$i"}, 'buy');
421

  
422
        $form->{"exchangerate_$i"} =
423
          ($exchangerate)
424
          ? $exchangerate
425
          : $form->parse_amount($myconfig, $form->{"exchangerate_$i"});
426
      }
427

  
428
      # record AR
429
      $amount =
430
        $form->round_amount($form->{"paid_$i"} * $form->{"exchangerate"},
431
                            2);
432

  
433

  
434
      $query = qq|DELETE FROM acc_trans WHERE trans_id=$form->{id} AND chart_id=(SELECT c.id FROM chart c
435
                                      WHERE c.accno = '$form->{AR}') AND amount=$amount AND transdate='$form->{"datepaid_$i"}'|;
436
      $dbh->do($query) || $form->dberror($query);
437

  
438
      $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
439
                  transdate)
440
                  VALUES ($form->{id}, (SELECT c.id FROM chart c
441
                                      WHERE c.accno = '$form->{AR}'),
442
                  $amount, '$form->{"datepaid_$i"}')|;
443
      $dbh->do($query) || $form->dberror($query);
444

  
445

  
446
      # record payment
447
      $form->{"paid_$i"} *= -1;
448

  
449
      $query = qq|DELETE FROM acc_trans WHERE trans_id=$form->{id} AND chart_id=(SELECT c.id FROM chart c
450
                                      WHERE c.accno = '$accno') AND amount=$form->{"paid_$i"} AND transdate='$form->{"datepaid_$i"}' AND source='$form->{"source_$i"}' AND memo='$form->{"memo_$i"}'|;
451
      $dbh->do($query) || $form->dberror($query);
452

  
453
      $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
454
                  source, memo)
455
                  VALUES ($form->{id}, (SELECT c.id FROM chart c
456
		                      WHERE c.accno = '$accno'),
457
		  $form->{"paid_$i"}, '$form->{"datepaid_$i"}',
458
		  '$form->{"source_$i"}', '$form->{"memo_$i"}')|;
459
      $dbh->do($query) || $form->dberror($query);
460

  
461

  
462
      # gain/loss
463
      $amount =
464
        $form->{"paid_$i"} * $form->{exchangerate} - $form->{"paid_$i"} *
465
        $form->{"exchangerate_$i"};
466
      if ($amount > 0) {
467
        $form->{fx}{ $form->{fxgain_accno} }{ $form->{"datepaid_$i"} } +=
468
          $amount;
469
      } else {
470
        $form->{fx}{ $form->{fxloss_accno} }{ $form->{"datepaid_$i"} } +=
471
          $amount;
472
      }
473

  
474
      $diff = 0;
475

  
476
      # update exchange rate
477
      if (($form->{currency} ne $form->{defaultcurrency}) && !$exchangerate) {
478
        $form->update_exchangerate($dbh, $form->{currency},
479
                                   $form->{"datepaid_$i"},
480
                                   $form->{"exchangerate_$i"}, 0);
481
      }
482
    }
483
  }
484

  
485
  # record exchange rate differences and gains/losses
486
  foreach my $accno (keys %{ $form->{fx} }) {
487
    foreach my $transdate (keys %{ $form->{fx}{$accno} }) {
488
      if (
489
          ($form->{fx}{$accno}{$transdate} =
490
           $form->round_amount($form->{fx}{$accno}{$transdate}, 2)
491
          ) != 0
492
        ) {
493
        $query = qq|DELETE FROM acc_trans WHERE trans_id=$form->{id} AND chart_id=(SELECT c.id FROM chart c
494
                                        WHERE c.accno = '$accno') AND amount=$form->{fx}{$accno}{$transdate} AND transdate='$transdate' AND cleared='0' AND fx_transaction='1'|;
495
        $dbh->do($query) || $form->dberror($query);
496
        $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
497
	            transdate, cleared, fx_transaction)
498
		    VALUES ($form->{id},
499
		           (SELECT c.id FROM chart c
500
		            WHERE c.accno = '$accno'),
501
		    $form->{fx}{$accno}{$transdate}, '$transdate', '0', '1')|;
502
        $dbh->do($query) || $form->dberror($query);
503
      }
504
    }
505
  }
506
  my $datepaid = ($form->{paid})    ? qq|'$form->{datepaid}'| : "NULL";
507

  
508
  # save AR record
509
  my $query = qq|UPDATE ar set
510
              paid = $form->{paid},
511
	      datepaid = $datepaid
512
              WHERE id=$form->{id}|;
513

  
514
  $dbh->do($query) || $form->dberror($query);
515

  
516
  my $rc = $dbh->commit;
517
  $dbh->disconnect;
518

  
519
  $main::lxdebug->leave_sub();
520

  
521
  return $rc;
522
}
523

  
380 524
sub delete_transaction {
381 525
  $main::lxdebug->enter_sub();
382 526

  
bin/mozilla/ap.pl
748 748
<input class=submit type=submit name=action value="|
749 749
        . $locale->text('Use As Template') . qq|">
750 750
|;
751
 
751
      print qq|
752
<input class=submit type=submit name=action value="|
753
        . $locale->text('Post Payment') . qq|">
754
|;
752 755
  } else {
753 756
    if (($transdate > $closedto) && !$form->{id}) {
754 757
      print qq|<input class=submit type=submit name=action value="|
......
875 878
  $lxdebug->leave_sub();
876 879
}
877 880

  
881

  
882
sub post_payment {
883
  $lxdebug->enter_sub();
884
  for $i (1 .. $form->{paidaccounts}) {
885
    if ($form->{"paid_$i"}) {
886
      $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
887

  
888
      $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
889

  
890
      $form->error($locale->text('Cannot post payment for a closed period!'))
891
        if ($datepaid <= $closedto);
892

  
893
      if ($form->{currency} ne $form->{defaultcurrency}) {
894
        $form->{"exchangerate_$i"} = $form->{exchangerate}
895
          if ($invdate == $datepaid);
896
        $form->isblank("exchangerate_$i",
897
                       $locale->text('Exchangerate for payment missing!'));
898
      }
899
    }
900
  }
901

  
902
  ($form->{AP})      = split /--/, $form->{AP};
903
  ($form->{AP_paid}) = split /--/, $form->{AP_paid};
904
  $form->redirect($locale->text(' Payment posted!'))
905
      if (AP->post_payment(\%myconfig, \%$form));
906
    $form->error($locale->text('Cannot post payment!'));
907

  
908

  
909
  $lxdebug->leave_sub();
910
}
911

  
912

  
878 913
sub post {
879 914
  $lxdebug->enter_sub();
880 915

  
bin/mozilla/ar.pl
771 771
          . $locale->text('Use As Template') . qq|">
772 772
  |;
773 773
      }
774
        print qq|
775
  <input class=submit type=submit name=action value="|
776
          . $locale->text('Post Payment') . qq|">
777
  |;
774 778
    
775 779
  } else {
776 780
    if ($transdate > $closedto) {
......
900 904
  $lxdebug->leave_sub();
901 905
}
902 906

  
907
sub post_payment {
908
  $lxdebug->enter_sub();
909
  for $i (1 .. $form->{paidaccounts}) {
910
    if ($form->{"paid_$i"}) {
911
      $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
912

  
913
      $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
914

  
915
      $form->error($locale->text('Cannot post payment for a closed period!'))
916
        if ($datepaid <= $closedto);
917

  
918
      if ($form->{currency} ne $form->{defaultcurrency}) {
919
        $form->{"exchangerate_$i"} = $form->{exchangerate}
920
          if ($invdate == $datepaid);
921
        $form->isblank("exchangerate_$i",
922
                       $locale->text('Exchangerate for payment missing!'));
923
      }
924
    }
925
  }
926

  
927
  ($form->{AR})      = split /--/, $form->{AR};
928
  ($form->{AR_paid}) = split /--/, $form->{AR_paid};
929
  $form->redirect($locale->text(' Payment posted!'))
930
      if (AR->post_payment(\%myconfig, \%$form));
931
    $form->error($locale->text('Cannot post payment!'));
932

  
933

  
934
  $lxdebug->leave_sub();
935
}
936

  
903 937
sub post {
904 938
  $lxdebug->enter_sub();
905 939

  
locale/de/all
923 923
  'Step 2 of 3: Services'       => 'Schritt 2 von 3: Dienstleistungen',
924 924
  'Step 3 of 3: Assemblies'     => 'Schritt 3 von 3: Erzeugnisse',
925 925
  'Step 3 of 3: Default units'  => 'Schritt 3 von 3: Standardeinheiten',
926
  'Steuernummer'                => '',
926 927
  'Steuersatz'                  => 'Steuersatz',
927 928
  'Stock'                       => 'einlagern',
928 929
  'Stock Assembly'              => 'Erzeugnis einlagern',
......
969 970
  'The database update/creation did not succeed. The file <TMPL_VAR file ESCAPE=HTML> contained the following error:' => 'Die Datenbankaktualisierung/erstellung schlug fehl. Die Datei <TMPL_VAR file ESCAPE=HTML> enthielt den folgenden Fehler:',
970 971
  'The database upgrade for the introduction of Buchungsgruppen is now complete.' => 'Das Datenbankupgrade f&uuml;r die Einf&uuml;hrung von Buchungsgruppen ist jetzt beendet.',
971 972
  'The database upgrade for the introduction of units is now complete.' => 'Das Datenbankupgrade zwecks Einf&uuml;hrung von Einheiten ist nun beendet.',
973
  'The dunning process is started' => '',
972 974
  'The dunning process started' => 'Der Mahnprozess ist gestartet.',
973 975
  'The factor is missing in row %d.' => 'Der Faktor fehlt in Zeile %d.',
974 976
  'The factor is missing.'      => 'Der Faktor fehlt.',
......
1117 1119
  'Warehouses'                  => 'Lager',
1118 1120
  'Warnings during template upgrade' => 'Warnungen bei Aktualisierung der Dokumentenvorlagen',
1119 1121
  'Weight'                      => 'Gewicht',
1122
  'Weight Unit'                 => '',
1120 1123
  'What type of item is this?'  => 'Was ist dieser Artikel?',
1121 1124
  'With Extension Of Time'      => 'mit Dauerfristverl?ngerung',
1122 1125
  'Workflow purchase_order'     => 'Workflow Lieferantenauftrag',
locale/de/ap
1 1
$self->{texts} = {
2
  ' Payment posted!'            => 'Zahlung gebucht!',
2 3
  'AP Transaction'              => 'Kreditorenbuchung',
3 4
  'AP Transactions'             => 'Kreditorenbuchungen',
4 5
  'Account'                     => 'Konto',
......
14 15
  'Bis'                         => 'bis',
15 16
  'Cannot delete transaction!'  => 'Buchung kann nicht gel?scht werden!',
16 17
  'Cannot post payment for a closed period!' => 'Es k?nnen keine Zahlungen f?r abgeschlossene B?cher gebucht werden!',
18
  'Cannot post payment!'        => 'Zahlung kann nicht gebucht werden!',
17 19
  'Cannot post transaction for a closed period!' => 'F?r einen bereits abgeschlossenen Zeitraum kann keine Buchung angelegt werden!',
18 20
  'Cannot post transaction!'    => 'Rechnung kann nicht gebucht werden!',
19 21
  'Closed'                      => 'Geschlossen',
......
71 73
  'Payment date missing!'       => 'Tag der Zahlung fehlt!',
72 74
  'Payments'                    => 'Zahlungsausg?nge',
73 75
  'Post'                        => 'Buchen',
76
  'Post Payment'                => 'Zahlung buchen',
74 77
  'Project'                     => 'Projekt',
75 78
  'Project not on file!'        => 'Dieses Projekt ist nicht in der Datenbank!',
76 79
  'Remaining'                   => 'Rest',
......
116 119
  'name_selected'               => 'name_selected',
117 120
  'post'                        => 'post',
118 121
  'post_as_new'                 => 'post_as_new',
122
  'post_payment'                => 'post_payment',
119 123
  'project_selected'            => 'project_selected',
120 124
  'sales_invoice'               => 'sales_invoice',
121 125
  'search'                      => 'search',
......
131 135
  'l?schen'                     => 'delete',
132 136
  'kreditorenbuchung_bearbeiten' => 'edit_accounts_payables_transaction',
133 137
  'buchen'                      => 'post',
138
  'zahlung_buchen'              => 'post_payment',
134 139
  'erneuern'                    => 'update',
135 140
  'als_vorlage_verwenden'       => 'use_as_template',
136 141
  'einkaufsrechnung'            => 'vendor_invoice',
locale/de/ar
1 1
$self->{texts} = {
2
  ' Payment posted!'            => 'Zahlung gebucht!',
2 3
  'AR Transaction'              => 'Debitorenbuchung',
3 4
  'AR Transactions'             => 'Debitorenbuchungen',
4 5
  'Account'                     => 'Konto',
......
14 15
  'Bis'                         => 'bis',
15 16
  'Cannot delete transaction!'  => 'Buchung kann nicht gel?scht werden!',
16 17
  'Cannot post payment for a closed period!' => 'Es k?nnen keine Zahlungen f?r abgeschlossene B?cher gebucht werden!',
18
  'Cannot post payment!'        => 'Zahlung kann nicht gebucht werden!',
17 19
  'Cannot post transaction for a closed period!' => 'F?r einen bereits abgeschlossenen Zeitraum kann keine Buchung angelegt werden!',
18 20
  'Cannot post transaction!'    => 'Rechnung kann nicht gebucht werden!',
19 21
  'Closed'                      => 'Geschlossen',
......
74 76
  'Paid'                        => 'bezahlt',
75 77
  'Payment date missing!'       => 'Tag der Zahlung fehlt!',
76 78
  'Post'                        => 'Buchen',
79
  'Post Payment'                => 'Zahlung buchen',
77 80
  'Project'                     => 'Projekt',
78 81
  'Project not on file!'        => 'Dieses Projekt ist nicht in der Datenbank!',
79 82
  'Remaining'                   => 'Rest',
......
122 125
  'name_selected'               => 'name_selected',
123 126
  'post'                        => 'post',
124 127
  'post_as_new'                 => 'post_as_new',
128
  'post_payment'                => 'post_payment',
125 129
  'project_selected'            => 'project_selected',
126 130
  'sales_invoice'               => 'sales_invoice',
127 131
  'search'                      => 'search',
......
135 139
  'weiter'                      => 'continue',
136 140
  'l?schen'                     => 'delete',
137 141
  'buchen'                      => 'post',
142
  'zahlung_buchen'              => 'post_payment',
138 143
  'rechnung'                    => 'sales_invoice',
139 144
  'erneuern'                    => 'update',
140 145
  'als_vorlage_verwenden'       => 'use_as_template',

Auch abrufbar als: Unified diff