VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: srsolutions on September 23, 2016, 14:50:54 PM

Title: Unit price incl. VAT on invoice
Post by: srsolutions on September 23, 2016, 14:50:54 PM
Hello everyone,

Is there a way to get the unit price including VAT on the invoices (now it is excluding VAT, quantity, VAT amount (vat x qtt)  and total amount (qtt x unit + vat)

I think this must be an option somewhere in the settings, but I just can't seem to find it  :o

Thank you so much for your input on this.

Steven

Virtuemart version: 3.0.16
Joomla version: 3.6.2
Title: Re: Unit price incl. VAT on invoice
Post by: GJC Web Design on September 23, 2016, 14:52:53 PM
You need to alter the template

over ride the components\com_virtuemart\views\invoice\tmpl\invoice_items.php
Title: Re: Unit price incl. VAT on invoice
Post by: srsolutions on September 23, 2016, 15:00:03 PM
Ok,

What exactly do I need to override? I tried changing line 118 to 126. But I think these are not the correct lines. I am not sure what to change.

<?php
$item->product_basePriceWithTax = (float) $item->product_basePriceWithTax;
if (!empty($item->product_priceWithTax) && $item->product_basePriceWithTax != $item->product_priceWithTax) {
echo '<span class="line-through">'.$this->currency->priceDisplay($item->product_item_price$this->currency) .'</span><br />';
echo '<span >'.$this->currency->priceDisplay($item->product_basePriceWithTax$this->currency) .'</span><br />';
} else {
echo '<span >'.$this->currency->priceDisplay($item->product_item_price$this->currency) .'</span><br />';
}
?>



If you can point me in the right direction I should be able to manage.

Thank you !
Title: Re: Unit price incl. VAT on invoice
Post by: GJC Web Design on September 23, 2016, 22:32:22 PM
you have to see what prices are available in the $item object

if b4 tax isn't there u will need to calc the amount

print 'Debug Line '.__LINE__.' $item <pre>'; print_r ($item); print "</pre><br />\n";
Title: Re: Unit price incl. VAT on invoice
Post by: srsolutions on September 24, 2016, 12:08:33 PM
b4 tax, tax amount and incl. tax are all filled in on every product and calculated by virtuemart.

In the webshop itself it is all ok, only on the invoices it states the amount excl. tax where we want to have the unit price incl. tax

Debug Line 120 $item

stdClass Object
(
    [virtuemart_order_item_id] => 68
    [product_quantity] => 1
    [order_item_name] => Bâton Starlet
    [order_item_sku] => t11stbat
    [virtuemart_product_id] => 18
    [product_item_price] => 23.92562
    [product_final_price] => 28.95000
    [product_basePriceWithTax] => 28.95
    [product_discountedPriceWithoutTax] => 23.92562
    [product_priceWithoutTax] => 23.92562
    [product_subtotal_with_tax] => 28.95000
    [product_subtotal_discount] => 0.00000
    [product_tax] => 5.02438
    [product_attribute] => {
    "7": "99"
}
    [order_status] => P
    [product_available_date] => 2009-12-28 00:00:00
    [product_availability] =>
    [intnotes] =>
    [virtuemart_category_id] => 153
    [product_mpn] =>
    [virtuemart_manufacturer_id] => Array
        (
            [0] => 6
        )

    [mf_name] => Star Line Baton Cie - USA
    [slug] => starlet-baton-3-8-inch-9-mm
    [mf_email] =>
    [mf_desc] =>
    [virtuemart_manufacturercategories_id] => 0
    [mf_url] =>
    [published] => 1
    [created_on] => 2009-12-29 18:22:34
    [created_by] => 0
    [modified_on] => 2016-07-22 06:44:48
    [modified_by] => 215
    [virtuemart_vendor_id] => 1
    [product_parent_id] => 0
    [product_sku] => t11stbat
    [product_gtin] =>
    [product_name] => Bâton Starlet
    [product_s_desc] =>  3/8 inch - 9 mm
    [product_desc] =>

Le modèle le plus populaire parmi les élèves. Il a un diamètre de 3/8 inch (9 mm). Beaucoup d'entraîneurs préfèrent ce bâton pour les novices. Pas de froufrous. Justement un bon bâton.

Disponible dans les tailles suivantes:





TAILLES DISPONIBLES


USA inch
16"
18"
20"
22"
24"
26"
28"
30"
32"


EUR cm
40
45
50
55
60
65
70
75
80






    [product_weight] => 0.0000
    [product_weight_uom] => KG
    [product_length] => 0.0000
    [product_width] => 0.0000
    [product_height] => 0.0000
    [product_lwh_uom] => M
    [product_url] =>
    [product_in_stock] => 100
    [product_ordered] => 42
    [low_stock_notification] => 10
    [product_special] => 1
    [pordering] => 0
    [product_sales] => 0
    [product_unit] => KG
    [product_packaging] => 0.0000
    [product_params] => min_order_level=""|max_order_level=""|step_order_level=""|product_box=""|
    [customtitle] =>
    [metadesc] =>
    [metakey] =>
    [metarobot] =>
    [metaauthor] =>
    [layout] => 0
    [allIds] => Array
        (
            [0] => 18
        )

    [virtuemart_media_id] => Array
        (
            [0] => 36
        )

    [shoppergroups] =>
    [allPrices] => Array
        (
            [0] => Array
                (
                    [virtuemart_product_price_id] => 16
                    [virtuemart_product_id] => 18
                    [virtuemart_shoppergroup_id] => 0
                    [product_price] => 23.925620
                    [override] => 0
                    [product_override_price] => 0.00000
                    [product_tax_id] => 0
                    [product_discount_id] => 0
                    [product_currency] => 47
                    [product_price_publish_up] => 0000-00-00 00:00:00
                    [product_price_publish_down] => 0000-00-00 00:00:00
                    [price_quantity_start] => 0
                    [price_quantity_end] => 0
                    [created_on] => 2016-06-25 09:04:19
                    [created_by] => 215
                    [modified_on] => 2016-07-22 06:44:48
                    [modified_by] => 215
                    [locked_on] => 0000-00-00 00:00:00
                    [locked_by] => 0
                    [costPrice] => 23.92562
                    [basePrice] => 23.92562
                    [basePriceVariant] => 23.92562
                    [basePriceWithTax] => 28.95
                    [discountedPriceWithoutTax] => 23.92562
                    [priceBeforeTax] => 23.92562
                    [salesPrice] => 28.95
                    [taxAmount] => 5.02438
                    [salesPriceWithDiscount] => 0
                    [salesPriceTemp] => 28.95
                    [unitPrice] => 0
                    [discountAmount] => 0
                    [priceWithoutTax] => 23.92562
                    [variantModification] => 0
                    [DBTax] => Array
                        (
                        )

                    [Tax] => Array
                        (
                            [3] => Array
                                (
                                    [0] => Tax 21%
                                    [1] => 21.0000
                                    [2] => +%
                                    [3] => 0
                                    [4] => 47
                                    [5] =>
                                    [6] => 1
                                    [7] => 3
                                )

                        )

                    [VatTax] => Array
                        (
                        )

                    [DATax] => Array
                        (
                        )

                    [Marge] => Array
                        (
                        )

                )

        )

    [selectedPrice] => 0
    [categoryItem] => Array
        (
            [0] => Array
                (
                    [virtuemart_category_id] => 153
                    [virtuemart_vendor_id] => 1
                    [category_name] => Bâtons Traditionnels
                    [slug] => bâtons
                    [category_description] =>
                    [category_template] => 0
                    [category_layout] => 0
                    [category_product_layout] => 0
                    [products_per_row] => 0
                    [ordering] => 7
                    [shared] => 0
                    [limit_list_step] => 0
                    [limit_list_initial] => 0
                    [metadesc] =>
                    [customtitle] =>
                    [metakey] =>
                    [metarobot] =>
                    [metaauthor] =>
                    [published] => 1
                    [VmTable_lhash] => e51c416f0d79593869fd0a45b69f2835
                    [*_tbl] => #__virtuemart_categories
                    [*_tbl_lang] => #__virtuemart_categories_fr_fr
                    [*_tbl_key] => virtuemart_category_id
                    [*_tbl_keys] => Array
                        (
                            [0] => virtuemart_category_id
                        )

                    [*_pkey] => virtuemart_category_id
                    [*_pkeyForm] => cid
                    [*_obkeys] => Array
                        (
                            [category_name] => 1
                            [slug] => 1
                        )

                    [*_unique] => 1
                    [*_unique_name] => Array
                        (
                            [slug] => 1
                        )

                    [*_orderingKey] => ordering
                    [*_slugAutoName] => category_name
                    [*_slugName] => slug
                    [*_db] => JDatabaseDriverMysqli Object
                        (
                            [name] => mysqli
                            [serverType] => mysql
                            [connection:protected] => mysqli Object
                                (
                                    [affected_rows] => 16
                                    [client_info] => mysqlnd 5.0.11-dev - 20120503 - $Id: 15d5c781cfcad91193dceae1d2cdd127674ddb3e $
                                    [client_version] => 50011
                                    [connect_errno] => 0
                                    [connect_error] =>
                                    [errno] => 0
                                    [error] =>
                                    [error_list] => Array
                                        (
                                        )

                                    [field_count] => 24
                                    [host_info] => Localhost via UNIX socket
                                    [info] =>
                                    [insert_id] => 0
                                    [server_info] => 5.5.41
                                    [server_version] => 50541
                                    [stat] => Uptime: 308914  Threads: 1  Questions: 2048638  Slow queries: 0  Opens: 74571  Flush tables: 1  Open tables: 400  Queries per second avg: 6.631
                                    [sqlstate] => 00000
                                    [protocol_version] => 10
                                    [thread_id] => 33603
                                    [warning_count] => 0
                                )

                            [nameQuote:protected] => `
                            [nullDate:protected] => 0000-00-00 00:00:00
                            [_database:JDatabaseDriver:private] => comalors_f5qKd
                            [count:protected] => 159
                            [cursor:protected] =>
                            [debug:protected] =>
                            [limit:protected] => 0
                            [log:protected] => Array
                                (
                                )

                            [timings:protected] => Array
                                (
                                )

                            [callStacks:protected] => Array
                                (
                                )

                            [offset:protected] => 0
                            [options:protected] => Array
                                (
                                    [driver] => mysqli
                                    [host] => localhost
                                    [user] => comalors_d9ea3
                                    [password] => AeKvKQ88
                                    [database] => comalors_f5qKd
                                    [prefix] => g9gbf_
                                    [select] => 1
                                    [port] => 3306
                                    [socket] =>
                                )

                            [sql:protected] => SELECT * FROM `#__menu` WHERE `component_id` = "10021" and `language` = "*"
                            [tablePrefix:protected] => g9gbf_
                            [utf:protected] => 1
                            [utf8mb4:protected] => 1
                            [errorNum:protected] => 0
                            [errorMsg:protected] =>
                            [transactionDepth:protected] => 0
                            [disconnectHandlers:protected] => Array
                                (
                                )

                        )

                    [*_rules] =>
                    [*_trackAssets] =>
                    [*_locked] =>
                    [*_loggable] => 1
                    [_xParams] => 0
                    [_varsToPushParam] => Array
                        (
                        )

                    [_translatable] => 1
                    [*_translatableFields] => Array
                        (
                            [0] => category_name
                            [1] => category_description
                            [2] => metadesc
                            [3] => metakey
                            [4] => customtitle
                            [slug] => slug
                        )

                    [_cryptedFields] =>
                    [*_langTag] => fr_fr
                    [_ltmp] =>
                    [_loaded] => 1
                    [*_updateNulls] =>
                    [_tablePreFix] => c.
                    [_autoincrement] => 1
                    [_observers] => JObserverUpdater Object
                        (
                            [observers:protected] => Array
                                (
                                )

                            [doCallObservers:protected] => 1
                        )

                    [created_on] => 2016-06-01 23:59:15
                    [created_by] => 214
                    [modified_on] => 2016-06-24 12:09:24
                    [modified_by] => 215
                    [id] => 666
                )

        )

    [canonCatId] => 153
    [categories] => Array
        (
            [0] => 153
        )

    [ordering] => 7
    [id] => 666
    [category_name] => Bâtons Traditionnels
    [orderable] => 1
    [modificatorSum] => 0
    [customfields] => Array
        (
            [0] => stdClass Object
                (
                    [virtuemart_custom_id] => 7
                    [custom_parent_id] => 0
                    [virtuemart_vendor_id] => 1
                    [custom_jplugin_id] => 0
                    [custom_element] => 0
                    [admin_only] => 0
                    [custom_title] => Taille
                    [show_title] => 1
                    [custom_tip] =>
                    [custom_value] =>
                    [custom_desc] => *choisissez votre taille
                    [field_type] => S
                    [is_list] => 0
                    [is_hidden] => 0
                    [is_cart_attribute] => 1
                    [is_input] => 1
                    [layout_pos] => addtocart
                    [custom_params] => addEmpty="0"|selectType="0"|
                    [shared] => 0
                    [published] => 1
                    [ordering] => 6
                    [virtuemart_customfield_id] => 99
                    [virtuemart_product_id] => 18
                    [customfield_value] => 28 inch / 70 cm
                    [customfield_price] =>
                    [customfield_params] => addEmpty=0|selectType=0|
                    [fpublished] => 0
                    [override] => 0
                    [disabler] => 0
                    [_varsToPushParamCustom] => Array
                        (
                            [addEmpty] => Array
                                (
                                    [0] => 0
                                    [1] => int
                                )

                            [selectType] => Array
                                (
                                    [0] => 0
                                    [1] => int
                                )

                        )

                    [_varsToPushParamCustomField] => Array
                        (
                            [addEmpty] => Array
                                (
                                    [0] => 0
                                    [1] => int
                                )

                            [selectType] => Array
                                (
                                    [0] => 0
                                    [1] => int
                                )

                        )

                    [_varsToPushParam] => Array
                        (
                            [addEmpty] => Array
                                (
                                    [0] => 0
                                    [1] => int
                                )

                            [selectType] => Array
                                (
                                    [0] => 0
                                    [1] => int
                                )

                        )

                    [addEmpty] => 0
                    [selectType] => 0
                    [_xParams] => customfield_params
                )

        )

    [product_tax_id] => 0
    [amount] => 1
    [quantity] => 1
    [prices] => Array
        (
            [virtuemart_product_price_id] => 16
            [virtuemart_product_id] => 18
            [virtuemart_shoppergroup_id] => 0
            [product_price] => 23.925620
            [override] => 0
            [product_override_price] => 0.00000
            [product_tax_id] => 0
            [product_discount_id] => 0
            [product_currency] => 47
            [product_price_publish_up] => 0000-00-00 00:00:00
            [product_price_publish_down] => 0000-00-00 00:00:00
            [price_quantity_start] => 0
            [price_quantity_end] => 0
            [created_on] => 2016-06-25 09:04:19
            [created_by] => 215
            [modified_on] => 2016-07-22 06:44:48
            [modified_by] => 215
            [locked_on] => 0000-00-00 00:00:00
            [locked_by] => 0
            [costPrice] => 23.92562
            [basePrice] => 23.92562
            [basePriceVariant] => 23.92562
            [basePriceWithTax] => 28.95
            [discountedPriceWithoutTax] => 23.92562
            [priceBeforeTax] => 23.92562
            [salesPrice] => 28.95
            [taxAmount] => 5.02438
            [salesPriceWithDiscount] => 0
            [salesPriceTemp] => 28.95
            [unitPrice] => 0
            [discountAmount] => 0
            [priceWithoutTax] => 23.92562
            [variantModification] => 0
            [DBTax] => Array
                (
                )

            [Tax] => Array
                (
                    [3] => Array
                        (
                            [0] => Tax 21%
                            [1] => 21.0000
                            [2] => +%
                            [3] => 0
                            [4] => 47
                            [5] =>
                            [6] => 1
                            [7] => 3
                        )

                )

            [VatTax] => Array
                (
                )

            [DATax] => Array
                (
                )

            [Marge] => Array
                (
                )

        )

    [product_template] =>
    [canonical] => index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=18&virtuemart_category_id=153
    [link] => index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=18&virtuemart_category_id=153
    [addToCartButton] =>
    [customProductData] => Array
        (
            [7] => 99
        )

)


23,93 €
Title: Re: Unit price incl. VAT on invoice
Post by: srsolutions on September 24, 2016, 12:58:44 PM
Problem solved, Seems I have overlooked rule 124  ::)

Changed all to product_basePriceWithTax except in rule 124....

this:
echo '<span >'.$this->currency->priceDisplay($item->product_item_price, $this->currency) .'</span><br />';

should be
echo '<span >'.$this->currency->priceDisplay($item->product_basePriceWithTax, $this->currency) .'</span><br />';