Rewritten sales shipping cost taxation, improved shipping cost handling in sales...
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 23 Jul 2019 07:54:27 +0000 (09:54 +0200)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 19 Aug 2019 10:41:58 +0000 (12:41 +0200)
37 files changed:
admin/gl_setup.php
applications/fixed_assets.php
applications/setup.php
includes/sysnames.inc
includes/ui/ui_lists.inc
inventory/includes/db/items_db.inc
inventory/manage/items.php
purchasing/includes/po_class.inc
purchasing/includes/supp_trans_class.inc
purchasing/includes/ui/po_ui.inc
reporting/includes/reports_classes.inc
reporting/rep109.php
reporting/rep111.php
reporting/rep209.php
sales/customer_delivery.php
sales/customer_invoice.php
sales/includes/cart_class.inc
sales/includes/db/cust_trans_db.inc
sales/includes/db/sales_credit_db.inc
sales/includes/db/sales_invoice_db.inc
sales/includes/db/sales_order_db.inc
sales/includes/ui/sales_credit_ui.inc
sales/includes/ui/sales_order_ui.inc
sales/manage/customer_branches.php
sales/manage/customers.php
sales/sales_order_entry.php
sales/view/view_credit.php
sales/view/view_dispatch.php
sales/view/view_invoice.php
sales/view/view_sales_order.php
sql/alter2.5.php
sql/alter2.5.sql
sql/en_US-demo.sql
sql/en_US-new.sql
taxes/db/tax_groups_db.inc
taxes/tax_calc.inc
taxes/tax_groups.php

index 3b0868160c51b43906857a37e408dc9c14425c4b..2b6de2178ec2a46afb3317e791dc7826d6446baa 100644 (file)
@@ -222,7 +222,7 @@ check_row(_("Print Item Image on Quote:"), 'print_item_images_on_quote', null);
 
 textarea_row(_("Legal Text on Invoice:"), 'legal_text', $_POST['legal_text'], 32, 4);
 
-gl_all_accounts_list_row(_("Shipping Charged Account:"), 'freight_act', $_POST['freight_act']);
+gl_all_accounts_list_row(_("Shipping Charged Account (default):"), 'freight_act', $_POST['freight_act']);
 
 gl_all_accounts_list_row(_("Deferred Income Account:"), 'deferred_income_act', $_POST['deferred_income_act'], true, false,
        _("Not used"), false, false, false);
index 8a3bb86dcb6e22c16b3adff79cb40a225ee4d0a2..8c6485d5805ba68481ad8775f9be5165d4a9235d 100644 (file)
@@ -43,7 +43,7 @@ class assets_app extends application
                $this->add_module(_("Maintenance"));
                
                $this->add_lapp_function(2, _("Fixed &Assets"),
-                       "inventory/manage/items.php?FixedAsset=1", 'SA_ASSET', MENU_ENTRY);
+                       "inventory/manage/items.php?type=F", 'SA_ASSET', MENU_ENTRY);
                $this->add_rapp_function(2, _("Fixed Assets &Locations"),
                        "inventory/manage/locations.php?FixedAsset=1", 'SA_INVENTORYLOCATION', MENU_MAINTENANCE);
                $this->add_rapp_function(2, _("Fixed Assets &Categories"),
index 5f29aff11f8cac3a00e861c1972a800e67525857..9b2e1118628e0d543fc1502a329b9f6c2596f1eb 100644 (file)
@@ -44,6 +44,8 @@ class setup_app extends application
                        "admin/payment_terms.php?", 'SA_PAYTERMS', MENU_MAINTENANCE);
                $this->add_lapp_function(1, _("Shi&pping Company"),
                        "admin/shipping_companies.php?", 'SA_SHIPPING', MENU_MAINTENANCE);
+               $this->add_lapp_function(1, _("Shipping &Options"),
+                       "inventory/manage/items.php?type=T", 'SA_SHIPPING', MENU_ENTRY);
                $this->add_rapp_function(1, _("&Points of Sale"),
                        "sales/manage/sales_points.php?", 'SA_POSSETUP', MENU_MAINTENANCE);
                $this->add_rapp_function(1, _("&Printers"),
index 507bd698dedecc98451c72b65190a208d8d129e9..1d7df6f012be6237b161f0aca6801fdd5306c328 100644 (file)
@@ -170,7 +170,8 @@ $depreciation_methods = array(
 $stock_types = array(
        'M' => _("Manufactured"),
        'B' => _("Purchased"),
-       'D' => _("Service")
+       'D' => _("Service"),
+       'T' => _("Shipping")
 );
 
 //----------------------------------------------------------------------------------
index 07202791f53962d019cef82e16d9ba3eeb9b237f..58a2bae2215f2c2165cb273c54d1d28add045731 100644 (file)
@@ -823,13 +823,17 @@ function dimensions_list_row($label, $name, $selected_id=null, $no_option=false,
 function stock_items_list($name, $selected_id=null, $all_option=false, 
        $submit_on_change=false, $opts=array(), $editkey = false, $type = "stock")
 {
-       $sql = "SELECT stock_id, s.description, c.description, s.inactive, s.editable
-                       FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
-
-       if (isset($opts['fixed_asset']) && $opts['fixed_asset'])
-               $sql .= " AND mb_flag='F'";
+       $sql = "SELECT stock_id, s.description, c.description, shipper.shipper_name, s.inactive, s.editable
+                       FROM ".TB_PREF."stock_master s 
+                               LEFT JOIN ".TB_PREF."shippers shipper ON shipper.shipper_id=s.shipper_id
+                               LEFT JOIN ".TB_PREF."stock_category c ON s.category_id=c.category_id";
+
+       if (isset($opts['shipping']) && $opts['shipping'])
+               $where[] = "mb_flag='T'";
+       elseif (isset($opts['fixed_asset']) && $opts['fixed_asset'])
+               $where[] = "mb_flag='F'";
        else
-               $sql .= " AND mb_flag!='F'";
+               $where[] = "NOT mb_flag IN('F','T')";
 
        if ($editkey)
                set_editor('item', $name, $editkey);
@@ -842,14 +846,15 @@ function stock_items_list($name, $selected_id=null, $all_option=false,
                        'spec_id' => ALL_TEXT,
                        'search_box' => true,
                        'search' => array("stock_id", "c.description","s.description"),
-                       'search_submit' => get_company_pref('no_item_list')!=0 && (!isset($opts['fixed_asset']) || !$opts['fixed_asset']),
+                       'search_submit' => get_company_pref('no_item_list') != 0 && (!isset($opts['fixed_asset']) || !$opts['fixed_asset']),
                        'size'=>10,
                        'select_submit'=> $submit_on_change,
                        'category' => 2,
-                       'order' => array('c.description','stock_id'),
+                       'order' => (isset($opts['shipping']) && $opts['shipping']) ? array('shipper.shipper_name','stock_id'): array('c.description','stock_id'),
                        'editlink' => $editkey ? add_edit_combo('item') : false,
                        'editable' => false,
-                       'max' => 255
+                       'max' => 255,
+                       'where' => $where
                  ), $opts), $type );
        return $ret;
 }
@@ -907,7 +912,7 @@ function sales_items_list($name, $selected_id=null, $all_option=false,
                        ".TB_PREF."stock_category c
                        ON i.category_id=c.category_id
                        WHERE i.stock_id=s.stock_id
-      AND mb_flag != 'F'";
+      AND NOT mb_flag IN('F','T')";
 
        
        if ($type == 'local')   { // exclude foreign codes
@@ -1032,7 +1037,7 @@ function stock_purchasable_items_list($name, $selected_id=null,
        $all_option=false, $submit_on_change=false, $all=false, $editkey=false)
 {
        return stock_items_list($name, $selected_id, $all_option, $submit_on_change,
-               array('where'=>array("NOT no_purchase"), 
+               array('where'=>array("NOT no_purchase", "mb_flag!='F'"), 
                        'show_inactive'=>$all), $editkey, "stock_purchased");
 }
 //
@@ -1051,19 +1056,53 @@ function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
 
 //------------------------------------------------------------------------------------
 
-function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
+function shipping_methods_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
+{
+       return stock_items_list($name, $selected_id, $all_option, $submit_on_change,
+               array('type'=>1, 'shipping'=>true, 'category' => false, 'search_box'=>false, 'search_sumbit' => false),
+                       false, false);//, "shipping_methods");
+}
+
+function shipping_methods_list_cells($label, $name, $selected_id=null,
+                               $all_option=false, $submit_on_change=false)
+{
+       if ($label != null)
+               echo "<td>$label</td>\n";
+       echo "<td>";
+       echo shipping_methods_list($name, $selected_id, $all_option, $submit_on_change);
+       echo "</td>\n";
+}
+
+function shipping_methods_list_row($label, $name, $selected_id=null,
+               $all_option=false, $submit_on_change=false)
+{
+       echo "<tr><td class='label'>$label</td>";
+       shipping_methods_list_cells(null, $name, $selected_id, $all_option, $submit_on_change);
+       echo "</tr>\n";
+}
+
+//------------------------------------------------------------------------------------
+
+function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true, $all=true)
 {
        global $stock_types;
 
+       $options = $stock_types;
+       if (!$all)
+       {
+               unset($options['T']);
+               unset($options['F']);
+       }
        echo "<tr>";
        if ($label != null)
                echo "<td class='label'>$label</td>\n";
        echo "<td>";
-
-       echo array_selector($name, $selected_id, $stock_types, 
+               
+       echo array_selector($name, $selected_id, $options, 
                array( 
                        'select_submit'=> true, 
-                       'disabled' => !$enabled) );
+                       'disabled' => !$enabled)
+               );
        echo "</td></tr>\n";
 }
 
@@ -1263,26 +1302,31 @@ function item_tax_types_list_row($label, $name, $selected_id=null, $show_inactiv
 
 //------------------------------------------------------------------------------------
 
-function shippers_list($name, $selected_id=null)
+function shippers_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
 {
        $sql = "SELECT shipper_id, shipper_name, inactive FROM ".TB_PREF."shippers";
        return combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', 
-               array('order'=>array('shipper_name')));
+               array('order'=>array('shipper_name'),
+                       'spec_option' => $none_option,
+                       'spec_id' => ALL_NUMERIC,
+                       'select_submit'=> $submit_on_change,
+                       'async' => false,
+));
 }
 
-function shippers_list_cells($label, $name, $selected_id=null)
+function shippers_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
 {
        if ($label != null)
                echo "<td>$label</td>\n";
        echo "<td>";
-       echo shippers_list($name, $selected_id);
+       echo shippers_list($name, $selected_id, $none_option, $submit_on_change);
        echo "</td>\n";
 }
 
-function shippers_list_row($label, $name, $selected_id=null)
+function shippers_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
 {
        echo "<tr><td class='label'>$label</td>";
-       shippers_list_cells(null, $name, $selected_id);
+       shippers_list_cells(null, $name, $selected_id, $none_option, $submit_on_change);
        echo "</tr>\n";
 }
 
@@ -1711,13 +1755,13 @@ function class_list_row($label, $name, $selected_id=null, $submit_on_change=fals
 }
 
 //-----------------------------------------------------------------------------------------------
-function stock_categories_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $fixed_asset=false)
+function stock_categories_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $type=false)
 {
        $where_opts = array();
-       if ($fixed_asset)
-               $where_opts[0] = "dflt_mb_flag='F'";
+       if (in_array($type, array('F', 'T')))
+               $where_opts[] = "dflt_mb_flag=".db_escape($type);
        else
-               $where_opts[0] = "dflt_mb_flag!='F'";
+               $where_opts[] = "NOT dflt_mb_flag IN('F','T')";
 
        $sql = "SELECT category_id, description, inactive FROM ".TB_PREF."stock_category";
        return combo_input($name, $selected_id, $sql, 'category_id', 'description',
@@ -1730,19 +1774,19 @@ function stock_categories_list($name, $selected_id=null, $spec_opt=false, $submi
                ));
 }
 
