Topic: Bug in Supplier Credit Note Edit

When I tried to Edit Credit Note of Supplier in FA 2.4.8 I faced following bug. My PHP is 7.4

Trying to get property 'Comments' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 16
/home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc:80:    copy_from_trans('')
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'tran_date' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 17
/home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc:80:    copy_from_trans('')
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'due_date' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 18
/home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc:80:    copy_from_trans('')
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'supp_reference' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 19
/home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc:80:    copy_from_trans('')
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'reference' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 20
/home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc:80:    copy_from_trans('')
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'supplier_id' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 21
/home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc:80:    copy_from_trans('')
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'dimension' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 22
/home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc:80:    copy_from_trans('')
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'dimension2' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 23
/home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc:80:    copy_from_trans('')
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'ex_rate' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 25
/home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc:80:    copy_from_trans('')
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'trans_type' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 86
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'trans_no' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 97
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Trying to get property 'supplier_id' of non-object in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 104
/home/pakerp/web/core.pakerp.net/public_html/purchasing/supplier_credit.php:348:    invoice_header('')
Unhandled exception [0]: Call to a member function clear_items() on null. in file: /home/pakerp/web/core.pakerp.net/public_html/purchasing/includes/ui/invoice_ui.inc at line 109
exception_handler((Error Object))

I don't think its a PHP related bug. The Session Variable is not instantiated.

Here is the Screen shot https://prnt.sc/tqcosv

Post's attachments

sup_edit.png 54.2 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.
www.boxygen.pk

Re: Bug in Supplier Credit Note Edit

diff --git a/core/purchasing/includes/supp_trans_class.inc b/core/purchasing/includes/supp_trans_class.inc
index be9ec00..5a17f86 100644
--- a/core/purchasing/includes/supp_trans_class.inc
+++ b/core/purchasing/includes/supp_trans_class.inc
@@ -66,7 +66,7 @@ class supp_trans
                        read_supp_invoice($trans_no, $trans_type, $this);
                        if ($trans_type == ST_SUPPCREDIT)
                        {
-                               $this->src_docs = find_src_invoices($trans_no);
+                               $this->src_docs = find_src_invoices($this);
                        }
                        read_supplier_details_to_trans($this, $this->supplier_id);
                }
diff --git a/core/purchasing/supplier_credit.php b/core/purchasing/supplier_credit.php
index 461c804..070afda 100644
--- a/core/purchasing/supplier_credit.php
+++ b/core/purchasing/supplier_credit.php
@@ -28,8 +28,12 @@ if (user_use_date_picker())
 
 //----------------------------------------------------------------------------------------
 
-if (isset($_GET['ModifyCredit']))
+if (isset($_GET['ModifyCredit'])) {
        check_is_editable(ST_SUPPCREDIT, $_GET['ModifyCredit']);
+    $_SESSION['page_title'] = sprintf( _("Modifying Supplier Credit # %d"), $_GET['ModifyCredit']);
+    $_SESSION['supp_trans'] = new supp_trans(ST_SUPPCREDIT, $_GET['ModifyCredit']);
+}
+

 
 //---------------------------------------------------------------------------------------------------

I doubt the old code ever worked.  I looked at the change history for related files and nothing has been changed that would have caused this to break.  The proposed change above is incomplete and untested; G/L line items cannot be edited, only added or deleted.

Re: Bug in Supplier Credit Note Edit

@BraathWate it worked. Thanks

www.boxygen.pk

Re: Bug in Supplier Credit Note Edit

@joe: check if it needs to get into the core.

Re: Bug in Supplier Credit Note Edit

Hello Guys,

I couldn't find any better solution, so I have followed @Braath Waate's solution. I hope it works and please help testing it.

The changes will be committed to repo asap.

/Joe