Some bug fixes in suppliers module related to tax structure changes
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 26 Mar 2008 11:05:00 +0000 (11:05 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 26 Mar 2008 11:05:00 +0000 (11:05 +0000)
purchasing/includes/db/invoice_db.inc
purchasing/includes/db/invoice_items_db.inc
purchasing/includes/supp_trans_class.inc
purchasing/includes/ui/invoice_ui.inc
reporting/rep105.php

index 29640d4b0efafb1c9ec5c4634331d5478e3892ed..6b97d52d29c1a94a50070920c2b2a737a7e7882e 100644 (file)
@@ -75,6 +75,7 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang
        
        $tax_total = 0;
     $taxes = $supp_trans->get_taxes($supp_trans->tax_group_id);
+
     foreach ($taxes as $taxitem) 
     {
        $tax_total += $taxitem['Value'];
@@ -145,7 +146,7 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang
        }
        
                $line_taxfree = $entered_grn->taxfree_charge_price($supp_trans->tax_group_id);
-               $line_tax = $entered_grn->full_charge_price() - $line_taxfree;          
+               $line_tax = $entered_grn->full_charge_price($supp_trans->tax_group_id) - $line_taxfree;         
        
        update_supp_received_items_for_invoice($entered_grn->id, $entered_grn->po_detail_item, 
                $entered_grn->this_quantity_inv, $entered_grn->chg_price);
@@ -190,9 +191,9 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang
                
                if (!$supp_trans->is_invoice)
                        $taxitem['Value'] = -$taxitem['Value'];
-               
+               // here we suppose that tax is never included in price (we are company customer).
                        add_supp_invoice_tax_item($trans_type, $invoice_id, $taxitem['tax_type_id'],
-                               $taxitem['rate'], $taxitem['included_in_price'], $taxitem['Value']);                    
+                               $taxitem['rate'], 0, $taxitem['Value']);                
                
                add_gl_trans_supplier($trans_type, $invoice_id, $date_, 
                        $taxitem['purchasing_gl_code'], 0, 0, $taxitem['Value'], 
index 78849f7b018e61f4b449f11856b841ef0b21e6d8..18ff4aa9ba37f609783d7f5f2a73c5ebd29e5e8d 100644 (file)
@@ -32,7 +32,7 @@ function add_supp_invoice_gl_item($supp_trans_type, $supp_trans_no, $gl_code, $a
 
 function get_supp_invoice_items($supp_trans_type, $supp_trans_no)
 {
-       $sql = "SELECT *,unit_price+unit_tax AS FullUnitPrice FROM ".TB_PREF."supp_invoice_items
+       $sql = "SELECT *, unit_price AS FullUnitPrice FROM ".TB_PREF."supp_invoice_items
                WHERE supp_trans_type = $supp_trans_type
                AND supp_trans_no = $supp_trans_no ORDER BY id";
        return db_query($sql, "Cannot retreive supplier transaction detail records");
index d6e06714b2f670bf0a8e203e1ba48a348182713b..6bffc18570f9b2d9c72392a8c411ef65ffd27036 100644 (file)
@@ -167,16 +167,18 @@ all the info to do the necessary entries without looking up ie additional querie
                $this->gl_code = $gl_code;
        }
        
-       function full_charge_price()
+       function full_charge_price($tax_group_id, $tax_group=null)
        {
-               return $this->chg_price;
+               return get_full_price_for_item($this->item_code, 
+                 $this->chg_price, $tax_group_id, 0, $tax_group);
        }
        
        function taxfree_charge_price($tax_group_id, $tax_group=null)
        {
-               if ($tax_group_id==null)
-                       return $this->chg_price;
-               return get_tax_free_price_for_item($this->item_code, $this->chg_price, $tax_group_id, $tax_group);
+//             if ($tax_group_id==null)
+//                     return $this->chg_price;
+               return get_tax_free_price_for_item($this->item_code, $this->chg_price, 
+                 $tax_group_id, 0, $tax_group);
        }
 }
 
index a7893386dcb0a458ce2dff22a3cda62bc145a46c..7af53f0cf36fcb51d41267481f41e91c9f9e7df1 100644 (file)
@@ -10,7 +10,6 @@ function copy_from_trans(&$supp_trans)
        $_POST['supp_reference'] = $supp_trans->supp_reference;
        $_POST['reference'] = $supp_trans->reference;
        $_POST['supplier_id'] = $supp_trans->supplier_id;
-       $_POST['tax_group_id'] = $supp_trans->tax_group_id;
 }
 
 //--------------------------------------------------------------------------------------------------
@@ -22,8 +21,6 @@ function copy_to_trans(&$supp_trans)
        $supp_trans->due_date = $_POST['due_date'];
        $supp_trans->supp_reference = $_POST['supp_reference'];
        $supp_trans->reference = $_POST['reference'];
-       $supp_trans->tax_group_id = $_POST['tax_group_id'];
-
 
        $supp_trans->ov_amount = 0; /* for starters */
        if (count($supp_trans->grn_items) > 0)
@@ -107,11 +104,7 @@ function invoice_header(&$supp_trans)
                exchange_rate_display($supplier_currency, $company_currency, $_POST['tran_date']);
        }
 
-
-       if (!isset($_POST['tax_group_id']))
-               $_POST['tax_group_id'] = $supp_trans->tax_group_id;
-    tax_groups_list_row(_("Tax Group:"), 'tax_group_id', $_POST['tax_group_id'], true);
-
+  label_row(_("Tax Group:"), $supp_trans->tax_description);
        echo "</table>";
 
        echo "</td>";
@@ -130,7 +123,7 @@ function invoice_totals(&$supp_trans)
     start_table("$table_style width=95%");
        label_row(_("Sub-total:"), price_format( $supp_trans->ov_amount), "align=right", "align=right");
 
-    $taxes = $supp_trans->get_taxes($_POST['tax_group_id']);
+    $taxes = $supp_trans->get_taxes($supp_trans->tax_group_id);
     $tax_total = display_edit_tax_items($taxes, 1, 0); // tax_included==0 (we are the company)
 
     $display_total = price_format($supp_trans->ov_amount + $tax_total);
index a5e0ef3c112277959a3c3e5460b38bfdf069922b..1d3f66b3dbe9fa40f7af137fbc6d942a526ea221 100644 (file)
@@ -147,7 +147,7 @@ function print_order_status_list()
                $rep->TextCol(0, 1,     $myrow['stk_code']);
                $rep->TextCol(1, 2,     $myrow['description']);
                $rep->TextCol(2, 3,     number_format2($myrow['quantity'], $dec));
-               $rep->TextCol(3, 4,     number_format2($myrow['qty_invoiced'], $dec));
+               $rep->TextCol(3, 4,     number_format2($myrow['qty_sent'], $dec));
                $rep->TextCol(4, 5,     number_format2($myrow['quantity'] - $myrow['qty_sent'], $dec));
                if ($myrow['quantity'] - $myrow['qty_sent'] > 0)
                {