-function stock_categories_list_cells($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $fixed_asset=false)
+function stock_categories_list_cells($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $type=false)
 {
        if ($label != null)
                echo "<td>$label</td>\n";
        echo "<td>";
-       echo stock_categories_list($name, $selected_id, $spec_opt, $submit_on_change, $fixed_asset);
+       echo stock_categories_list($name, $selected_id, $spec_opt, $submit_on_change, $type);
        echo "</td>\n";
 }
 
-function stock_categories_list_row($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $fixed_asset=false)
+function stock_categories_list_row($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false, $type=false)
 {
        echo "<tr><td class='label'>$label</td>";
-       stock_categories_list_cells(null, $name, $selected_id, $spec_opt, $submit_on_change, $fixed_asset);
+       stock_categories_list_cells(null, $name, $selected_id, $spec_opt, $submit_on_change, $type);
        echo "</tr>\n";
 }
 
index cfbbbdbe579bd0f68097906ecead76ce54957c08..57ddf3162d33b562d558318e12e023fb79bd9a4b 100644 (file)
@@ -14,7 +14,7 @@ function update_item($stock_id, $description, $long_description, $category_id,
        $cogs_account,  $adjustment_account, $wip_account, $dimension_id, 
        $dimension2_id, $no_sale, $editable, $no_purchase,
        $depreciation_method = 'D', $depreciation_rate=100, $depreciation_factor=1,
-       $depreciation_start=null, $fa_class_id=null, $vat_category='')
+       $depreciation_start=null, $fa_class_id=null, $vat_category='', $shipper_id=0)
 {
        $sql = "UPDATE ".TB_PREF."stock_master SET long_description=".db_escape($long_description).",
                description=".db_escape($description).",
@@ -33,7 +33,8 @@ function update_item($stock_id, $description, $long_description, $category_id,
                depreciation_method=".db_escape($depreciation_method).",
                depreciation_rate=".db_escape($depreciation_rate).",
                depreciation_factor=".db_escape($depreciation_factor).",
-               fa_class_id=".db_escape($fa_class_id);
+               fa_class_id=".db_escape($fa_class_id).",
+               shipper_id=".db_escape($shipper_id);
 
        if ($units != '')
                $sql .= ", units=".db_escape($units);
@@ -61,14 +62,14 @@ function add_item($stock_id, $description, $long_description, $category_id,
        $cogs_account, $adjustment_account,     $wip_account, $dimension_id, 
        $dimension2_id, $no_sale, $editable, $no_purchase,
        $depreciation_method='D', $depreciation_rate=100,  $depreciation_factor=1, $depreciation_start=null,
-       $fa_class_id=null, $vat_category=0)
+       $fa_class_id=null, $vat_category=0, $shipper_id=0)
 {
        $sql = "INSERT INTO ".TB_PREF."stock_master (stock_id, description, long_description, category_id,
                tax_type_id, units, mb_flag, sales_account, inventory_account, cogs_account,
                adjustment_account, wip_account, dimension_id, dimension2_id, no_sale, no_purchase, editable, vat_category,
                depreciation_method, depreciation_rate, depreciation_factor"
                .(isset($depreciation_start) ? ", depreciation_start, depreciation_date, fa_class_id" : "")
-               .") VALUES (".db_escape($stock_id).", ".db_escape($description).", ".db_escape($long_description).",
+               .",shipper_id) VALUES (".db_escape($stock_id).", ".db_escape($description).", ".db_escape($long_description).",
                ".db_escape($category_id).", ".db_escape($tax_type_id).", "
                .db_escape($units).", ".db_escape($mb_flag).",
                ".db_escape($sales_account).", ".db_escape($inventory_account)
@@ -80,7 +81,7 @@ function add_item($stock_id, $description, $long_description, $category_id,
                .db_escape($editable).",".db_escape($vat_category).","
                .db_escape($depreciation_method).",".db_escape($depreciation_rate).",".db_escape($depreciation_factor)
                .(isset($depreciation_start) ? ",'".date2sql($depreciation_start)."','".date2sql($depreciation_start)."',".db_escape($fa_class_id) : "")
-               .")";
+               .",".db_escape($shipper_id).")";
 
        db_query($sql, "The item could not be added");
 
@@ -149,7 +150,10 @@ function item_in_foreign_codes($stock_id)
         _('Cannot delete this item because there are existing sales order items for it.'),
        "SELECT COUNT(*) FROM "
                .TB_PREF."purch_order_details WHERE item_code=".db_escape($stock_id)=>
-        _('Cannot delete this item because there are existing purchase order items for it.')
+        _('Cannot delete this item because there are existing purchase order items for it.'),
+       "SELECT COUNT(*) FROM "
+               .TB_PREF."sales_orders WHERE ship_via=".db_escape($stock_id)=>
+        _('Cannot delete this item because there are existing sales transactions for it.'),
        );
 
        $msg = '';
@@ -230,4 +234,3 @@ function get_items_search($description, $type)
 
        return db_query($sql, "Failed in retreiving item list.");
 }
-
index 352a2fbf6e028b925b529108b1b08015a49ef711..fb3905a5ce3fa6047a53b1a2681cc94d494c6caa 100644 (file)
@@ -19,16 +19,21 @@ if ($SysPrefs->use_popup_windows)
 if (user_use_date_picker())
        $js .= get_js_date_picker();
 
-if (isset($_GET['FixedAsset'])) {
-  $page_security = 'SA_ASSET';
-  $_SESSION['page_title'] = _($help_context = "Fixed Assets");
-  $_POST['mb_flag'] = 'F';
-  $_POST['fixed_asset']  = 1;
+if (isset($_GET['type'])) {
+       if ($_GET['type'] == 'F') {
+
+         $page_security = 'SA_ASSET';
+         $_SESSION['page_title'] = _($help_context = "Fixed Assets");
+         $_POST['mb_flag'] = 'F';
+       } elseif ($_GET['type'] == 'T') {
+
+         $page_security = 'SA_SHIPPING';
+         $_SESSION['page_title'] = _($help_context = "Shipping Options");
+         $_POST['mb_flag'] = 'T';
+       }
 }
 else {
   $_SESSION['page_title'] = _($help_context = "Items");
-       if (!get_post('fixed_asset'))
-               $_POST['fixed_asset']  = 0;
 }
 
 
@@ -142,7 +147,7 @@ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
  /* EOF Add Image upload for New Item  - by Ori */
 }
 
-if (get_post('fixed_asset')) {
+if (get_post('mb_flag') == 'F') {
        check_db_has_fixed_asset_categories(_("There are no fixed asset categories defined in the system. At least one fixed asset category is required to add a fixed asset."));
        check_db_has_fixed_asset_classes(_("There are no fixed asset classes defined in the system. At least one fixed asset class is required to add a fixed asset."));
 } else
@@ -157,7 +162,8 @@ function clear_data()
        unset($_POST['category_id']);
        unset($_POST['tax_type_id']);
        unset($_POST['units']);
-       unset($_POST['mb_flag']);
+       if (!in_array(@$_POST['mb_flag'], array('T', 'F')))
+               unset($_POST['mb_flag']);
        unset($_POST['NewStockID']);
        unset($_POST['dimension_id']);
        unset($_POST['dimension2_id']);
@@ -205,7 +211,7 @@ if (isset($_POST['addupdate']))
                        set_focus('NewStockID');
        }
        
-  if (get_post('fixed_asset')) {
+  if (get_post('mb_flag') == 'F') {
     if ($_POST['depreciation_rate'] > 100) {
       $_POST['depreciation_rate'] = 100;
     }
@@ -231,14 +237,14 @@ if (isset($_POST['addupdate']))
                { /*so its an existing one */
                        update_item($_POST['NewStockID'], $_POST['description'],
                                $_POST['long_description'], $_POST['category_id'], 
-                               $_POST['tax_type_id'], get_post('units'),
-                               get_post('fixed_asset') ? 'F' : get_post('mb_flag'), $_POST['sales_account'],
+                               $_POST['tax_type_id'], get_post('units'), 
+                               get_post('mb_flag'), $_POST['sales_account'],
                                $_POST['inventory_account'], $_POST['cogs_account'],
                                $_POST['adjustment_account'], $_POST['wip_account'], 
                                $_POST['dimension_id'], $_POST['dimension2_id'],
                                check_value('no_sale'), check_value('editable'), check_value('no_purchase'),
                                get_post('depreciation_method'), input_num('depreciation_rate'), input_num('depreciation_factor'), get_post('depreciation_start', null),
-                               get_post('fa_class_id'), get_post('vat_category'));
+                               get_post('fa_class_id'), get_post('vat_category'), get_post('shipper'));
 
                        update_record_status($_POST['NewStockID'], $_POST['inactive'],
                                'stock_master', 'stock_id');
@@ -253,13 +259,13 @@ if (isset($_POST['addupdate']))
 
                        add_item($_POST['NewStockID'], $_POST['description'],
                                $_POST['long_description'], $_POST['category_id'], $_POST['tax_type_id'],
-                               $_POST['units'], get_post('fixed_asset') ? 'F' : get_post('mb_flag'), $_POST['sales_account'],
+                               $_POST['units'], get_post('mb_flag'), $_POST['sales_account'],
                                $_POST['inventory_account'], $_POST['cogs_account'],
                                $_POST['adjustment_account'], $_POST['wip_account'], 
                                $_POST['dimension_id'], $_POST['dimension2_id'],
                                check_value('no_sale'), check_value('editable'), check_value('no_purchase'),
                                get_post('depreciation_method'), input_num('depreciation_rate'), input_num('depreciation_factor'), get_post('depreciation_start', null),
-                               get_post('fa_class_id'), get_post('vat_category'));
+                               get_post('fa_class_id'), get_post('vat_category'), get_post('shipper'));
 
                        display_notification(_("A new item has been added."));
                        $_POST['stock_id'] = $_POST['NewStockID'] = 
@@ -390,13 +396,12 @@ function item_settings(&$stock_id, $new_item)
                hidden('NewStockID', $_POST['NewStockID']);
                set_focus('description');
        }
-       $fixed_asset = get_post('fixed_asset');
 
        text_row(_("Name:"), 'description', null, 52, 200);
 
        textarea_row(_('Description:'), 'long_description', null, 42, 3);
 
-       stock_categories_list_row(_("Category:"), 'category_id', null, false, $new_item, $fixed_asset);
+       stock_categories_list_row(_("Category:"), 'category_id', null, false, $new_item, get_post('mb_flag'));
 
        if ($new_item && (list_updated('category_id') || !isset($_POST['sales_account']))) { // changed category for new item or first page view
 
@@ -404,10 +409,14 @@ function item_settings(&$stock_id, $new_item)
 
                $_POST['tax_type_id'] = $category_record["dflt_tax_type"];
                $_POST['units'] = $category_record["dflt_units"];
-               $_POST['mb_flag'] = $category_record["dflt_mb_flag"];
+               if (!in_array(get_post('mb_flag'), array('T', 'F')))
+                       $_POST['mb_flag'] = $category_record["dflt_mb_flag"];
                $_POST['inventory_account'] = $category_record["dflt_inventory_act"];
                $_POST['cogs_account'] = $category_record["dflt_cogs_act"];
-               $_POST['sales_account'] = $category_record["dflt_sales_act"];
+               if (get_post('mb_flag') == 'T' && !isset($_POST['sales_account']))
+                       $_POST['sales_account'] = get_company_pref('freight_act');
+               else
+                       $_POST['sales_account'] = $category_record["dflt_sales_act"];
                $_POST['adjustment_account'] = $category_record["dflt_adjustment_act"];
                $_POST['wip_account'] = $category_record["dflt_wip_act"];
                $_POST['dimension_id'] = $category_record["dflt_dim1"];
@@ -423,23 +432,24 @@ function item_settings(&$stock_id, $new_item)
        // show inactive item tax type in selector only if already set.
   item_tax_types_list_row(_("Item Tax Type:"), 'tax_type_id', null, !$new_item && item_type_inactive(get_post('tax_type_id')));
 
-       if (!get_post('fixed_asset'))
-               stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, $fresh_item);
+       if (!in_array(get_post('mb_flag'), array('T', 'F')))
+               stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, $fresh_item, false);
 
        stock_units_list_row(_('Units of Measure:'), 'units', null, $fresh_item);
 
     vat_category_list_row(_("VAT category:"), 'vat_category', null, $fresh_item, false, !$new_item);
 
