Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7391daa6

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

  • ID 7391daa613df795dec089ae73957c9a6bbf281f5
  • Vorgänger fade054f
  • Nachfolger 99ed8abf

Fix zu Bug 662.
post wurde von storno mitverwendet, das abschliessende redirect schlug bei geaendertem programmverlauf fehl

Unterschiede anzeigen:

bin/mozilla/gl.pl
1599 1599

  
1600 1600
}
1601 1601

  
1602
sub post {
1602
sub post_transaction {
1603 1603
  $lxdebug->enter_sub();
1604 1604

  
1605
  $form->{title} = $locale->text("$form->{title} General Ledger Transaction");
1606

  
1607 1605
  # check if there is something in reference and date
1608 1606
  $form->isblank("reference",   $locale->text('Reference missing!'));
1609 1607
  $form->isblank("transdate",   $locale->text('Transaction Date missing!'));
......
1621 1619
  $creditlock = 0;
1622 1620
  $debitlock  = 0;
1623 1621

  
1624
  my @flds =
1625
    qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
1622
  my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
1626 1623

  
1627 1624
  for my $i (1 .. $form->{rowcount}) {
1625
    next if $form->{"debit_$i"} eq "" && $form->{"credit_$i"} eq "";
1628 1626

  
1629
    unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
1630
      for (qw(debit credit tax)) {
1631
        $form->{"${_}_$i"} =
1632
          $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
1633
      }
1627
    for (qw(debit credit tax)) {
1628
      $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
1629
    }
1634 1630

  
1635
      push @a, {};
1636
      $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
1631
    push @a, {};
1632
    $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
1637 1633

  
1638
      if ($debitcredit) {
1639
        $debitcount++;
1640
      } else {
1641
        $creditcount++;
1642
      }
1634
    if ($debitcredit) {
1635
      $debitcount++;
1636
    } else {
1637
      $creditcount++;
1638
    }
1643 1639

  
1644
      if (($debitcount >= 2) && ($creditcount == 2)) {
1645
        $form->{"credit_$i"} = 0;
1646
        $form->{"tax_$i"}    = 0;
1647
        $creditcount--;
1648
        $creditlock = 1;
1649
      }
1650
      if (($creditcount >= 2) && ($debitcount == 2)) {
1651
        $form->{"debit_$i"} = 0;
1652
        $form->{"tax_$i"}   = 0;
1653
        $debitcount--;
1654
        $debitlock = 1;
1655
      }
1656
      if (($creditcount == 1) && ($debitcount == 2)) {
1657
        $creditlock = 1;
1658
      }
1659
      if (($creditcount == 2) && ($debitcount == 1)) {
1660
        $debitlock = 1;
1661
      }
1662
      if ($debitcredit && $credittax) {
1663
        $form->{"taxchart_$i"} = "0--0.00";
1664
      }
1665
      if (!$debitcredit && $debittax) {
1666
        $form->{"taxchart_$i"} = "0--0.00";
1667
      }
1668
      $amount =
1669
        ($form->{"debit_$i"} == 0)
1670
        ? $form->{"credit_$i"}
1671
        : $form->{"debit_$i"};
1672
      $j = $#a;
1673
      if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
1674
        $form->{"taxchart_$i"} = "0--0.00";
1675
        $form->{"tax_$i"}      = 0;
1676
      }
1677
      if (!$form->{"korrektur_$i"}) {
1678
        ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
1679
        if ($taxkey > 1) {
1640
    if (($debitcount >= 2) && ($creditcount == 2)) {
1641
      $form->{"credit_$i"} = 0;
1642
      $form->{"tax_$i"}    = 0;
1643
      $creditcount--;
1644
      $creditlock = 1;
1645
    }
1646
    if (($creditcount >= 2) && ($debitcount == 2)) {
1647
      $form->{"debit_$i"} = 0;
1648
      $form->{"tax_$i"}   = 0;
1649
      $debitcount--;
1650
      $debitlock = 1;
1651
    }
1652
    if (($creditcount == 1) && ($debitcount == 2)) {
1653
      $creditlock = 1;
1654
    }
1655
    if (($creditcount == 2) && ($debitcount == 1)) {
1656
      $debitlock = 1;
1657
    }
1658
    if ($debitcredit && $credittax) {
1659
      $form->{"taxchart_$i"} = "0--0.00";
1660
    }
1661
    if (!$debitcredit && $debittax) {
1662
      $form->{"taxchart_$i"} = "0--0.00";
1663
    }
1664
    $amount = ($form->{"debit_$i"} == 0)
1665
            ? $form->{"credit_$i"}
1666
            : $form->{"debit_$i"};
1667
    $j = $#a;
1668
    if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
1669
      $form->{"taxchart_$i"} = "0--0.00";
1670
      $form->{"tax_$i"}      = 0;
1671
    }
1672
    if (!$form->{"korrektur_$i"}) {
1673
      ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
1674
      if ($taxkey > 1) {
1675
        if ($debitcredit) {
1676
          $debittax = 1;
1677
        } else {
1678
          $credittax = 1;
1679
        }
1680
        if ($form->{taxincluded}) {
1681
          $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1680 1682
          if ($debitcredit) {
1681
            $debittax = 1;
1683
            $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1682 1684
          } else {
1683
            $credittax = 1;
1685
            $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1684 1686
          }
1685
          if ($form->{taxincluded}) {
1686
            $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1687
            if ($debitcredit) {
1688
              $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1689
            } else {
1690
              $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1691
            }
1692
          } else {
1693
            $form->{"tax_$i"} = $amount * $rate;
1694
          }
1695
        } else {
1696
          $form->{"tax_$i"} = 0;
1697
        }
1698
      } elsif ($form->{taxincluded}) {
1699
        if ($debitcredit) {
1700
          $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1701 1687
        } else {
1702
          $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1688
          $form->{"tax_$i"} = $amount * $rate;
1703 1689
        }
1690
      } else {
1691
        $form->{"tax_$i"} = 0;
1692
      }
1693
    } elsif ($form->{taxincluded}) {
1694
      if ($debitcredit) {
1695
        $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1696
      } else {
1697
        $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1704 1698
      }
1705

  
1706
      for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1707
      $count++;
1708 1699
    }
1700

  
1701
    for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1702
    $count++;
1709 1703
  }
1710 1704

  
1711 1705
  for $i (1 .. $count) {
......
1722 1716
    $cr  = $form->{"credit_$i"};
1723 1717
    $tax = $form->{"tax_$i"};
1724 1718
    if ($dr && $cr) {
1725
      $form->error(
1726
        $locale->text(
1727
          'Cannot post transaction with a debit and credit entry for the same account!'
1728
        ));
1719
      $form->error($locale->text('Cannot post transaction with a debit and credit entry for the same account!'));
1729 1720
    }
1730
    if ($form->{taxincluded}) {
1731
      if ($dr) {
1732
        $debit += $dr + $tax;
1733
      }
1734
      if ($cr) {
1735
        $credit += $cr + $tax;
1736
      }
1737
      $taxtotal += $tax;
1738
    } else {
1739
      if ($dr) {
1740
        $debit += $dr + $tax;
1741
      }
1742
      if ($cr) {
1743
        $credit += $cr + $tax;
1744
      }
1745
    }
1746
  }
1747
  if (!$taxtotal) {
1748
    $form->{taxincluded} = 0;
1721
    $debit    += $dr + $tax if $dr;
1722
    $credit   += $cr + $tax if $cr;
1723
    $taxtotal += $tax if $form->{taxincluded}
1749 1724
  }
1725
  
1726
  $form->{taxincluded} = 0 if !$taxtotal;
1750 1727

  
1751 1728
  # this is just for the wise guys
1752 1729
  $form->error($locale->text('Cannot post transaction for a closed period!'))
......
1771 1748
  # saving the history
1772 1749
  if(!exists $form->{addition} && $form->{id} ne "") {
1773 1750
    $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1774
  	$form->{addition} = "SAVED";
1775
  	$form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id}; 
1776
  	$form->save_history($form->dbconnect(\%myconfig));
1751
    $form->{addition} = "SAVED";
1752
    $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id}; 
1753
    $form->save_history($form->dbconnect(\%myconfig));
1777 1754
  }
