Die ausgewiesenen Mahngebühren gelten pro Rechnung, nicht pro erzeugter Mahnung,...
[kivitendo-erp.git] / bin / mozilla / ar.pl
index 482ac64..d218ff6 100644 (file)
@@ -36,7 +36,7 @@ use SL::IS;
 use SL::PE;
 use Data::Dumper;
 
-require "$form->{path}/arap.pl";
+require "bin/mozilla/arap.pl";
 require "bin/mozilla/common.pl";
 require "bin/mozilla/drafts.pl";
 
@@ -87,7 +87,7 @@ sub add {
   
   $form->{title}    = "Add";
   $form->{callback} =
-    "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
+    "$form->{script}?action=add&login=$form->{login}&password=$form->{password}"
     unless $form->{callback};
 
   AR->get_transdate(\%myconfig, $form);
@@ -471,7 +471,7 @@ selectcustomer}</select>|
   $form->{fokus} = "arledger.customer";
 
   # use JavaScript Calendar or not
-  $form->{jsscript} = $jscalendar;
+  $form->{jsscript} = 1;
   $jsscript = "";
   if ($form->{jsscript}) {
 
@@ -500,6 +500,10 @@ selectcustomer}</select>|
       qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"></td>|;
   }
 
+  $form->{javascript} .=
+    qq|<script type="text/javascript" src="js/common.js"></script>| .
+    qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
+
   $form->header;
   $onload = qq|focus()|;
   $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
@@ -530,7 +534,7 @@ selectcustomer}</select>|
            <table>
              <tr>
                <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
-               <td colspan=3>$customer</td>
+               <td colspan=3>$customer <input type="button" value="?" onclick="show_vc_details('customer')"></td>
                <input type=hidden name=selectcustomer value="$form->{selectcustomer}">
                <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
                <input type=hidden name=customer_id value="$form->{customer_id}">