+       if (get_post('mb_flag') != 'T')
        check_row(_("Editable description:"), 'editable');
 
-       if (get_post('fixed_asset'))
+       if (get_post('mb_flag') == 'F')
                hidden('no_sale', 0);
        else
                check_row(_("Exclude from sales:"), 'no_sale');
 
        check_row(_("Exclude from purchases:"), 'no_purchase');
 
-       if (get_post('fixed_asset')) {
+       if (get_post('mb_flag') == 'F') {
                table_section_title(_("Depreciation"));
 
                fixed_asset_classes_list_row(_("Fixed Asset Class").':', 'fa_class_id', null, false, true);
@@ -478,6 +488,8 @@ function item_settings(&$stock_id, $new_item)
                        label_row(_("Last Depreciation").':', $_POST['depreciation_date']==$_POST['depreciation_start'] ? _("None") :  $_POST['depreciation_date']);
                }
                hidden('depreciation_date');
+       } else if (get_post('mb_flag') == 'T') {
+               shippers_list_row(_("Shipping company:"), 'shipper');
        }
        table_section(2);
 
@@ -499,25 +511,24 @@ function item_settings(&$stock_id, $new_item)
 
        gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']);
 
-       if (get_post('fixed_asset')) {
-               gl_all_accounts_list_row(_("Asset account:"), 'inventory_account', $_POST['inventory_account']);
-               gl_all_accounts_list_row(_("Depreciation cost account:"), 'cogs_account', $_POST['cogs_account']);
-               gl_all_accounts_list_row(_("Depreciation/Disposal account:"), 'adjustment_account', $_POST['adjustment_account']);
-       }
-       elseif (!is_service(get_post('mb_flag')))
-       {
-               gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']);
-               gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
-               gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'adjustment_account', $_POST['adjustment_account']);
-       }
-       else 
-       {
-               gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
-               hidden('inventory_account', $_POST['inventory_account']);
-               hidden('adjustment_account', $_POST['adjustment_account']);
+       switch(get_post('mb_flag')) {
+               case 'F':
+                       gl_all_accounts_list_row(_("Asset account:"), 'inventory_account', $_POST['inventory_account']);
+                       gl_all_accounts_list_row(_("Depreciation cost account:"), 'cogs_account', $_POST['cogs_account']);
+                       gl_all_accounts_list_row(_("Depreciation/Disposal account:"), 'adjustment_account', $_POST['adjustment_account']);
+                       break;
+               case 'T':
+               case 'D':
+                       gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
+                       hidden('inventory_account', $_POST['inventory_account']);
+                       hidden('adjustment_account', $_POST['adjustment_account']);
+                       break;
+               default:
+                       gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']);
+                       gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
+                       gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'adjustment_account', $_POST['adjustment_account']);
        }
 
-
        if (is_manufactured(get_post('mb_flag')))
                gl_all_accounts_list_row(_("WIP Account:"), 'wip_account', $_POST['wip_account']);
        else
@@ -549,7 +560,7 @@ function item_settings(&$stock_id, $new_item)
                check_row(_("Delete Image:"), 'del_image');
 
        record_status_list_row(_("Item status:"), 'inactive');