1778 1755
  # /saving the history 
1779 1756

  
1757
  $lxdebug->leave_sub();
1758
}
1759

  
1760
sub post {
1761
  $lxdebug->enter_sub();
1762

  
1763
  $form->{title} = $locale->text("$form->{title} General Ledger Transaction");
1764

  
1765
  post_transaction();
1766

  
1780 1767
  $form->{callback} = build_std_url("action=add", "show_details");
1781 1768
  $form->redirect($form->{callback});
1782 1769

  
1783 1770
  $lxdebug->leave_sub();
1784

  
1785 1771
}
1786 1772

  
1787 1773
sub post_as_new {
......
1835 1821
    }
1836 1822
  }
1837 1823

  
1838
  post();
1824
  post_transaction();
1839 1825

  
1840 1826
  # saving the history
1841 1827
  if(!exists $form->{addition} && $form->{id} ne "") {
......
1845 1831
  }
1846 1832
  # /saving the history 
1847 1833

  
1834
  $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); 
1835

  
1848 1836
  $lxdebug->leave_sub();
1849 1837

  
1850 1838
}
locale/de/all
1115 1115
  'Total'                       => 'Summe',
1116 1116
  'Total Fees'                  => 'Kumulierte Geb?hren',
1117 1117
  'Trade Discount'              => 'Rabatt',
1118
  'Transaction %d cancelled.'   => 'Buchung %d erfolgreich storniert.',
1118 1119
  'Transaction Date missing!'   => 'Buchungsdatum fehlt!',
1119 1120
  'Transaction deleted!'        => 'Buchung gel?scht!',
1120 1121
  'Transaction description'     => 'Vorgangsbezeichnung',
locale/de/gl
153 153
  'Taxkey'                      => 'Steuerschl?ssel',
154 154
  'The \'tag\' field must only consist of alphanumeric characters or the carachters - _ ( )' => 'Das Feld \'tag\' darf nur aus alphanumerischen Zeichen und den Zeichen - _ ( ) bestehen.',
155 155
  'To (time)'                   => 'Bis',
156
  'Transaction %d cancelled.'   => 'Buchung %d erfolgreich storniert.',
156 157
  'Transaction Date missing!'   => 'Buchungsdatum fehlt!',
157 158
  'Transaction deleted!'        => 'Buchung gel?scht!',
158 159
  'Transaction has already been cancelled!' => 'Diese Buchung wurde bereits storniert.',
......
212 213
  'part_selection_internal'     => 'part_selection_internal',
213 214
  'post'                        => 'post',
214 215
  'post_as_new'                 => 'post_as_new',
216
  'post_transaction'            => 'post_transaction',
215 217
  'prepare_transaction'         => 'prepare_transaction',
216 218
  'project_selected'            => 'project_selected',
217 219
  'project_selection_internal'  => 'project_selection_internal',

Auch abrufbar als: Unified diff