Topic: Changing one of the columns in "Invoice Against Sales Delivery"

Need some help getting pointed in the direction for where the code is that determines what data is pulled from the database.

What I am trying to do is change the "Branch" column to show my new "Ship From" data.  Now I can change the column heading all day long, what I can't figure out is where to change the data that's being called up.  I was able to make it change in the "Sales Order Inquiry" to where it shows the "Ship From" data from my database.  After I made that change this afternoon, I forgot how I did it have been trying to figure that out as well so I could do the same thing for the "Invoice Against Sales Delivery".

I see in sales/inquiry/sales_deliveries_view.php where it calls the sql and the sets up the columns, but I can't find where it calls the data from the database.

$sql = get_sql_for_sales_deliveries_view($selected_customer, $selected_stock_item, $_POST['customer_id']);

$cols = array(
        _("Delivery #") => array('fun'=>'trans_view'),
        _("Customer"),
        'branch_code' => 'skip',
        _("Branch") => array('ord'=>''),
        //_("Ship From") => array('type' => 'ship_from' , 'ord' => '') , This is a line I added, but is commented out right now.  I know if I comment out the line above and uncomment this one I can change the column title.
        _("Deliver To"),
        _("Reference"),
        _("Cust Ref"),
        _("Delivery Date") => array('type'=>'date', 'ord'=>''),
        _("Due By") => 'date',
        _("Delivery Total") => array('type'=>'amount', 'ord'=>''),
        _("Currency") => array('align'=>'center'),
        submit('BatchInvoice',_("Batch"), false, _("Batch Invoicing"))
            => array('insert'=>true, 'fun'=>'batch_checkbox', 'align'=>'center'),
        array('insert'=>true, 'fun'=>'edit_link'),
        array('insert'=>true, 'fun'=>'invoice_link'),
        array('insert'=>true, 'fun'=>'prt_link')
);

Thank you for the help in this!

2 (edited by apmuthu 12/11/2016 05:01:41 am)

Re: Changing one of the columns in "Invoice Against Sales Delivery"

You are trying to change the heading label - it has nothing to do with the actual field from where it comes. The type array element is for formatting the column and also has nothing to do with the contents of any table's field.

Anything like: _("string") is shortform for gettext("string") and is changed by changing the *.po file and compiling it as *.mo file using msgfmt. Refer the Translations page in the Wiki.

To achieve what you want, pick out the strings that are affected and then trace the translation strings in the appropriate .po file and edit them in a text editor using "No BOM" format and then compile it it as the *.mo file and replace it in the fa install.

Re: Changing one of the columns in "Invoice Against Sales Delivery"

apmuthu wrote:

You are trying to change the heading label - it has nothing to do with the actual field from where it comes. The type array element is for formatting the column and also has nothing to do with the contents of any table's field.

Anything like: _("string") is shortform for gettext("string") and is changed by changing the *.po file and compiling it as *.mo file using msgfmt. Refer the Translations page in the Wiki.

To achieve what you want, pick out the strings that are affected and then trace the translation strings in the appropriate .po file and edit them in a text editor using "No BOM" format and then compile it it as the *.mo file and replace it in the fa install.

Ok, I think I didn't explain what I was trying to do that well.

What I am want to do is instead of the Branch information being shown in the branch column, have it pull from my DB the Ship From information instead.  I did that with the Sales Order Search page, but I can't figure out how to do that with the Invoice Against Deliveries page.

Here is what the page looks like now

Here is what I want to change

Here is how I changed the data in the search sales order page

4 (edited by apmuthu 12/14/2016 04:24:33 pm)

Re: Changing one of the columns in "Invoice Against Sales Delivery"

Your navigation:

Sales -> Invoice Against Sales Delivery

will yield a url like:

http://localhost/sales/inquiry/sales_deliveries_view.php?OutstandingOnly=1

The file sales/inquiry/sales_deliveries_view.php calls the function get_sql_for_sales_deliveries_view() defined in sales/includes/db/cust_trans_db.inc just before assigning the array of column headings to $cols.

Edit the SQL in the said function to include the Ship_From field and adjust the $cols for the heading (either by hardcoding or as gettext translation string in .po/.mo).

Post's attachments

NotInvDely_Mod_Screen.png 62.8 kb, file has never been downloaded. 

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

Re: Changing one of the columns in "Invoice Against Sales Delivery"

apmuthu wrote:

Your navigation:

Sales -> Invoice Against Sales Delivery

will yield a url like:

http://localhost/sales/inquiry/sales_deliveries_view.php?OutstandingOnly=1

The file sales/inquiry/sales_deliveries_view.php calls the function get_sql_for_sales_deliveries_view() defined in sales/includes/db/cust_trans_db.inc just before assigning the array of column headings to $cols.

Edit the SQL in the said function to include the Ship_From field and adjust the $cols for the heading (either by hardcoding or as gettext translation string in .po/.mo).

Wow, that was so easy to do.  Thank you for all the help.

On a side note though, by making that change to the function get_sql_for_sales_deliveries_view() defined in sales/includes/db/cust_trans_db.inc it now allows me to batch invoice deliveries from the same customer but different branches.  If I process the invoice will that mess up the transactions in the GL or any of the other accounts?  I guess I could make a quick backup of the db and then create the batch invoice and see what happens.  Just was curious if there was something in the deep background that might get messed up with that invoice if I did that.

Re: Changing one of the columns in "Invoice Against Sales Delivery"

I guess another question I have is I have made a lot of modifications to the core and hard coding changes to FA.  Is there a way to take what I have done and turn it into a module or way to package it up so when an update to FA comes along I won't be pulling my hair out trying to redo all the modifications I have created?

Re: Changing one of the columns in "Invoice Against Sales Delivery"

Keeping the Branch Column and adding the Ship_From field along with the appropriate report and sql filters / where constructs and the headings ($cols) will mitigate the Branch filter issue.

1. Create a local Git repo using TortoiseGIT in your windows environment (works with Linux and Mac too) with the core files in a core folder.
2. Place your files in a mods sibling folder. Import the affected core files as is into the same path under your mods folder and commit the change.
3. Make changes to the files in the mods folder and commit the change with information regarding the feature / change envisaged with it.
4. Whenever the core file changes, compare with your modded file and implement the changes thereof in it.