-       if (get_post('fixed_asset')) {
+       if (get_post('mb_flag') == 'F') {
                table_section_title(_("Values"));
                if (!$new_item) {
                        hidden('material_cost');
@@ -589,8 +600,12 @@ if (db_has_stock_items())
 {
        start_table(TABLESTYLE_NOBORDER);
        start_row();
-    stock_items_list_cells(_("Select an item:"), 'stock_id', null,
-         _('New item'), true, check_value('show_inactive'), false, array('fixed_asset' => get_post('fixed_asset')));
+       if (get_post('mb_flag') == 'T')
+               shipping_methods_list_cells(_("Select method:"), 'stock_id', null, _("New method"), true);
+       else
+       stock_items_list_cells(_("Select an item:"), 'stock_id', null,
+                       _('New item'), true, check_value('show_inactive'), false,
+                       array('fixed_asset' => get_post('mb_flag') == 'F'));
        $new_item = get_post('stock_id')=='';
        check_cells(_("Show inactive:"), 'show_inactive', null, true);
        end_row();
@@ -612,22 +627,33 @@ $stock_id = get_post('stock_id');
 if (!$stock_id)
        unset($_POST['_tabs_sel']); // force settings tab for new customer
 
-$tabs = (get_post('fixed_asset'))
-       ? array(
-               'settings' => array(_('&General settings'), $stock_id),
-               'movement' => array(_('&Transactions'), $stock_id) )
-       : array(
-               'settings' => array(_('&General settings'), $stock_id),
-               'sales_pricing' => array(_('S&ales Pricing'), (user_check_access('SA_SALESPRICE') ? $stock_id : null)),
-               'purchase_pricing' => array(_('&Purchasing Pricing'), (user_check_access('SA_PURCHASEPRICING') ? $stock_id : null)),
-               'unit_cost' => array(_('Unit &Cost'), (user_check_access('SA_STANDARDCOST') ? $stock_id : null)),
-               'reorder_level' => array(_('&Reorder Levels'), (is_inventory_item($stock_id) && 
-                       user_check_access('SA_REORDER') ? $stock_id : null)),
-               'movement' => array(_('&Transactions'), (user_check_access('SA_ITEMSTRANSVIEW') && is_inventory_item($stock_id) ? 
-                       $stock_id : null)),
-               'status' => array(_('&Status'), (user_check_access('SA_ITEMSSTATVIEW') ? $stock_id : null)),
-       );
-
+switch(get_post('mb_flag')) {
+       case 'F':
+               $tabs = array(
+                       'settings' => array(_('&General settings'), $stock_id),
+                       'movement' => array(_('&Transactions'), $stock_id) );
+               break;
+       case 'T':
+               $tabs = array(
+                       'settings' => array(_('&General settings'), $stock_id),
+                       'sales_pricing' => array(_('S&ales Pricing'), (user_check_access('SA_SALESPRICE') ? $stock_id : null)),
+                       'purchase_pricing' => array(_('&Purchasing Pricing'), (user_check_access('SA_PURCHASEPRICING') ? $stock_id : null)),
+                       'unit_cost' => array(_('Unit &Cost'), (user_check_access('SA_STANDARDCOST') ? $stock_id : null)),
+                       );
+               break;
+
+       default:
+               $tabs = array(
+                       'settings' => array(_('&General settings'), $stock_id),
+                       'sales_pricing' => array(_('S&ales Pricing'), (user_check_access('SA_SALESPRICE') ? $stock_id : null)),
+                       'purchase_pricing' => array(_('&Purchasing Pricing'), (user_check_access('SA_PURCHASEPRICING') ? $stock_id : null)),
+                       'unit_cost' => array(_('Unit &Cost'), (user_check_access('SA_STANDARDCOST') ? $stock_id : null)),
+                       'reorder_level' => array(_('&Reorder Levels'), (is_inventory_item($stock_id) && 
+                               user_check_access('SA_REORDER') ? $stock_id : null)),
+                       'movement' => array(_('&Transactions'), (user_check_access('SA_ITEMSTRANSVIEW') && is_inventory_item($stock_id) ? 
+                               $stock_id : null)),
+                       'status' => array(_('&Status'), (user_check_access('SA_ITEMSSTATVIEW') ? $stock_id : null)), );
+}
 tabbed_content_start('tabs', $tabs);
 
        switch (get_post('_tabs_sel')) {
@@ -675,9 +701,8 @@ tabbed_content_end();
 div_end();
 
 hidden('fixed_asset', get_post('fixed_asset'));
-
-if (get_post('fixed_asset'))
-       hidden('mb_flag', 'F');
+if (in_array(get_post('mb_flag'), array('F', 'T')))
+       hidden('mb_flag', get_post('mb_flag'));
 
 end_form();
 
index 7db50351e79fde1942bb2cf9e6129012fce237c6..b5dcdc0ba4140397d4e52ca5563d0bcac79a2faa 100644 (file)
@@ -148,8 +148,7 @@ class purch_order
                        $items[] = $ln_itm->stock_id;
                        $prices[] = round($ln_itm->price * $ln_itm->quantity,  user_price_dec());
                }
-               $taxes = get_tax_for_items($this->trans_type, $items, $prices, 0,
-                 $this->tax_group_id, $this->tax_included);
+               $taxes = get_tax_for_items($this->trans_type, $items, $prices, $this->tax_group_id, $this->tax_included);
 
        // Adjustment for swiss franken, we always have 5 rappen = 1/20 franken
            if ($this->curr_code == 'CHF') {
@@ -180,8 +179,7 @@ class purch_order
                }
 
                if (!$this->tax_included ) {
-                       $taxes = get_tax_for_items($this->trans_type, $items, $prices, 0, $this->tax_group_id,
-                       $this->tax_included);
+                       $taxes = get_tax_for_items($this->trans_type, $items, $prices, $this->tax_group_id, $this->tax_included);
 
                        foreach($taxes as $tax)
                                $total += round($tax['Value'], $dec);
index ddb55681e038a515dbe36a0353b840c2da6bc678..80adbc18b9a50e4eec65879b568fa4060c4deb2b 100644 (file)
@@ -135,7 +135,7 @@ class supp_trans
                $prices[] = round( $ln_itm->this_quantity_inv * $ln_itm->chg_price, user_price_dec());
         }
 
-        $taxes = get_tax_for_items($this->trans_type, $items, $prices, 0, $this->tax_group_id, 
+        $taxes = get_tax_for_items($this->trans_type, $items, $prices, $this->tax_group_id, 
                $this->tax_included);
 
                if (isset($this->tax_overrides))
index 3dd64c62d23720b4d586335897d8cad69ab393ef..092e801c58952f2df1d07514d5790d49217eedc1 100644 (file)
@@ -402,7 +402,7 @@ function po_item_controls(&$order, &$rowcounter, $line_no=-1)
                if ($order->fixed_asset)
                        stock_purchasable_fa_list_cells(null, 'stock_id', null, false, true, false, true, $order->line_items);
                else
-                       stock_items_list_cells(null, 'stock_id', null, false, true, false, true, array('editable' => 30, 'where'=>array("NOT no_purchase")));
+                       stock_purchasable_items_list_cells(null, 'stock_id', null, false, true, false, true, array('editable' => 30, 'where'=>array("NOT no_purchase")));
 
                if (list_updated('stock_id')) {
                            $Ajax->activate('price');
index 0d150930760c79f8c096e1599f1561f73c161a5a..bc5a68ef9df218cb97eecd46597448c2628a9487 100644 (file)
@@ -423,7 +423,7 @@ class BoxReports
                                case 'CATEGORIES':
                                        return stock_categories_list($name, null, _("No Category Filter"));
                                case 'FCATEGORIES':
-                                       return stock_categories_list($name, null, _("No Category Filter"), false, true);
+                                       return stock_categories_list($name, null, _("No Category Filter"), false, 'F');
                                case 'FCLASS':
                                        return fixed_asset_classes_list($name, null, _("No Class Filter"), false);
                                case 'SALESTYPES':
index 06aecf085289e1d0294af0d06d379eb4ff9d91d1..e53d52a35125150b7a0ed6687a04bd748512ee1a 100644 (file)
@@ -110,6 +110,10 @@ function print_sales_orders()
                $result = get_sales_order_details($i, ST_SALESORDER);
                $SubTotal = 0;
                $items = $prices = array();
+               if ($myrow["ship_via"]) {
+                       $items[] = $myrow["ship_via"];
+                       $prices[] = $myrow["freight_cost"];
+               }
                while ($myrow2=db_fetch($result))
                {
                        $Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
@@ -141,6 +145,7 @@ function print_sales_orders()
                        if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight))
                                $rep->NewPage();
                }
+               
                if ($myrow['comments'] != "")
                {
                        $rep->NewLine();
@@ -167,9 +172,7 @@ function print_sales_orders()
                        $rep->TextCol(6, 7,     $DisplayTotal, -2);
                        $rep->NewLine();
                }
-
-               $tax_items = get_tax_for_items(ST_SALESINVOICE, $items, $prices, $myrow["freight_cost"],
-                 $myrow['tax_group_id'], $myrow['tax_included']);
+               $tax_items = get_tax_for_items(ST_SALESINVOICE, $items, $prices, $myrow['tax_group_id'], $myrow['tax_included']);
                $first = true;
                foreach($tax_items as $tax_item)
                {
index a8c779271d0277903a0ccd0955ec15790e2b415b..49096e4a9aa055aba8fa1c021a2faae015616641 100644 (file)
@@ -94,6 +94,10 @@ function print_sales_quotations()
                $result = get_sales_order_details($i, ST_SALESQUOTE);
                $SubTotal = 0;
                $items = $prices = array();
+               if ($myrow["ship_via"]) {
+                       $items[] = $myrow["ship_via"];
+                       $prices[] = $myrow["freight_cost"];
+               }
                while ($myrow2=db_fetch($result))
                {
                        $Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
@@ -165,8 +169,7 @@ function print_sales_quotations()
                        $rep->NewLine();
                }
 
-               $tax_items = get_tax_for_items(ST_SALESORDER, $items, $prices, $myrow["freight_cost"],
-                 $myrow['tax_group_id'], $myrow['tax_included']);
+               $tax_items = get_tax_for_items(ST_SALESORDER, $items, $prices, $myrow['tax_group_id'], $myrow['tax_included']);
                $first = true;
                foreach($tax_items as $tax_item)
                {
index 7e990baea1496f5f9086cc8bda6ad188ee93a7b5..ae76e245633c0c4a9d38c58686fda6a48acb2fd4 100644 (file)
@@ -167,8 +167,7 @@ function print_po()
                $rep->TextCol(6, 7,     $DisplaySubTot, -2);
                $rep->NewLine();
 
-               $tax_items = get_tax_for_items(ST_PURCHORDER, $items, $prices, 0,
-                 $myrow['tax_group_id'], $myrow['tax_included'], TCA_LINES);
+               $tax_items = get_tax_for_items(ST_PURCHORDER, $items, $prices, $myrow['tax_group_id'], $myrow['tax_included'], TCA_LINES);
                $first = true;
                foreach($tax_items as $tax_item)
                {
index 1e29859ea49905f170704b7f19967f9c62c0a4e7..d0895890936e4cb72fa09da451cbd1f6ca0a85e0 100644 (file)
@@ -353,8 +353,8 @@ locations_list_cells(null, 'Location', null, false, true);
 if (!isset($_POST['ship_via'])) {
        $_POST['ship_via'] = $_SESSION['Items']->ship_via;
 }
-label_cell(_("Shipping Company"), "class='tableheader2'");
-shippers_list_cells(null, 'ship_via', $_POST['ship_via']);
+label_cell(_("Shipping Method"), "class='tableheader2'");
+shipping_methods_list_cells(null, 'ship_via', $_POST['ship_via']);
 
 // set this up here cuz it's used to calc qoh
 if (!isset($_POST['DispatchDate']) || !is_date($_POST['DispatchDate'])) {
index e4ab5158322f95ef6fffea1a7f20fdf724a76317..ba0c8a413ffe7618c0311f3713bb6847f1864186 100644 (file)
@@ -467,13 +467,13 @@ start_row();
 if (!isset($_POST['ship_via'])) {
        $_POST['ship_via'] = $_SESSION['Items']->ship_via;
 }
-label_cell(_("Shipping Company"), "class='tableheader2'");
+label_cell(_("Shipping"), "class='tableheader2'");
 if ($prepaid)
 {
-       $shipper = get_shipper($_SESSION['Items']->ship_via);
-       label_cells(null, $shipper['shipper_name']);
+       $shipping = get_item($_SESSION['Items']->ship_via);
+       label_cells(null, $shipping['description']);
 } else
-       shippers_list_cells(null, 'ship_via', $_POST['ship_via']);
+       shipping_methods_list_cells(null, 'ship_via', $_POST['ship_via']);
 
 if (!isset($_POST['InvoiceDate']) || !is_date($_POST['InvoiceDate'])) {
        $_POST['InvoiceDate'] = new_doc_date();
index e1f63d5309fec9920e0df08cf716e0a2c70df1de..660fcc28e59743b29f2987a46fe72050f346e1df 100644 (file)
@@ -284,7 +284,7 @@ class Cart
        // Makes parent documents for direct delivery/invoice by recurent call.
        // $policy - 0 or 1:  writeoff/return for IV, back order/cancel for DN
        function write($policy=0) {
-               
+
                global $SysPrefs, $Refs;
                
                begin_transaction(); // prevents partial database changes in case of direct delivery/invoice
@@ -517,8 +517,12 @@ class Cart
        {
                $items = array();
                $prices = array();
-               if ($shipping_cost == null)
-                       $shipping_cost = $this->freight_cost;
+               if ($this->ship_via != '') {
+                       if ($shipping_cost == null)
+                               $shipping_cost = $this->freight_cost;
+                       $items[] = $this->ship_via;
+                       $prices[] = $shipping_cost;
+               }
 
                foreach ($this->line_items as $ln_itm) {
                        $items[] = $ln_itm->stock_id;
@@ -527,8 +531,7 @@ class Cart
                                $ln_itm->line_price()* (1 - $ln_itm->discount_percent)),  user_price_dec());
                }
 
-               $taxes = get_tax_for_items($this->trans_type, $items, $prices, $shipping_cost,
-                       $this->tax_group_id, $this->tax_included);
+               $taxes = get_tax_for_items($this->trans_type, $items, $prices, $this->tax_group_id, $this->tax_included);
 
     // Adjustment for swiss franken, we always have 5 rappen = 1/20 franken
     if ($this->customer_currency == 'CHF') {
@@ -551,7 +554,7 @@ class Cart
 
        function get_shipping_tax()
        {
-               $freight = split_item_price(NULL, $this->freight_cost, $this->tax_group_id, $this->tax_included, $this->trans_type);
+               $freight = split_item_price($this->ship_via, $this->freight_cost, $this->tax_group_id, $this->tax_included, $this->trans_type);
 
                return $freight['Tax'];
        }
index 888181ebae9b811a4b04c863364e5a488d8879ad..453a3b3f2f1748d5583734bc0269d2c921adbc7c 100644 (file)
@@ -139,8 +139,8 @@ function get_customer_trans($trans_id, $trans_type, $customer_id=null)
        }
 
        if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTCREDIT || $trans_type == ST_CUSTDELIVERY) {
-               // it's an invoice so also get the shipper and salestype
-               $sql .= ", ".TB_PREF."shippers.shipper_name, "
+               // it's an invoice so also get the shipping method and salestype
+               $sql .= ", IFNULL(ship.description, '-') shipping, "
                .TB_PREF."sales_types.sales_type, "
                .TB_PREF."sales_types.tax_included, "
                ."branch.*, "
@@ -155,7 +155,7 @@ function get_customer_trans($trans_id, $trans_type, $customer_id=null)
 
        $sql .= " FROM ".TB_PREF."debtor_trans trans
                                        LEFT JOIN ".TB_PREF."comments com ON trans.type=com.type AND trans.trans_no=com.id
-                                       LEFT JOIN ".TB_PREF."shippers ON ".TB_PREF."shippers.shipper_id=trans.ship_via, 
+                                       LEFT JOIN ".TB_PREF."stock_master ship ON ship.stock_id=trans.ship_via, 
                                        ".TB_PREF."debtors_master cust";
 
        if ($trans_type == ST_CUSTPAYMENT || $trans_type == ST_BANKDEPOSIT) {
@@ -164,7 +164,6 @@ function get_customer_trans($trans_id, $trans_type, $customer_id=null)
        }
 
        if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTCREDIT || $trans_type == ST_CUSTDELIVERY) {
-               // it's an invoice so also get the shipper, salestypes
                $sql .= ", ".TB_PREF."sales_types, "
                .TB_PREF."cust_branch branch, "
                .TB_PREF."tax_groups ";
index 37e0157711bf425f835a233ea8dd2898c9ade65d..998a6a204a2828b35441ad8a2ac488b2ba6f599e 100644 (file)
@@ -138,8 +138,10 @@ function write_credit_note(&$credit_note, $write_off_acc)
                        $credit_note->customer_id);
        }
 
+       $freight = get_item($credit_note->ship_via);
+
        if ($credit_note->freight_cost != 0) {
-               $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $company_data["freight_act"], 0, 0,
+               $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $freight["freight_act"], 0, 0,
                        $credit_note->get_tax_free_shipping(), $credit_note->customer_id);
        }
 
index 1f79aa09db3780410457b0c71af0a167d1172298..862df0a4cbb9439dbb270cff37ad879ddb241ddb 100644 (file)
@@ -158,8 +158,10 @@ function write_sales_invoice(&$invoice)
        }
        $to_allocate = ($items_total + $charge_shipping + $items_added_tax + $freight_added_tax);
 
+       $freight = get_item($invoice->ship_via);
+
        if ($charge_shipping != 0) {
-               $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $company_data["freight_act"], 0, 0,
+               $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $freight["sales_account"], 0, 0,
                        -$invoice->get_tax_free_shipping()*$prepaid_factor, $invoice->customer_id);
        }
        // post all taxes
index 9a8272a0a353d9b65cc93abf2431b80f6dc6bf3d..968777ab8c0360fb4f8c438cc96c4db1bb3c29a7 100644 (file)
@@ -231,7 +231,7 @@ function get_sales_order_header($order_no, $trans_type)
          stype.id AS sales_type_id,
          stype.tax_included,
          stype.factor,
-         ship.shipper_name,
+         ship.description as shipping,
          tax_group.name AS tax_group_name,
          tax_group.id AS tax_group_id,
          cust.tax_id,
@@ -245,7 +245,7 @@ function get_sales_order_header($order_no, $trans_type)
                        LEFT JOIN (SELECT order_, sum(alloc) inv_allocs FROM ".TB_PREF."debtor_trans 
                                WHERE type=".ST_SALESINVOICE." AND order_=".db_escape($order_no)."  GROUP BY order_)
                                 inv ON sorder.trans_type=".ST_SALESORDER." AND inv.order_=sorder.order_no
-                       LEFT JOIN ".TB_PREF."shippers ship ON  ship.shipper_id = sorder.ship_via,"
+                       LEFT JOIN ".TB_PREF."stock_master ship ON ship.stock_id = sorder.ship_via,"
          .TB_PREF."debtors_master cust,"
          .TB_PREF."sales_types stype, "
          .TB_PREF."tax_groups tax_group, "
index 0fd4dfc7c87aef892ea3316ede3fef2d2825e7fc..1a69deee97c3dfeef95208d9ee26b6b72943469e 100644 (file)
@@ -105,7 +105,7 @@ function display_credit_header(&$order)
                $change_prices = 1;
        }
 
-    shippers_list_row(_("Shipping Company:"), 'ShipperID', $order->ship_via);
+    shipping_methods_list_row(_("Shipping:"), 'ShipperID', $order->ship_via);
 
        label_row(_("Customer Discount:"), ($order->default_discount * 100) . "%");
 
index 311bc3f2c43283ec838c29dc2c00e0b7daa29148..d5e5600eaf023884f7cde538460d20cf91fb343b 100644 (file)
@@ -215,9 +215,15 @@ function display_order_summary($title, &$order, $editable_items=false)
        if ($order->trans_no!=0)
                ++$colspan;
        start_row();
-       label_cell(_("Shipping Charge"), "colspan=$colspan align=right");
-       small_amount_cells(null, 'freight_cost', price_format(get_post('freight_cost',0)));
-       label_cell('', 'colspan=2');
+
+       label_cell(_("Shipping method:") . shipping_methods_list('ship_via', null, _("None"), true), "colspan=$colspan align=right");
+
+       if (get_post('ship_via') !== ALL_TEXT) 
+       {
+               small_amount_cells(null, 'freight_cost', price_format(get_post('freight_cost',0)));
+               label_cell('', 'colspan=2');
+       } else
+               label_cell('', 'colspan=3');
        end_row();
        $display_sub_total = price_format($total + input_num('freight_cost'));
        label_row(_("Sub-total"), $display_sub_total, "colspan=$colspan align=right","align=right", 2);
@@ -457,12 +463,22 @@ function display_order_header(&$order, $editable, $date_text)
 
        end_outer_table(1); // outer table
 
+       if (list_updated('ship_via')) {
+               $_SESSION['Items']->ship_via = get_post('ship_via');
+               $_POST['freight_cost'] = price_format(get_price(get_post('ship_via'), $_SESSION['Items']->customer_currency, get_post('sales_type')));
+               $Ajax->activate('items_table');
+       }
+
+
        if ($change_prices != 0) {
                foreach ($order->line_items as $line_no=>$item) {
                        $line = &$order->line_items[$line_no];
                        $line->price = get_kit_price($line->stock_id, $order->customer_currency,
                                $order->sales_type, $order->price_factor, get_post('OrderDate'));
                }
+       }
+       if ($change_prices != 0 || list_updated('ship_via')) {
+               $_POST['freight_cost'] = price_format(get_price(get_post('ship_via'), $_SESSION['Items']->customer_currency, get_post('sales_type')));
            $Ajax->activate('items_table');
        }
 
@@ -640,8 +656,6 @@ function display_delivery_details(&$order)
                  _('Customer reference number for this order (if any)'));
                textarea_row(_("Comments:"), "Comments", $order->Comments, 31, 5);
 
-               shippers_list_row(_("Shipping Company:"), 'ship_via', $order->ship_via);
-
                end_outer_table(1);
        }
        div_end();
index 2e1eae54fca9ef9e2d954d60c1e8c130d591146e..8902135a7280d78ccc24a8366bac6dec91137873 100644 (file)
@@ -234,7 +234,7 @@ function branch_settings($selected_id, $num_branches) {
        sales_areas_list_row( _("Sales Area:"), 'area', null);
        sales_groups_list_row(_("Sales Group:"), 'group_no', null, true);
        locations_list_row(_("Default Inventory Location:"), 'default_location', null);
-       shippers_list_row(_("Default Shipping Company:"), 'default_ship_via', null);
+       shipping_methods_list_row(_("Default Shipping:"), 'default_ship_via', null);
        tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null);
 
        table_section_title(_("GL Accounts"));
index 3810e2b4f2c271a0688ce61d4056c57d9d0a05e0..01d9fe505dbaa6c24df5edd67c32bd627bcbb344 100644 (file)
@@ -294,7 +294,7 @@ function customer_settings($selected_id)
        {
                table_section_title(_("Branch"));
                locations_list_row(_("Default Inventory Location:"), 'location');
-               shippers_list_row(_("Default Shipping Company:"), 'ship_via');
+               shipping_methods_list_row(_("Default Shipping:"), 'ship_via');
                sales_areas_list_row( _("Sales Area:"), 'area', null);
                tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null);
        }