@@ -843,7 +847,6 @@ sub form_footer {
 
 <input name=callback type=hidden value="$form->{callback}">
 
-<input type=hidden name=path value=$form->{path}>
 <input type=hidden name=login value=$form->{login}>
 <input type=hidden name=password value=$form->{password}>
 |
@@ -899,7 +902,7 @@ sub form_footer {
   }
 
   if ($form->{menubar}) {
-    require "$form->{path}/menu.pl";
+    require "bin/mozilla/menu.pl";
     &menubar;
   }
   # button for saving history
@@ -1016,7 +1019,7 @@ sub update {
 sub post_payment {
   $lxdebug->enter_sub();
   for $i (1 .. $form->{paidaccounts}) {
-    if ($form->{"paid_$i"}) {
+    if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
       $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
 
       $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
@@ -1053,9 +1056,17 @@ sub post {
 
   $closedto  = $form->datetonum($form->{closedto},  \%myconfig);
   $transdate = $form->datetonum($form->{transdate}, \%myconfig);
+  $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
 
-  $form->error($locale->text('Cannot post transaction for a closed period!'))
-    if ($transdate <= $closedto);
+  my $zero_amount_posting = 1;
+  for $i (1 .. $form->{rowcount}) {
+    if ($form->parse_amount(\%myconfig, $form->{"amount_$i"})) {
+      $zero_amount_posting = 0;
+      last;
+    }
+  }
+
+  $form->error($locale->text('Zero amount posting!')) if $zero_amount_posting;
 
   $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
     if ($form->{currency} ne $form->{defaultcurrency});
@@ -1225,7 +1236,7 @@ sub search {
   $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
   
   # use JavaScript Calendar or not
-  $form->{jsscript} = $jscalendar;
+  $form->{jsscript} = 1;
   $jsscript = "";
   if ($form->{jsscript}) {
 
@@ -1296,6 +1307,10 @@ sub search {
          <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
          <td colspan=3><input name=ordnumber size=20></td>
        </tr>
+       <tr>
+         <th align=right nowrap>| . $locale->text('Transaction description') . qq|</th>
+         <td colspan=3><input name=transaction_description size=40></td>
+       </tr>
        <tr>
          <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
          <td colspan=3><input name=notes size=40></td>
@@ -1372,6 +1387,8 @@ sub search {
                <td nowrap>| . $locale->text('Subtotal') . qq|</td>
                <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
                <td nowrap>| . $locale->text('Project Number') . qq|</td>
+               <td align=right><input name="l_transaction_description" class=checkbox type=checkbox value=Y></td>
+               <td nowrap>| . $locale->text('Transaction description') . qq|</td>
              </tr>
            </table>
          </td>
@@ -1386,7 +1403,6 @@ sub search {
 
 <input type=hidden name=nextsub value=$form->{nextsub}>
 
-<input type=hidden name=path value=$form->{path}>
 <input type=hidden name=login value=$form->{login}>
 <input type=hidden name=password value=$form->{password}>
 
@@ -1415,7 +1431,7 @@ sub ar_transactions {
   AR->ar_transactions(\%myconfig, \%$form);
 
   $callback =
-    "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
+    "$form->{script}?action=ar_transactions&login=$form->{login}&password=$form->{password}";
   $href = $callback;
 
   if ($form->{customer}) {
@@ -1448,6 +1464,12 @@ sub ar_transactions {
     $option .= "\n<br>" if $option;
     $option .= $locale->text('Notes') . " : $form->{notes}";
   }
+  if ($form->{transaction_description}) {
+    $callback .= "&transaction_description=" . $form->escape($form->{transaction_description}, 1);
+    $href .= "&transaction_description=" . $form->escape($form->{transaction_description});
+    $option .= "\n<br>" if $option;
+    $option .= $locale->text('Transaction description') . " : $form->{transaction_description}";
+  }
 
   if ($form->{transdatefrom}) {
     $callback .= "&transdatefrom=$form->{transdatefrom}";
@@ -1484,7 +1506,7 @@ sub ar_transactions {
 
   @columns =
     qw(transdate id type invnumber ordnumber name netamount tax amount paid
-       datepaid due duedate notes employee shippingpoint shipvia
+       datepaid due duedate transaction_description notes employee shippingpoint shipvia
        globalprojectnumber);
 
   $form->{"l_type"} = "Y";
@@ -1560,6 +1582,8 @@ sub ar_transactions {
     . "</a></th>";
   $column_header{globalprojectnumber} =
     qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
+  $column_header{transaction_description} =
+    "<th class=listheading>" . $locale->text('Transaction description') . "</th>";
 
   $form->{title} = $locale->text('AR Transactions');
 
@@ -1645,12 +1669,18 @@ sub ar_transactions {
     $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
 
     $column_data{invnumber} =
-      "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
+      "<td><a href=$module?action=edit&id=$ar->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
+
+    my $is_storno  = $ar->{storno} && ($ar->{invnumber} =~ /^Storno zu/);
+    my $has_storno = $ar->{storno} && !$is_storno;
+
     $column_data{type} = "<td>" .
-      ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
-       $ar->{amount} < 0 ?
-       $locale->text("Credit note (one letter abbreviation)") :
-       $locale->text("Invoice (one letter abbreviation)")) . "</td>";
+      ($has_storno       ? $locale->text("Invoice with Storno (abbreviation)") :
+       $is_storno        ? $locale->text("Storno (one letter abbreviation)") :
+       $ar->{amount} < 0 ? $locale->text("Credit note (one letter abbreviation)") :
+       $ar->{invoice}    ? $locale->text("Invoice (one letter abbreviation)") :
+                           $locale->text("AR Transaction (abbreviation)"))
+        . "</td>";
     $column_data{ordnumber} = "<td>$ar->{ordnumber}&nbsp;</td>";
     $column_data{name}      = "<td>$ar->{name}</td>";
     $ar->{notes} =~ s/\r\n/<br>/g;
@@ -1660,6 +1690,8 @@ sub ar_transactions {
     $column_data{employee}      = "<td>$ar->{employee}&nbsp;</td>";
     $column_data{globalprojectnumber}  =
       "<td>" . H($ar->{globalprojectnumber}) . "</td>";
+    $column_data{transaction_description}  =
+      "<td>" . H($ar->{transaction_description}) . "</td>";
 
     $i++;
     $i %= 2;
@@ -1720,7 +1752,6 @@ sub ar_transactions {
 
 <input name=callback type=hidden value="$form->{callback}">
 
-<input type=hidden name=path value=$form->{path}>
 <input type=hidden name=login value=$form->{login}>
 <input type=hidden name=password value=$form->{password}>