sales order AllowPriceOverrides line by line  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

sales order AllowPriceOverrides line by line

Postby DannyC » Fri Oct 27, 2017 2:59 pm

Hi,
Version 7.1.00
I know I can set salesOrder.SystemSettings.AllowPriceOverrides which allows editing prices for the whole sales order.

What would the syntax be if I want to enumerate each sales order line, and set the line prices to be editable and other lines not editable.
Code: Select all
For Each SOLine As JiwaSales.SalesOrder.SalesOrderLine In salesOrder.SalesOrderLines
   IF SOLine.MyProperty = the price can be edited THEN
         'something in here
    End If
Next

Cheers

Danny
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: sales order AllowPriceOverrides line by line  Topic is solved

Postby SBarnes » Sat Oct 28, 2017 7:36 pm

Hi Danny,

Set the Discountable property on the line for example the following code would open up every line on an order

Code: Select all
      foreach(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine  line in salesorder.SalesOrderLines)
      {
         line.Discountable = true;
      }


The sales order form will take care of the rest, of course the system setting to allow price overrides must be set as well.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: sales order AllowPriceOverrides line by line

Postby Mike.Sheen » Sun Oct 29, 2017 12:59 pm

SBarnes wrote:The sales order form will take care of the rest, of course the system setting to allow price overrides must be set as well.


And remember you can override the system setting in code, without having to actually set the system setting via the configuration form - the sales order grabs a copy of the system settings relevant to sales orders upon load of the form / business logic - so overriding that in code won't write the setting back, but the sales order form / business logic will always operate on it's own copy:

Code: Select all
salesOrder.SystemSettings.AllowPriceOverride = true;


To be thorough, you can set it and set it back to the old state when you've done what you need

Code: Select all
bool oldAllowPriceOverride = salesOrder.SystemSettings.AllowPriceOverride;
try {
   salesOrder.SystemSettings.AllowPriceOverride = true;
   ...
}
finally {
   salesOrder.SystemSettings.AllowPriceOverride = oldAllowPriceOverride;
}
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 14 guests

cron