index dad3c63c1e846014e232a26c246676a1dd59a384..77e975d4258566c64c342b88ca9011ce993148c5 100644 (file)
@@ -258,24 +258,25 @@ function copy_to_cart()
 {
        $cart = &$_SESSION['Items'];
 
+
        $cart->reference = $_POST['ref'];
 
        $cart->Comments =  $_POST['Comments'];
 
        $cart->document_date = $_POST['OrderDate'];
 
-       $newpayment = false;
 
+       $newpayment = false;
        if (isset($_POST['payment']) && ($cart->payment != $_POST['payment'])) {
                $cart->payment = $_POST['payment'];
                $cart->payment_terms = get_payment_terms($_POST['payment']);
                $newpayment = true;
        }
        if ($cart->payment_terms['cash_sale']) {
-               if ($newpayment) {
+               if ($newpayment) 
+               {
                        $cart->due_date = $cart->document_date;
                        $cart->phone = $cart->cust_ref = $cart->delivery_address = '';
-                       $cart->ship_via = 0;
                        $cart->deliver_to = '';
                        $cart->prep_amount = 0;
                }
@@ -285,10 +286,11 @@ function copy_to_cart()
                $cart->deliver_to = $_POST['deliver_to'];
                $cart->delivery_address = $_POST['delivery_address'];
                $cart->phone = $_POST['phone'];
-               $cart->ship_via = $_POST['ship_via'];
                if (!$cart->trans_no || ($cart->trans_type == ST_SALESORDER && !$cart->is_started()))
                        $cart->prep_amount = input_num('prep_amount', 0);
        }
+
+       $cart->ship_via = $_POST['ship_via'];
        $cart->Location = $_POST['Location'];
        $cart->freight_cost = input_num('freight_cost');
        if (isset($_POST['email']))
@@ -408,10 +410,7 @@ function can_process() {
                        return false;
                }
 
-               if ($_POST['freight_cost'] == "")
-                       $_POST['freight_cost'] = price_format(0);
-
-               if (!check_num('freight_cost',0)) {
+               if (isset($_POST['freight_cost']) && !check_num('freight_cost',0)) {
                        display_error(_("The shipping cost entered is expected to be numeric."));
                        set_focus('freight_cost');
                        return false;
index a6f709801c4bb5e34d517a612367a540775769b9..7c2442e5f3c024a57d22cdad4289f33e4f9dbcb2 100644 (file)
@@ -71,7 +71,7 @@ label_cells(_("Currency"), $myrow["curr_code"], "class='tableheader2'");
 end_row();
 start_row();
 label_cells(_("Sales Type"), $myrow["sales_type"], "class='tableheader2'");
-label_cells(_("Shipping Company"), $myrow["shipper_name"], "class='tableheader2'");
+label_cells(_("Shipping"), $myrow["shipping"], "class='tableheader2'");
 end_row();
 comments_display_row(ST_CUSTCREDIT, $trans_id);
 end_table();
index 8c1b031332ee13c4c50f6321c65019f8388f6071..69f1534e01067a2c9cf2d3c8b6f136bc92187fd2 100644 (file)
@@ -89,7 +89,7 @@ label_cells(_("Our Order No"),
 end_row();
 start_row();
 label_cells(_("Customer Order Ref."), $sales_order["customer_ref"], "class='tableheader2'");
-label_cells(_("Shipping Company"), $myrow["shipper_name"], "class='tableheader2'");
+label_cells(_("Shipping"), $myrow["shipping"], "class='tableheader2'");
 label_cells(_("Sales Type"), $myrow["sales_type"], "class='tableheader2'");
 end_row();
 start_row();
index f605fc6934084e7bd384a62366dc5d9dad5c4a1e..ead1bd3a4a30193a10c9b012cea682c679406ead 100644 (file)
@@ -89,7 +89,7 @@ label_cells(_("Our Order No"),
 end_row();
 start_row();
 label_cells(_("Customer Order Ref."), $sales_order["customer_ref"], "class='tableheader2'");
-label_cells(_("Shipping Company"), $myrow["shipper_name"], "class='tableheader2'");
+label_cells(_("Shipping"), $myrow["shipping"], "class='tableheader2'");
 label_cells(_("Sales Type"), $myrow["sales_type"], "class='tableheader2'");
 end_row();
 start_row();
index 61a2181b8089e145f456b2452790d02d39b326c3..aab384b7c8c84f9d1bbe7479e8673627371f9ac6 100644 (file)
@@ -90,7 +90,8 @@ label_cells(_("All Payments Allocated"), price_format($_SESSION['View']->sum_pai
 end_row();
 } else
        label_row(_("Payment Terms"), $_SESSION['View']->payment_terms['terms'], "class='tableheader2'", "colspan=3");
-
+$shipping = get_item($_SESSION['View']->ship_via);
+label_row(_("Shipping"), $shipping['description'], "class='tableheader2'", "colspan=3");
 label_row(_("Delivery Address"), nl2br($_SESSION['View']->delivery_address),
        "class='tableheader2'", "colspan=3");
 label_row(_("Reference"), $_SESSION['View']->reference, "class='tableheader2'", "colspan=3");
index f79dde51f9b6f41a01b3b60d5de67c506d6696f1..1d511e14e862e362bb94cbaf64c51a190735411e 100644 (file)
@@ -22,18 +22,51 @@ class fa2_5 extends fa_patch {
                $this->description = _('Upgrade from version 2.4 to 2.5');
        }
 
-       //
-       //      Install procedure. All additional changes 
-       //      not included in sql file should go here.
-       //
+    /*
+           Shows parameters to be selected before upgrade (if any)
+       */
+    function show_params($company)
+       {
+
+               display_note(_('Check upgrade parameters below and start upgrade.'));
+               start_table(TABLESTYLE);
+               table_section(1);
+               table_section_title(_("Shipments category default settings"));
+               text_row(_("Category Name:"), 'shipping_cat_description', _('Shippment'), 30, 30);
+               item_tax_types_list_row(_('Item Tax Type:'), 'shipping_tax_type');
+               stock_units_list_row(_('Unit of measure:'), 'shipping_units');
+               gl_all_accounts_list_row(_("Sales Account:"), 'shipping_sales_act', get_company_pref('freight_act'));
+               gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'shipping_cogs_act', get_company_pref('default_cogs_act'));
+               end_table();
+               br();
+
+    }
+
+    /*
+           Fetch & check upgrade parameters, check additional upgrade pre-conditions, set SQL variables.
+               This function is run after successfull switching to target database connection, before sql upgrade script is run.
+    */
+       function prepare()
+    {
+       // set upgrade script parameters
+       foreach( array('shipping_cat_description', 'shipping_tax_type', 'shipping_units', 'shipping_sales_act', 'shipping_cogs_act') as $name)
+                       db_query("SET @$name=".db_escape(get_post($name)));
+               return true;
+       }
+
+
+       /*
+               Install procedure. All additional changes 
+               not included in sql file should go here.
+       */
        function install($company, $force=false)
        {
                return true;
        }
 
-       //
-       // optional procedure done after upgrade fail, before backup is restored
-       //
+       /*
+               Optional procedure done after upgrade fail, before backup is restored
+       */
        function post_fail($company)
        {
        }
index c92046e05c9ee3daaf5ce9159121a8342b5aa77e..1511ff1123b49565094629456dde9a352aba4aff 100644 (file)
@@ -24,3 +24,38 @@ UPDATE `0_trans_tax_details` tax
  SET tax.tax_group_id = IFNULL(supp.tax_group_id, cust.tax_group_id);
 
 ALTER TABLE `0_tax_groups` ADD COLUMN `tax_area` tinyint(1) NOT NULL DEFAULT '0' AFTER `name`;
+
+# shipment options
+ALTER TABLE `0_stock_master` ADD COLUMN `shipper_id` INT(11) NOT NULL DEFAULT '0' AFTER `vat_category`;
+
+INSERT INTO `0_stock_category` (`description`, `dflt_tax_type`, `dflt_units`, `dflt_mb_flag`, `dflt_sales_act`, `dflt_cogs_act`, `dflt_no_sale`)
+       VALUES (@shipping_cat_description, @shipping_tax_type, @shipping_units, 'T', @shipping_sales_act, @shipping_cogs_act, '1');
+
+SET @shipment_cat=LAST_INSERT_ID();
+
+INSERT INTO `0_stock_master` (`stock_id`, `tax_type_id`, `description`, `units`, `mb_flag`, `sales_account`, `no_sale`, `no_purchase`, `vat_category`, `category_id`, `shipper_id`, `inactive`)
+       SELECT shipper.shipper_name, @shipping_tax_type, shipper.shipper_name, @shipping_units, 'T', @shipping_sales_act, 1, 1, 0, @shipment_cat, shipper.shipper_id, shipper.inactive
+               FROM `0_shippers` shipper;
+
+ALTER TABLE `0_sales_orders` CHANGE COLUMN `ship_via` `ship_via` varchar(20) NOT NULL DEFAULT '';
+
+UPDATE `0_sales_orders` ord
+       LEFT JOIN `0_shippers` ship ON  ord.ship_via=ship.shipper_id
+       LEFT JOIN `0_stock_master` stock ON stock.shipper_id=ship.shipper_id
+       SET ord.ship_via=stock.stock_id;
+
+ALTER TABLE `0_debtor_trans` CHANGE COLUMN `ship_via` `ship_via` varchar(20) NOT NULL DEFAULT '';
+
+UPDATE `0_debtor_trans` trans
+       LEFT JOIN `0_shippers` ship ON  trans.ship_via=ship.shipper_id
+       LEFT JOIN `0_stock_master` stock ON stock.shipper_id=ship.shipper_id
+       SET trans.ship_via=stock.stock_id;
+
+ALTER TABLE `0_cust_branch` CHANGE COLUMN `default_ship_via` `default_ship_via` varchar(20) NOT NULL DEFAULT '';
+
+UPDATE `0_cust_branch` branch
+       LEFT JOIN `0_shippers` ship ON  branch.default_ship_via=ship.shipper_id
+       LEFT JOIN `0_stock_master` stock ON stock.shipper_id=ship.shipper_id
+       SET branch.default_ship_via=stock.stock_id;
+
+ALTER TABLE `0_tax_group_items` DROP COLUMN `tax_shipping`;
index 1d7184cbfef6dad61529af0f29733021cbd99c60..b6cdf6e10d14068f3589a3180e90af520fff24c1 100644 (file)
@@ -561,7 +561,7 @@ CREATE TABLE `0_cust_branch` (
   `sales_discount_account` varchar(15) NOT NULL DEFAULT '',
   `receivables_account` varchar(15) NOT NULL DEFAULT '',
   `payment_discount_account` varchar(15) NOT NULL DEFAULT '',
-  `default_ship_via` int(11) NOT NULL DEFAULT '1',
+  `default_ship_via` varchar(20) NOT NULL DEFAULT '',
   `br_post_address` tinytext NOT NULL,
   `group_no` int(11) NOT NULL DEFAULT '0',
   `notes` tinytext NOT NULL,
@@ -575,8 +575,8 @@ CREATE TABLE `0_cust_branch` (
 -- Data of table `0_cust_branch` --
 
 INSERT INTO `0_cust_branch` VALUES
-('1', '1', 'Donald Easter LLC', 'Donald Easter', 'N/A', '1', '1', 'DEF', '1', '', '4510', '1200', '4500', '1', 'N/A', '0', '', NULL, '0'),
-('2', '2', 'MoneyMaker Ltd.', 'MoneyMaker', '', '1', '1', 'DEF', '2', '', '4510', '1200', '4500', '1', '', '0', '', NULL, '0');
+('1', '1', 'Donald Easter LLC', 'Donald Easter', 'N/A', '1', '1', 'DEF', '1', '', '4510', '1200', '4500', 'post-std', 'N/A', '0', '', NULL, '0'),
+('2', '2', 'MoneyMaker Ltd.', 'MoneyMaker', '', '1', '1', 'DEF', '2', '', '4510', '1200', '4500', 'post-std', '', '0', '', NULL, '0');
 
 -- Structure of table `0_debtor_trans` --
 
@@ -601,7 +601,7 @@ CREATE TABLE `0_debtor_trans` (
   `alloc` double NOT NULL DEFAULT '0',
   `prep_amount` double NOT NULL DEFAULT '0',
   `rate` double NOT NULL DEFAULT '1',
-  `ship_via` int(11) DEFAULT NULL,
+  `ship_via` varchar(20) NOT NULL DEFAULT '',
   `dimension_id` int(11) NOT NULL DEFAULT '0',
   `dimension2_id` int(11) NOT NULL DEFAULT '0',
   `payment_terms` int(11) DEFAULT NULL,
@@ -615,20 +615,20 @@ CREATE TABLE `0_debtor_trans` (
 -- Data of table `0_debtor_trans` --
 
 INSERT INTO `0_debtor_trans` VALUES
-('1', '10', '0', '1', '1', '2018-05-10', '2018-05-05', '001/2018', '1', '1', '6240', '0', '0', '0', '0', '6240', '0', '1', '1', '0', '0', '4', '1'),
-('2', '10', '0', '1', '1', '2018-05-07', '2018-05-07', '002/2018', '1', '2', '300', '0', '0', '0', '0', '300', '0', '1', '1', '0', '0', '4', '1'),
-('3', '10', '0', '2', '2', '2018-05-07', '2018-06-17', '003/2018', '1', '5', '267.14', '0', '0', '0', '0', '0', '0', '1.123', '1', '1', '0', '1', '1'),
-('4', '10', '0', '1', '1', '2018-05-07', '2018-05-07', '004/2018', '1', '7', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '4', '1'),
-('5', '10', '0', '1', '1', '2019-01-21', '2019-01-21', '001/2019', '1', '8', '1250', '0', '0', '0', '0', '1250', '0', '1', '1', '0', '0', '4', '1'),
-('1', '12', '0', '1', '1', '2018-05-10', '0000-00-00', '001/2018', '0', '0', '6240', '0', '0', '0', '0', '6240', '0', '1', '0', '0', '0', NULL, '0'),
-('2', '12', '0', '1', '1', '2018-05-07', '0000-00-00', '002/2018', '0', '0', '300', '0', '0', '0', '0', '300', '0', '1', '0', '0', '0', NULL, '0'),
-('3', '12', '0', '1', '1', '2018-05-07', '0000-00-00', '003/2018', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', NULL, '0'),
-('4', '12', '0', '1', '1', '2019-01-21', '0000-00-00', '001/2019', '0', '0', '1250', '0', '0', '0', '0', '1250', '0', '1', '0', '0', '0', NULL, '0'),
-('1', '13', '1', '1', '1', '2018-05-10', '2018-05-05', 'auto', '1', '1', '6240', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '4', '1'),
-('2', '13', '1', '1', '1', '2018-05-07', '2018-05-07', 'auto', '1', '2', '300', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '4', '1'),
-('3', '13', '1', '2', '2', '2018-05-07', '2018-06-17', 'auto', '1', '5', '267.14', '0', '0', '0', '0', '0', '0', '1.123', '1', '1', '0', '1', '1'),
-('4', '13', '1', '1', '1', '2018-05-07', '2018-05-07', 'auto', '1', '7', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '4', '1'),
-('5', '13', '1', '1', '1', '2019-01-21', '2019-01-21', 'auto', '1', '8', '1250', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '4', '1');
+('1', '10', '0', '1', '1', '2018-05-10', '2018-05-05', '001/2018', '1', '1', '6240', '0', '0', '0', '0', '6240', '0', '1', 'std-post', '0', '0', '4', '1'),
+('2', '10', '0', '1', '1', '2018-05-07', '2018-05-07', '002/2018', '1', '2', '300', '0', '0', '0', '0', '300', '0', '1', 'std-post', '0', '0', '4', '1'),
+('3', '10', '0', '2', '2', '2018-05-07', '2018-06-17', '003/2018', '1', '5', '267.14', '0', '0', '0', '0', '0', '0', '1.123', 'std-post', '1', '0', '1', '1'),
+('4', '10', '0', '1', '1', '2018-05-07', '2018-05-07', '004/2018', '1', '7', '0', '0', '0', '0', '0', '0', '0', '1', 'std-post', '0', '0', '4', '1'),
+('5', '10', '0', '1', '1', '2019-01-21', '2019-01-21', '001/2019', '1', '8', '1250', '0', '0', '0', '0', '1250', '0', '1', 'std-post', '0', '0', '4', '1'),
+('1', '12', '0', '1', '1', '2018-05-10', '0000-00-00', '001/2018', '0', '0', '6240', '0', '0', '0', '0', '6240', '0', '1', '', '0', '0', NULL, '0'),
+('2', '12', '0', '1', '1', '2018-05-07', '0000-00-00', '002/2018', '0', '0', '300', '0', '0', '0', '0', '300', '0', '1', '', '0', '0', NULL, '0'),
+('3', '12', '0', '1', '1', '2018-05-07', '0000-00-00', '003/2018', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '', '0', '0', NULL, '0'),
+('4', '12', '0', '1', '1', '2019-01-21', '0000-00-00', '001/2019', '0', '0', '1250', '0', '0', '0', '0', '1250', '0', '', '0', '0', '0', NULL, '0'),
+('1', '13', '1', '1', '1', '2018-05-10', '2018-05-05', 'auto', '1', '1', '6240', '0', '0', '0', '0', '0', '0', '1', 'std-post', '0', '0', '4', '1'),
+('2', '13', '1', '1', '1', '2018-05-07', '2018-05-07', 'auto', '1', '2', '300', '0', '0', '0', '0', '0', '0', '1', 'std-post', '0', '0', '4', '1'),
+('3', '13', '1', '2', '2', '2018-05-07', '2018-06-17', 'auto', '1', '5', '267.14', '0', '0', '0', '0', '0', '0', '1.123', 'std-post', '1', '0', '1', '1'),
+('4', '13', '1', '1', '1', '2018-05-07', '2018-05-07', 'auto', '1', '7', '0', '0', '0', '0', '0', '0', '0', '1', 'std-post', '0', '0', '4', '1'),
+('5', '13', '1', '1', '1', '2019-01-21', '2019-01-21', 'auto', '1', '8', '1250', '0', '0', '0', '0', '0', '0', '1', 'std-post', '0', '0', '4', '1');
 
 -- Structure of table `0_debtor_trans_details` --
 
@@ -1439,7 +1439,7 @@ CREATE TABLE `0_sales_orders` (
   `comments` tinytext,
   `ord_date` date NOT NULL DEFAULT '0000-00-00',
   `order_type` int(11) NOT NULL DEFAULT '0',
-  `ship_via` int(11) NOT NULL DEFAULT '0',
+  `ship_via` varchar(20) NOT NULL DEFAULT '',
   `delivery_address` tinytext NOT NULL,
   `contact_phone` varchar(30) DEFAULT NULL,
   `contact_email` varchar(100) DEFAULT NULL,
@@ -1457,14 +1457,14 @@ CREATE TABLE `0_sales_orders` (
 -- Data of table `0_sales_orders` --
 
 INSERT INTO `0_sales_orders` VALUES
-('1', '30', '1', '0', '1', '1', 'auto', '', NULL, '2018-05-10', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-05', '4', '6240', '0', '0'),
-('2', '30', '1', '0', '1', '1', 'auto', '', NULL, '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-07', '4', '300', '0', '0'),
-('3', '30', '0', '0', '1', '1', '001/2018', '', NULL, '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-08', '4', '300', '0', '0'),
-('4', '30', '0', '0', '2', '2', '002/2018', '', NULL, '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'MoneyMaker Ltd.', '0', 'DEF', '2018-05-08', '1', '267.14', '0', '0'),
-('5', '30', '1', '0', '2', '2', 'auto', '', NULL, '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'MoneyMaker Ltd.', '0', 'DEF', '2018-06-17', '1', '267.14', '0', '0'),
-('6', '30', '0', '1', '1', '1', '003/2018', '', NULL, '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-08', '4', '450', '0', '0'),
-('7', '30', '1', '0', '1', '1', 'auto', '', 'Recurrent Invoice covers period 04/01/2018 - 04/07/2018.', '2018-05-07', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-07', '4', '0', '0', '0'),
-('8', '30', '1', '0', '1', '1', 'auto', '', NULL, '2019-01-21', '1', '1', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2019-01-21', '4', '1250', '0', '0');
+('1', '30', '1', '0', '1', '1', 'auto', '', NULL, '2018-05-10', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-05', '4', '6240', '0', '0'),
+('2', '30', '1', '0', '1', '1', 'auto', '', NULL, '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-07', '4', '300', '0', '0'),
+('3', '30', '0', '0', '1', '1', '001/2018', '', NULL, '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-08', '4', '300', '0', '0'),
+('4', '30', '0', '0', '2', '2', '002/2018', '', NULL, '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'MoneyMaker Ltd.', '0', 'DEF', '2018-05-08', '1', '267.14', '0', '0'),
+('5', '30', '1', '0', '2', '2', 'auto', '', NULL, '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'MoneyMaker Ltd.', '0', 'DEF', '2018-06-17', '1', '267.14', '0', '0'),
+('6', '30', '0', '1', '1', '1', '003/2018', '', NULL, '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-08', '4', '450', '0', '0'),
+('7', '30', '1', '0', '1', '1', 'auto', '', 'Recurrent Invoice covers period 04/01/2018 - 04/07/2018.', '2018-05-07', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2018-05-07', '4', '0', '0', '0'),
+('8', '30', '1', '0', '1', '1', 'auto', '', NULL, '2019-01-21', '1', 'post-std', 'N/A', NULL, NULL, 'Donald Easter LLC', '0', 'DEF', '2019-01-21', '4', '1250', '0', '0');
 
 -- Structure of table `0_sales_pos` --
 
@@ -1626,7 +1626,8 @@ INSERT INTO `0_stock_category` VALUES
 ('1', 'Components', '1', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
 ('2', 'Charges', '1', 'each', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
 ('3', 'Systems', '1', 'each', 'M', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
-('4', 'Services', '1', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0');
+('4', 'Services', '1', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
+('5', 'Shipping', '1', 'each', 'T', '4430', '5010', '', '', '', '0', '0', '0', '1', '0', '0');
 
 -- Structure of table `0_stock_fa_class` --
 
@@ -1678,18 +1679,20 @@ CREATE TABLE `0_stock_master` (
   `depreciation_date` date NOT NULL DEFAULT '0000-00-00',
   `fa_class_id` varchar(20) NOT NULL DEFAULT '',
   `vat_category` tinyint(1) NOT NULL DEFAULT '0',
+  `shipper_id` int(11) NOT NULL DEFAULT '0',
   PRIMARY KEY (`stock_id`)
 ) ENGINE=InnoDB ;
 
 -- Data of table `0_stock_master` --
 
 INSERT INTO `0_stock_master` VALUES
-('101', '1', '1', 'iPad Air 2 16GB', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '200', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0'),
-('102', '1', '1', 'iPhone 6 64GB', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '150', '150', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0'),
-('103', '1', '1', 'iPhone Cover Case', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '10', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0'),
-('201', '3', '1', 'AP Surf Set', '', 'each', 'M', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '360', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0'),
-('202', '4', '1', 'Maintenance', '', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0'),
-('301', '4', '1', 'Support', '', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0');
+('101', '1', '1', 'iPad Air 2 16GB', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '200', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('102', '1', '1', 'iPhone 6 64GB', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '150', '150', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('103', '1', '1', 'iPhone Cover Case', '', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '10', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('201', '3', '1', 'AP Surf Set', '', 'each', 'M', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '360', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('202', '4', '1', 'Maintenance', '', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('301', '4', '1', 'Support', '', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0'),
+('post-std', '5', '1', 'Standard post package', '', 'each', 'T', '4430', '5010', '', '', '', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0');
 
 -- Structure of table `0_stock_moves` --
 
@@ -1976,14 +1979,13 @@ DROP TABLE IF EXISTS `0_tax_group_items`;
 CREATE TABLE `0_tax_group_items` (
   `tax_group_id` int(11) NOT NULL DEFAULT '0',
   `tax_type_id` int(11) NOT NULL DEFAULT '0',
-  `tax_shipping` tinyint(1) NOT NULL DEFAULT '0',
   PRIMARY KEY (`tax_group_id`,`tax_type_id`)
 ) ENGINE=InnoDB ;
 
 -- Data of table `0_tax_group_items` --
 
 INSERT INTO `0_tax_group_items` VALUES
-('1', '1', '1');
+('1', '1');
 
 -- Structure of table `0_tax_groups` --
 
index 6e2fba329b75bec2c15bbf3736ff3dd3a71afe1f..7cfb0fc915b84299c0cf9c1633c54798b0e50792 100644 (file)
@@ -481,7 +481,7 @@ CREATE TABLE `0_cust_branch` (
   `sales_discount_account` varchar(15) NOT NULL DEFAULT '',
   `receivables_account` varchar(15) NOT NULL DEFAULT '',
   `payment_discount_account` varchar(15) NOT NULL DEFAULT '',
-  `default_ship_via` int(11) NOT NULL DEFAULT '1',
+  `default_ship_via` varchar(20) NOT NULL DEFAULT '',
   `br_post_address` tinytext NOT NULL,
   `group_no` int(11) NOT NULL DEFAULT '0',
   `notes` tinytext NOT NULL,
@@ -517,7 +517,7 @@ CREATE TABLE `0_debtor_trans` (
   `alloc` double NOT NULL DEFAULT '0',
   `prep_amount` double NOT NULL DEFAULT '0',
   `rate` double NOT NULL DEFAULT '1',
-  `ship_via` int(11) DEFAULT NULL,
+  `ship_via`  varchar(20) NOT NULL DEFAULT '',
   `dimension_id` int(11) NOT NULL DEFAULT '0',
   `dimension2_id` int(11) NOT NULL DEFAULT '0',
   `payment_terms` int(11) DEFAULT NULL,
@@ -1162,7 +1162,7 @@ CREATE TABLE `0_sales_orders` (
   `comments` tinytext,
   `ord_date` date NOT NULL DEFAULT '0000-00-00',
   `order_type` int(11) NOT NULL DEFAULT '0',
-  `ship_via` int(11) NOT NULL DEFAULT '0',
+  `ship_via` varchar(20) NOT NULL DEFAULT '',
   `delivery_address` tinytext NOT NULL,
   `contact_phone` varchar(30) DEFAULT NULL,
   `contact_email` varchar(100) DEFAULT NULL,
@@ -1338,7 +1338,8 @@ INSERT INTO `0_stock_category` VALUES
 ('1', 'Components', '1', 'each', 'B', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
 ('2', 'Charges', '1', 'each', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
 ('3', 'Systems', '1', 'each', 'M', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
-('4', 'Services', '1', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0');
+('4', 'Services', '1', 'hr', 'D', '4010', '5010', '1510', '5040', '1530', '0', '0', '0', '0', '0', '0'),
+('5', 'Shipping', '1', 'each', 'T', '4430', '5010', '', '', '', '0', '0', '0', '1', '0', '0');
 
 -- Structure of table `0_stock_fa_class` --
 
@@ -1390,11 +1391,13 @@ CREATE TABLE `0_stock_master` (
   `depreciation_date` date NOT NULL DEFAULT '0000-00-00',
   `fa_class_id` varchar(20) NOT NULL DEFAULT '',
   `vat_category` tinyint(1) NOT NULL DEFAULT '0',
+  `shipper_id` int(11) NOT NULL DEFAULT '0',
   PRIMARY KEY (`stock_id`)
 ) ENGINE=InnoDB;
 
 -- Data of table `0_stock_master` --
-
+INSERT INTO `0_stock_master` VALUES
+('post-std', '5', '1', 'Standard post package', '', 'each', 'T', '4430', '5010', '', '', '', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'S', '0', '1', '0000-00-00', '0000-00-00', '', '0', '0');
 -- Structure of table `0_stock_moves` --
 
 DROP TABLE IF EXISTS `0_stock_moves`;
@@ -1649,14 +1652,13 @@ DROP TABLE IF EXISTS `0_tax_group_items`;
 CREATE TABLE `0_tax_group_items` (
   `tax_group_id` int(11) NOT NULL DEFAULT '0',
   `tax_type_id` int(11) NOT NULL DEFAULT '0',
-  `tax_shipping` tinyint(1) NOT NULL DEFAULT '0',
   PRIMARY KEY (`tax_group_id`,`tax_type_id`)
 ) ENGINE=InnoDB ;
 
 -- Data of table `0_tax_group_items` --
 
 INSERT INTO `0_tax_group_items` VALUES
-('1', '1', '1');
+('1', '1');
 
 -- Structure of table `0_tax_groups` --
 
index 5e152855cbaf5cb419f7be3a40cbf17c79b33dcb..ef91b3ea4f7cc5fdf8134a15d3afa764387fe417 100644 (file)
@@ -9,7 +9,7 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-function add_tax_group($name, $taxes, $tax_shippings, $tax_area)
+function add_tax_group($name, $taxes, $tax_area)
 {
        begin_transaction();
 
@@ -18,12 +18,12 @@ function add_tax_group($name, $taxes, $tax_shippings, $tax_area)
        
        $id = db_insert_id();
        
-       add_tax_group_items($id, $taxes, $tax_shippings);
+       add_tax_group_items($id, $taxes);
        
        commit_transaction();   
 }
 
-function update_tax_group($id, $name, $taxes, $tax_shippings, $tax_area)
+function update_tax_group($id, $name, $taxes, $tax_area)
 {
        begin_transaction();    
 
@@ -31,9 +31,9 @@ function update_tax_group($id, $name, $taxes, $tax_shippings, $tax_area)
        db_query($sql, "could not update tax group");
        
        delete_tax_group_items($id);
-       add_tax_group_items($id, $taxes, $tax_shippings);       
+       add_tax_group_items($id, $taxes);
        
-       commit_transaction();                   
+       commit_transaction();
 }
 
 function get_all_tax_groups($all=false)
@@ -66,13 +66,13 @@ function delete_tax_group($id)
        commit_transaction();
 }
 
-function add_tax_group_items($id, $items, $tax_shippings)
+function add_tax_group_items($id, $items)
 {
        for ($i=0; $i < count($items); $i++) 
        {
-               $sql = "INSERT INTO ".TB_PREF."tax_group_items (tax_group_id, tax_type_id, tax_shipping)
-                       VALUES (".db_escape($id).",  ".db_escape($items[$i]).", " . $tax_shippings[$i] .")";
-               db_query($sql, "could not add item tax group item");                                    
+               $sql = "INSERT INTO ".TB_PREF."tax_group_items (tax_group_id, tax_type_id)
+                       VALUES (".db_escape($id).",  ".db_escape($items[$i]).")";
+               db_query($sql, "could not add item tax group item");
        }               
 }
 
@@ -80,14 +80,13 @@ function delete_tax_group_items($id)
 {
        $sql = "DELETE FROM ".TB_PREF."tax_group_items WHERE tax_group_id=".db_escape($id);
        
-       db_query($sql, "could not delete item tax group items");                                        
+       db_query($sql, "could not delete item tax group items");
 }
 
 //
 //     Return all tax types with rate value updated according to tax group selected
-//     Call the function without arg to find shipment group taxes.
 //
-function get_tax_group_rates($group_id=null, $tax_shipping=false)
+function get_tax_group_rates($group_id)
 {
        global $SysPrefs;
 
@@ -97,14 +96,10 @@ function get_tax_group_rates($group_id=null, $tax_shipping=false)
                        : "CONCAT(t.name, ' (', t.rate, '%)') as tax_type_name,")
                ."t.sales_gl_code,
                  t.purchasing_gl_code,
-                 IF(g.tax_type_id, t.rate, NULL) as rate,
-                 g.tax_shipping
+                 IF(g.tax_type_id, t.rate, NULL) as rate
                FROM ".TB_PREF."tax_types t 
                  LEFT JOIN ".TB_PREF."tax_group_items g ON t.id=g.tax_type_id
-       AND g.tax_group_id=". ($group_id ? db_escape($group_id) : "(SELECT MIN(id) FROM ".TB_PREF."tax_groups)")                  
-       . " WHERE !t.inactive";
-       if ($tax_shipping)
-               $sql .= " AND g.tax_shipping=1";
+       AND g.tax_group_id=".db_escape($group_id). " WHERE !t.inactive";
 
        return db_query($sql, "cannot get tax types as array");
 }
@@ -143,7 +138,7 @@ function find_domestic_tax_group()
                (SELECT g.id, count(*) cnt 
                        FROM ".TB_PREF."tax_group_items i
                        LEFT JOIN ".TB_PREF."tax_groups g ON g.id=i.tax_group_id
-               WHERE tax_shipping=0 AND tax_area=0 AND !inactive
+               WHERE tax_area=0 AND !inactive
                GROUP BY g.id) cnts
                ORDER by cnt DESC";
        $result = db_query($sql, "cannot get domestic group id");
@@ -151,17 +146,3 @@ function find_domestic_tax_group()
        return $group['id'];
 }
 
-function get_shipping_tax_as_array($id=null)
-{
-       $ret_tax_array = array();
-
-       $tax_group_items = get_tax_group_rates($id, true);
-
-       while ($tax_group_item = db_fetch($tax_group_items)) 
-       {
-               $tax_group_item['Value'] = 0;
-               $ret_tax_array[$tax_group_item['tax_type_id']] = $tax_group_item;
-       }
-       
-       return $ret_tax_array;
-}
index 004fcd33fcb49ae2bc64a497bd21692b5969b760..4b36dc07a641494ed9baada5f3632bec932dbe50 100644 (file)
@@ -33,13 +33,6 @@ function get_base_taxdata($stock_id, $group_id)
 
        $taxdata = array('tax_area' => $group_data['tax_area'], 'taxes' => null);
 
-       if ($stock_id===null) // shipping special case
-       {
-               $taxdata['vat_category'] = VC_SERVICES;
-               $taxdata['taxes'] = get_tax_group_items_as_array(null);
-               return $taxdata;
-       }
-
        $item_tax_type = get_item_tax_type_for_item($stock_id); // get item tax data
        $taxdata['vat_category'] = $item_tax_type['vat_category'];
 
@@ -91,7 +84,6 @@ function get_base_taxdata($stock_id, $group_id)
 
 /*
        Main tax procedure splitting transaction item value according to item tax rules applicable:
-               $stock_id - stock item code; NULL for shipping
                $amount - price/value to be splitted
                $tax_group - entity tax group
                $tax_included - whether value includes all taxes
@@ -223,19 +215,10 @@ function split_item_price($stock_id, $amount, $group_id, $tax_included=false, $t
 //
 // $vat_factors - effective part of vat values included in tax; calculated but not included vat is added to net value
 //
-function get_tax_for_items($trans_type, $items, $prices, $shipping_cost, $tax_group, $tax_included=null,
+function get_tax_for_items($trans_type, $items, $prices, $tax_group, $tax_included=null,
        $tax_algorithm = null, $vat_factors = null, $allow_reverse = true)
 {
 
-       // if shipping cost is passed, just add to the prices/items tables
-       if ($shipping_cost != 0)
-       {
-               $items[] = NULL;
-               $prices[] = $shipping_cost;
-               if ($vat_factors)
-                       $vat_factors[] = 1;
-       }
-
        // calculate tax sums
        $ret_tax_array = array();
        foreach($items as $i => $stock_id)
index 451c344aaecc4894ab4917fe57d0a598560ffea1..00ad23bd15dba5a287496136293955ab9d316aa7 100644 (file)
@@ -45,26 +45,23 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
 
                // create an array of the taxes and array of rates
        $taxes = array();
-       $tax_shippings = array();
 
                while (($id = find_submit('tax_type_id'))!=-1)
                {
                        if (check_value('tax_type_id'.$id) != 0)
                        {
                                $taxes[] = $id;
-                               $tax_shippings[] = check_value('tax_shipping'.$id);
                        }       
                        unset($_POST['tax_type_id' . $id]);
-                       unset($_POST['tax_shipping' . $id]);
                }
        if ($selected_id != -1) 
        {
-                       update_tax_group($selected_id, $_POST['name'], $taxes, $tax_shippings, get_post('tax_area'));
+                       update_tax_group($selected_id, $_POST['name'], $taxes, get_post('tax_area'));
                        display_notification(_('Selected tax group has been updated'));
        } 
        else 
        {
-                       add_tax_group($_POST['name'], $taxes, $tax_shippings, get_post('tax_area'));
+                       add_tax_group($_POST['name'], $taxes, get_post('tax_area'));
                        display_notification(_('New tax group has been added'));
        }
 
@@ -174,7 +171,7 @@ display_note(_("Select the taxes that are included in this group."), 1, 1);
 $items = get_tax_group_rates($selected_id!=-1 ? $selected_id : null);
 
 start_table(TABLESTYLE2);
-$th = array(_("Tax"), "", _("Shipping Tax"));
+$th = array(_("Tax"), "");
 table_header($th);
 
 while($item = db_fetch($items)) 
@@ -184,8 +181,6 @@ while($item = db_fetch($items))
        {
                check_cells($item['tax_type_name'], 'tax_type_id' . $item['tax_type_id'], 
                        isset($item['rate']), true, false, "align='center'");
-               if (isset($item['rate']))
-                       check_cells(null, 'tax_shipping' . $item['tax_type_id'], $item['tax_shipping']);
        }
        else
        {
@@ -196,8 +191,6 @@ while($item = db_fetch($items))
                        //$_POST['_tax_type_id' . $item['tax_type_id'].'_update'] = 0;
                        $Ajax->activate('_page_body');
                }
-               if (check_value('tax_type_id' . $item['tax_type_id'])==1)
-                       check_cells(null, 'tax_shipping' . $item['tax_type_id'], null);
        }               
        end_row();