added roundings on prints
authorRolf Fluehmann <rolf.fluehmann@revamp-it.ch>
Thu, 9 Jun 2016 10:43:08 +0000 (12:43 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Thu, 16 Jun 2016 14:23:19 +0000 (16:23 +0200)
SL/IS.pm
SL/OE.pm
templates/print/RB/invoice.html
templates/print/RB/sales_order.html
templates/print/RB/sales_quotation.html
templates/webpages/is/form_footer.html
templates/webpages/oe/form_footer.html

index e32827f..c579aad 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -519,9 +519,15 @@ sub invoice_details {
   $form->{nodiscount}          = $form->format_amount($myconfig, $nodiscount, 2);
   $form->{yesdiscount}         = $form->format_amount($myconfig, $form->{nodiscount_total} - $nodiscount, 2);
 
-  $form->{invtotal} = ($form->{taxincluded}) ? $form->{total} : $form->{total} + $tax;
-  $form->{total}    = $form->format_amount($myconfig, $form->{invtotal} - $form->{paid}, 2);
+  my $grossamount = ($form->{taxincluded}) ? $form->{total} : $form->{total} + $tax;
+  $form->{invtotal} = $form->round_amount($grossamount, 2, 1);
+  $form->{rounding} = $form->round_amount(
+    $form->{invtotal} - $form->round_amount($grossamount, 2),
+    2
+  );
 
+  $form->{rounding} = $form->format_amount($myconfig, $form->{rounding}, 2);
+  $form->{total}    = $form->format_amount($myconfig, $form->{invtotal} - $form->{paid}, 2);
   $form->{invtotal} = $form->format_amount($myconfig, $form->{invtotal}, 2);
   $form->{paid}     = $form->format_amount($myconfig, $form->{paid}, 2);
 
index c4e768b..31b3067 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -1576,9 +1576,15 @@ sub order_details {
     $form->{subtotal_nofmt} = $form->{ordtotal};
   }
 
-  $form->{ordtotal} = ($form->{taxincluded}) ? $form->{ordtotal} : $form->{ordtotal} + $tax;
+  my $grossamount = ($form->{taxincluded}) ? $form->{ordtotal} : $form->{ordtotal} + $tax;
+  $form->{ordtotal} = $form->round_amount( $grossamount, 2, 1);
+  $form->{rounding} = $form->round_amount(
+    $form->{ordtotal} - $form->round_amount($grossamount, 2),
+    2
+  );
 
   # format amounts
+  $form->{rounding} = $form->format_amount($myconfig, $form->{rounding}, 2);
   $form->{quototal} = $form->{ordtotal} = $form->format_amount($myconfig, $form->{ordtotal}, 2);
 
   $form->set_payment_options($myconfig, $form->{$form->{type} =~ /_quotation/ ? 'quodate' : 'orddate'}, $form->{type});
index b4a5ec9..a167dc6 100644 (file)
@@ -5,7 +5,7 @@
 <tr valign=bottom>
   <td width=10>&nbsp;</td>
   <td>
-  
+
   <table width=100%>
   <tr>
     <td>
 
 
   <table width=100% callspacing=0 cellpadding=0>
-    
+
   <tr>
     <td align=right>
     <table>
     <tr>
       <th align=right>Ausgestellt am</th><td width=10>&nbsp;</td><td><%invdate%></td>
     </tr>
-  
+
     <tr>
       <th align=right>Bezahlbar bis</th><td width=10>&nbsp;</td><td><%duedate%></td>
     </tr>
@@ -48,7 +48,7 @@
     <tr>
       <th align=right>Nummer</th><td>&nbsp;</td><td><%invnumber%></td></tr>
     </tr>
-  
+
     <tr>
       <th align=right>Lieferdatum</th><td>&nbsp;</td><td><%deliverydate%></td></tr>
     </tr>
@@ -85,7 +85,7 @@
       <br><%city%>
       <br><%country%>
       </td>
-      
+
       <td><%shiptoname%>
       <br><%shiptostreet%>
       <br><%shiptozipcode%>
   <tr>
     <td>&nbsp;</td>
   </tr>
-  
+
   <tr>
     <td>
     <table width=100%>
@@ -139,7 +139,7 @@ netprice = linetotal/qty
     <tr>
       <td colspan=7><hr noshade></td>
     </tr>
-    
+
 <%if taxincluded%>
     <tr>
       <th colspan=5 align=right>Total</th>
@@ -160,6 +160,13 @@ netprice = linetotal/qty
     </tr>
 <%end tax%>
 
+<%if rounding%>
+    <tr>
+      <th colspan=5 align=right>Rundung</th>
+      <td colspan=2 align=right><%rounding%></td>
+    </tr>
+<%end rounding%>
+
 <%if paid%>
     <tr>
       <th colspan=5 align=right>Bezahlt</th>
@@ -207,7 +214,7 @@ netprice = linetotal/qty
 </tr>
 
 <tr><td>&nbsp;</td></tr>
-  
+
 <tr>
   <td>
   <table width=100%>
index 4cbe20a..260d1ed 100644 (file)
@@ -5,7 +5,7 @@
 <tr valign=bottom>
   <td width=10>&nbsp;</td>
   <td>
-  
+
   <table width=100%>
   <tr>
     <td>
 
 
   <table width=100% callspacing=0 cellpadding=0>
-    
+
   <tr>
     <td align=right>
     <table>
     <tr>
       <th align=right>Bestelldatum</th><td width=10>&nbsp;</td><td><%orddate%></td>
     </tr>
-  
+
     <tr>
       <th align=right>Lieferbar bei</th><td width=10>&nbsp;</td><td><%reqdate%></td>
     </tr>
@@ -48,7 +48,7 @@
     <tr>
       <th align=right>Bestellnummer</th><td>&nbsp;</td><td><%ordnumber%></td></tr>
     </tr>
-  
+
     <tr>
       <td>&nbsp;</td>
     </tr>
@@ -86,7 +86,7 @@
   <tr>
     <td>&nbsp;</td>
   </tr>
-  
+
   <tr>
     <td>
     <table width=100%>
@@ -119,7 +119,7 @@ adjust the colspan if you include this to shift subtotal one to the right
     <tr>
       <td colspan=7><hr noshade></td>
     </tr>
-    
+
 <%if taxincluded%>
     <tr>
       <th colspan=5 align=right>Total</th>
@@ -141,6 +141,11 @@ adjust the colspan if you include this to shift subtotal one to the right
     </tr>
 <%end tax%>
 
+<%if rounding%>
+      <th colspan=5 align=right>Rundung</th>
+      <td colspan=2 align=right><%rounding%></td>
+<%end rounding%>
+
     <tr>
       <td colspan=2>&nbsp;</td>
       <td colspan=5><hr noshade></td>
@@ -184,7 +189,7 @@ adjust the colspan if you include this to shift subtotal one to the right
 </tr>
 
 <tr><td>&nbsp;</td></tr>
-  
+
 <tr>
   <td>
   <table width=100%>
index 1380631..983d976 100644 (file)
@@ -5,7 +5,7 @@
 <tr valign=bottom>
   <td width=10>&nbsp;</td>
   <td>
-  
+
   <table width=100%>
   <tr valign=top>
     <td>
     <td colspan=2>
       <table width=100% border=1>
         <tr>
-         <th width=17% align=left nowrap>Nummer</th>
-         <th width=17% align=left>Datum</th>
-         <th width=17% align=left>Gültig bis</th>
-         <th width=17% align=left nowrap>Kontakt</th>
-         <th width=17% align=left nowrap>Lagerplatz</th>
-         <th width=15% align=left nowrap>Lieferung mit</th>
-       </tr>
-
-       <tr>
-         <td><%quonumber%></td>
-         <td><%quodate%></td>
-         <td><%reqdate%></td>
-         <td><%employee%></td>
-         <td><%shippingpoint%></td>
-         <td><%shipvia%></td>
-       </tr>
+    <th width=17% align=left nowrap>Nummer</th>
+    <th width=17% align=left>Datum</th>
+    <th width=17% align=left>Gültig bis</th>
+    <th width=17% align=left nowrap>Kontakt</th>
+    <th width=17% align=left nowrap>Lagerplatz</th>
+    <th width=15% align=left nowrap>Lieferung mit</th>
+  </tr>
+
+  <tr>
+    <td><%quonumber%></td>
+    <td><%quodate%></td>
+    <td><%reqdate%></td>
+    <td><%employee%></td>
+    <td><%shippingpoint%></td>
+    <td><%shipvia%></td>
+  </tr>
       </table>
     </td>
   </tr>
     </tr>
 <%end tax%>
 
+<%if rounding%>
+      <th colspan=6 align=right>Rundung</th>
+      <td colspan=2 align=right><%rounding%></td>
+<%end rounding%>
+
     <tr>
       <td colspan=4>&nbsp;</td>
       <td colspan=4><hr noshade></td>
index 7f1bb62..9101d2c 100644 (file)
        </tr>
 [%- END %]
 
-[%- IF rounding %]
-        <tr>
-          <th align='right'>[% 'Rounding' | $T8 %]</th>
-          <td align='right'>[% LxERP.format_amount(rounding, 2) %]</td>
-        </tr>
-[%- END %]
-
 [%# tax %]
 [% FOREACH item = taxaccounts_array %]
 [% SET description_ref = item _ '_description' %]
        </tr>
   [%- END %]
 [%- END %]
+
+[%- IF rounding %]
+        <tr>
+          <th align='right'>[% 'Rounding' | $T8 %]</th>
+          <td align='right'>[% LxERP.format_amount(rounding, 2) %]</td>
+        </tr>
+[%- END %]
+
         <tr>
          <th align="right">[% 'Total' | $T8 %]</th>
          <td align="right">[% LxERP.format_amount(invtotal, 2) %]</td>
index fbeb529..6c6072e 100644 (file)
                 <td align='right'>[% LxERP.format_amount(invsubtotal, 2) %]</td>
               </tr>
 [%- END %]
+              [% tax %]
 [%- IF rounding %]
               <tr>
                 <th align='right'>[% 'Rounding' | $T8 %]</th>
                 <td align='right'>[% LxERP.format_amount(rounding, 2) %]</td>
               </tr>
 [%- END %]
-              [% tax %]
               <tr>
                 <th align="right">[% 'Total' | $T8 %]</th>
                 <td align="right">[% LxERP.format_amount(invtotal, 2) %]