Strange issue V15.0.1 - Using Compute Field in Complementary attributes (lines) Invoice ODT

Hi @eldy, @ksar and others,

Greetings,

I am facing a strange issue of only particular fields doesnot appear if we use computational field in complementary attributes(lines) of Invoices:

Please refer to below picture:

The same formula WORKS FINE with other parameters. Like few examples given below:

  1. (($reloadedobj = new Facture($db)) && ($reloadedobj->fetchNoCompute($obj->id:(($obj->rowid ? $obj->rowid: $object->id)) > 0)) ? $reloadedobj → ref: ‘-1’
  2. (($reloadedobj = new Facture($db)) && ($reloadedobj->fetchNoCompute($obj->id:(($obj->rowid ? $obj->rowid: $object->id)) > 0)) ? $reloadedobj → total_ht: ‘-1’
  3. (($reloadedobj = new Facture($db)) && ($reloadedobj->fetchNoCompute($obj->id:(($obj->rowid ? $obj->rowid: $object->id)) > 0)) ? $reloadedobj → total_ttc: ‘-1’

Surprisingly, nothing appear if we use localtax1 and/or localtax2 on the PDF when called thru custom field. I have already enabled local tax in setup as well. Thats is:

  1. (($reloadedobj = new Facture($db)) && ($reloadedobj->fetchNoCompute($obj->id:(($obj->rowid ? $obj->rowid: $object->id)) > 0)) ? $reloadedobj → localtax1: ‘-1’

or

  1. (($reloadedobj = new Facture($db)) && ($reloadedobj->fetchNoCompute($obj->id:(($obj->rowid ? $obj->rowid: $object->id)) > 0)) ? $reloadedobj → localtax2: ‘-1’

GIVES ONLY BLANK OUTPUT

Can anyone help how to display localtax1 and localtax2 on PDF generated through ODT

thanks
yesbee

Hello,

Do a print_r($reloadedobj) to know the name of the possibles fields.

You don’t need ot use computed field for this.
According to this doc:

there is available tags to show value of localtax1 and localtax2.

1 Like

Dear @ksar, @eldy,

Greetings and appreciate your reply in spite of busy schedule.

Here is what I am trying to do:

Also here is the link for object dump:

https://drive.google.com/file/d/1zj9cGEwG3o0BqYO-WYpxetlThz2nWLln/view?usp=sharing

Just need help to access these fields under:
[“lines”]=> array(3) {[0]=> object(FactureLigne)#214 (143) {
[“element”]=> string(10) “facturedet”

Fields are:

[tva_tx]=> string(6) 18.000
[localtax1_tx]=> string(5) 0.000
[localtax2_tx]=> string(5) 0.000

so that the formula will become [tva_tx] + [localtax1_tx] + [localtax2_tx] = total line tax

thanks a ton,
yesbee.

So my understanding is that
You can show the vat amount, the local tax1 and local tax2 into your ODT. The tag replacement is ok.
But you miss a tag that contains the sum of all of this 3 taxes, this is the reason why you created a computed field ? Right ?

Yes. You are right… bulls eye…

thanks and regards,
yesbee

@eldy, @ksar,

Can you kindly help on how to address “element” in the computation field:

object(Facture)#210 (140) {
[“lines”]=> array(3) {
[0]=> object(FactureLigne)#214 (143) {
[“element”]=> string(10) “facturedet”

$object->lines[0]->element works but I am not sure about how to substitute variable for ‘0’ so that the line number changes for each line.

thanks and regards,
yesbee

/*********** */
Found the solution & it is:

"just add an additional parameter in /htdocs/core/class/commondocgenerator.class.php
with the formula to calculate the tax "

and Voila, it works like a charm…

thanks,
yesbee.

Yes it works like that, but then it’s a core modification => Will be erased on the next update.
Better to develop a specific module to do that.