Jump to content
  • 0

Cost Field In Invoice Calculation


dubjuice

Question

In the detault template for invoices it seems to include the tax on each line item in the invoice in the field called cost.  This seems confusing, it shouldn't show the total including tax.  How can i change this?

 

Right now it shows:

description | qty I unit price I cost = qty * unit price * tax

subtotal shows total without tax,

tax line

total line with tax

 

it should be:

description | qty I unit price I cost = qty * unit price

subtotal = total without tax,

tax = total taxes

total = subtotal +tax

 

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

If you update Blesta, then yes, the change you made would be overridden. You would have to maintain the custom changes yourself. Alternatively, you could use vQmod to make the change instead, so it will persist.

 

Also, I think you can use:

$this->invoice->line_items[$i]->subtotal

..instead of calculating the subtotal yourself.

Link to comment
Share on other sites

  • 0

In the detault template for invoices it seems to include the tax on each line item in the invoice in the field called cost.  This seems confusing, it shouldn't show the total including tax.  How can i change this?

 

Right now it shows:

description | qty I unit price I cost = qty * unit price * tax

subtotal shows total without tax,

tax line

total line with tax

 

it should be:

description | qty I unit price I cost = qty * unit price

subtotal = total without tax,

tax = total taxes

total = subtotal +tax

i think this was already discused in old thread about tax calculation . have you tried the inclusive tax calculation ?

Link to comment
Share on other sites

  • 0

I did try searching for it but couldnt find anything.  Whats the inclusive tax calculation?  I fix the problem by modifying the default_invoice_pdf.php file making the following change to calculate the cost field instead of using the total from the line item.  Problem is that if the system is updated i think this will get overriden (not 100% sure about that). 

 

 

public function drawInvoice() {
        
        $options = $this->line_options;
        $options['y_pos'] = max($this->header_end_y, $this->GetY());
        
        // Build line items
        $lines = array();

        for ($i=0; $i<count($this->invoice->line_items); $i++) {
            $lines[] = array(
                'name'=>$this->invoice->line_items[$i]->description,
                'qty'=>$this->CurrencyFormat->truncateDecimal($this->invoice->line_items[$i]->qty, 0),
                'unit_price'=>$this->CurrencyFormat->format($this->invoice->line_items[$i]->amount, $this->invoice->currency, self::$standard_num_options),
                'price'=>$this->CurrencyFormat->format(($this->invoice->line_items[$i]->amount*$this->invoice->line_items[$i]->qty), $this->invoice->currency, self::$standard_num_options),
                   /**'price'=>$this->CurrencyFormat->format($this->invoice->line_items[$i]->total, $this->invoice->currency, self::$standard_num_options),**/
            );

Link to comment
Share on other sites

  • 0

I did try searching for it but couldnt find anything.  Whats the inclusive tax calculation?  I fix the problem by modifying the default_invoice_pdf.php file making the following change to calculate the cost field instead of using the total from the line item.  Problem is that if the system is updated i think this will get overriden (not 100% sure about that). 

 

 

public function drawInvoice() {

        

        $options = $this->line_options;

        $options['y_pos'] = max($this->header_end_y, $this->GetY());

        

        // Build line items

        $lines = array();

        for ($i=0; $i<count($this->invoice->line_items); $i++) {

            $lines[] = array(

                'name'=>$this->invoice->line_items[$i]->description,

                'qty'=>$this->CurrencyFormat->truncateDecimal($this->invoice->line_items[$i]->qty, 0),

                'unit_price'=>$this->CurrencyFormat->format($this->invoice->line_items[$i]->amount, $this->invoice->currency, self::$standard_num_options),

                'price'=>$this->CurrencyFormat->format(($this->invoice->line_items[$i]->amount*$this->invoice->line_items[$i]->qty), $this->invoice->currency, self::$standard_num_options),

                   /**'price'=>$this->CurrencyFormat->format($this->invoice->line_items[$i]->total, $this->invoice->currency, self::$standard_num_options),**/

            );

this change is just for the invoice pdf .is the amount are well set in the invoice due shown in billing ?

Link to comment
Share on other sites

  • 0

i dont really understand your question.  All i want is for the invoice that is generated to show the correct line item total without tax.  Having the cost column include the tax makes no sense.  People assuming the column totals up which it doesnt because if you total the cost column its the total price not the subtotal price.   My fix in the PDF works fine Im just concerned that if i update blesta the changes will get overridden with a new pdf template file.

Link to comment
Share on other sites

  • 0

i dont really understand your question.  All i want is for the invoice that is generated to show the correct line item total without tax.  Having the cost column include the tax makes no sense.  People assuming the column totals up which it doesnt because if you total the cost column its the total price not the subtotal price.   My fix in the PDF works fine Im just concerned that if i update blesta the changes will get overridden with a new pdf template file.

so from the begining i misunderstand you . i have though that the tax calculation is wrong , what you are refiring how the tax line should be shown in invoice .

Link to comment
Share on other sites

  • 0

If you update Blesta, then yes, the change you made would be overridden. You would have to maintain the custom changes yourself. Alternatively, you could use vQmod to make the change instead, so it will persist.

 

Also, I think you can use:

$this->invoice->line_items[$i]->subtotal

..instead of calculating the subtotal yourself.

yes thanks, that works too.  How do i go about creating a custom template? that would work best i think.  Would allow me to make some other changes on the invoice as well if i wanted.

I just tried to create a new folder under invoice templates and copied the files in there from the default and changed all the names (ie bmts_invoice) but when i load the invoice customization page it just white screens, deleted the folder and files and the page loads again

Link to comment
Share on other sites

  • 0

just copy the default_invoice to any other template you want letsay my_invoice .

don't forget to hcnage all the name files and class from DefaultInvoice to MyInvoice .

have this already done in my test server . i can't share the files , because i have option betwen HTML output and PDF output , but is not completed totally , so there is some bugs/fix to finish , after i will puplish it freely .

Link to comment
Share on other sites

  • 0

just copy the default_invoice to any other template you want letsay my_invoice .

don't forget to hcnage all the name files and class from DefaultInvoice to MyInvoice .

have this already done in my test server . i can't share the files , because i have option betwen HTML output and PDF output , but is not completed totally , so there is some bugs/fix to finish , after i will puplish it freely .

beauty.. got it working.  Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...