@@ -547,7 +547,7 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
547547 }
548548 }
549549
550- // ref
550+ // ref object
551551 $ this ->ref_object = ((!empty ($ object ->newref )) ? $ object ->newref : $ object ->ref ); // newref is set when validating a draft, ref is set in other cases
552552 // type of object
553553 $ this ->element = $ object ->element ;
@@ -595,7 +595,13 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
595595 'fk_incoterms ' , 'label_incoterms ' , 'location_incoterms ' , 'lines ' ));
596596 }
597597
598- if (!empty ($ object ->thirdparty )) {
598+ // For customer payment and supplier payment, the thirdparty can be added in payment detail
599+ $ addthirdpartyatpaymentlevel = 0 ;
600+ if (!empty ($ object ->thirdparty ) && !in_array ($ this ->element , array ('payment ' , 'payment_supplier ' ))) {
601+ $ addthirdpartyatpaymentlevel = 1 ;
602+ }
603+
604+ if (!empty ($ object ->thirdparty ) && !$ addthirdpartyatpaymentlevel ) {
599605 $ this ->object_data ->thirdparty = new stdClass ();
600606
601607 foreach ($ object ->thirdparty as $ key => $ value ) {
@@ -652,7 +658,7 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
652658 $ valuequalifiedforstorage = true ; // We accept '' value for some fields
653659 $ value = (string ) $ value ;
654660 }
655- if (!is_null ($ value ) && empty ($ value ) && in_array ($ key , array ('tva_assuj ' ))) {
661+ if (!is_null ($ value ) && empty ($ value ) && in_array ($ key , array ('tva_assuj ' , ' localtax1_assuj ' , ' localtax2_assuj ' ))) {
656662 $ valuequalifiedforstorage = true ; // We accept zero value for amounts
657663 }
658664 if (!is_null ($ value ) && (string ) $ value !== '' ) {
@@ -753,6 +759,33 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
753759 if (!empty ($ object ->newref )) {
754760 $ this ->object_data ->ref = $ object ->newref ;
755761 }
762+
763+ // Add data for action emails
764+ if ($ action == 'BILL_SENTBYMAIL ' ) {
765+ $ emailobj = new stdClass ();
766+ $ emailobj ->email_from = $ object ->email_from ;
767+ //$emailobj->email_to = $object->email_to;
768+ $ emailobj ->email_msgid = $ object ->email_msgid ;
769+ $ emailobj ->email_subject = $ object ->email_subject ;
770+
771+ $ this ->object_data ->action_email_sent = $ emailobj ;
772+ }
773+
774+ // Add data for action doc_preview
775+ if ($ action == 'DOC_PREVIEW ' ) {
776+ $ docpreviewobj = new stdClass ();
777+ $ docpreviewobj ->pos_print_counter = $ object ->pos_print_counter ;
778+
779+ //$this->object_data->action_doc_preview = $docpreviewobj;
780+ }
781+
782+ // Add data for action doc_download
783+ if ($ action == 'DOC_DOWNLOAD ' ) {
784+ $ docdownloadobj = new stdClass ();
785+ $ docdownloadobj ->pos_print_counter = $ object ->pos_print_counter ;
786+
787+ //$this->object_data->action_doc_download = $docdownloadobj;
788+ }
756789 } elseif ($ this ->element == 'invoice_supplier ' ) {
757790 '@phan-var-force FactureFournisseur $object ' ;
758791 foreach ($ object as $ key => $ value ) {
@@ -849,7 +882,9 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
849882 $ paymentpart = new stdClass ();
850883 $ paymentpart ->amount = $ amount ;
851884
852- if (!in_array ($ this ->element , array ('payment_donation ' , 'payment_various ' ))) {
885+ // If we want to add thirdparty on each payment level
886+ // (seems not necessary as we have one thirdparty per payment on invoice level)
887+ if ($ addthirdpartyatpaymentlevel ) {
853888 $ result = $ tmpobject ->fetch_thirdparty ();
854889 if ($ result == 0 ) {
855890 $ this ->error = 'Failed to fetch thirdparty for object with id ' .$ tmpobject ->id ;
@@ -870,7 +905,7 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
870905 // List of thirdparty fields qualified
871906 if (!in_array ($ key , array (
872907 'name ' , 'name_alias ' , 'ref_ext ' , 'address ' , 'zip ' , 'town ' , 'state_code ' , 'country_code ' , 'idprof1 ' , 'idprof2 ' , 'idprof3 ' , 'idprof4 ' , 'idprof5 ' , 'idprof6 ' , 'phone ' , 'fax ' , 'email ' , 'barcode ' ,
873- 'tva_intra ' , 'localtax1_assuj ' , 'localtax1_value ' , 'localtax2_assuj ' , 'localtax2_value ' , 'managers ' , 'capital ' , 'typent_code ' , 'forme_juridique_code ' , 'code_client ' , 'code_fournisseur '
908+ 'tva_intra ' , 'tva_assuj ' , ' localtax1_assuj ' , 'localtax1_value ' , 'localtax2_assuj ' , 'localtax2_value ' , 'managers ' , 'capital ' , 'typent_code ' , 'forme_juridique_code ' , 'code_client ' , 'code_fournisseur '
874909 ))) {
875910 continue ; // Discard if not into a dedicated list
876911 }
0 commit comments