Tax Rounding on invoices


#1

Hi there,

I was wondering if its possible to round up or down the tax calculation.

Like when the price is: 231.40 it will output 279.99 (21%) in these cases i like it to round up.

Or just calculate backward from the final price as in price is 280 then just calculate the included tax.

Any of this possible ?


#2

Of course it is possible. The issue here is if there is widespread need for such a feature.

In the example you provided, it will make sense if the currency if calculated to (say) 3 decimal points and you are rounding to two. Otherwise adjusting cents upwards or downwards might have legal and financial implications.

For example, in my country, charging VAT means you are collecting taxes on behalf of the state. This is calculated on total turnover for a month. If I issue (say) a thousand invoices where I have rounded, I run the risk of misstating my VAT returns to the state, which carries penalties.

The one place where I see the rounding happen is at cash point of sale, where the bill is rounded to the lowest 10 cents. This because 1 cent, 2 cent, and 5 cent coins have been taken out of circulation.

You can change the code to calculate the values like
$adjusted_invoice_amount = ceil( $invoice_amount / 100 ) * 100;


#3

Awesome for time saving purpose where do i find that pard of the code ?.

Ps. you are right rounding is indeed forbidden i checked the tax office so i will have to discuss this with the big boss.

Also some additional questions if i may my employer likes it so where going to permanently use it.

  1. The maintainer is stopping is this the end of the project i saw quite a list of people going to continue but since the question is still there i assumed there is yet to be a permanent maintainer ?
  2. overrides i have edited the invoice templates directly and wil change that code as suggested above I can’t find a override if so what is the naming convention? is it there or should care be taken when updating.
    3.I like to change the invoice product template since we do not really use products i like to just make a fixed set of fields there or change the product layout. What would be the recommended way to do this.
  3. is there a coding convention manual for the project to see how things are bulld up for newbie at programming is can’t do without it :frowning:

Thanks for the quick response and as always providing software for the small people !


#4

There might be a number of different places you may want to do this. It is left up to you to figure out where, I can however, give you a starting point.

Invoiceplane, and Codeignitor generally follows the MVC (Model-Controller-View) design pattern, so in general

  • A request from a View is handled by a Controller
  • The controller processes the request, then calls upon the Model to perform the business processes.
  • The Model passes control back to the Controller, who send the output to the View

So, say you want to save the values on the database
=> for invoices, you would look in application/modules/invoices/models/Mdl_invoices.php
=> for quotes, you would look in application/modules/quotes/models/Mdl_quotes.php
Get the picture?

So, in the case of invoices, in the model you would find a function to create a new invoice,

   public function create($db_array = null, $include_invoice_tax_rates = true)
    {
         ....
    }

You can either change the values in the Model, or find each place that calls that function (for example in a controller), and change it before calling the function. It is no
t so straighforward, however. Remember that you have to display the value correctly in the invoice before saving it - you cannot show one value and save another. You would therefore want to adjust the rounding when adding a new item on the invoice and calculating the rounded up values.


#5

The project is as strong as ever. I use this for my business and have no issues with it’s future.

Refer to my response above

As a starting point, Look at the code in

  • application/modules/families/
  • application/modules/products/

#6

Awesome thanks for all the info.

Was wondering one last thing the invoice makes the field out of user_%variable% is there currently a set place for set variable for company info. or do i need to make a new array and setup these and then call them in the pdf.


#7

The value comes from the models. For example, if you see in the invoice code
<?php echo $invoice->user_name; ?> <?php echo $invoice->invoice_date_created; ?>
then look in the Mdl_invoice.php file.

Some fields are straightforward because you know they come from the ip_invoices table, for example $invoice->invoice_date_created. Some will come from joined tables, for example $invoice->user_name, which are done in the model code as well You will have to study the model code to see how the joined tables are integrated into the model.

You are welcome to add to the model, which then makes the variable accessible to the view code.


#8

Fair enough i acctualy got that far who who i getting the hang of this ! :slight_smile:

I was wondering if it was already there before adding the custom variable and making a form connected to in in the admin area for general company info.

I am correct in understanding there is only a company fields based on users.? (why btw ?)