Page 1 of 1

sales order AllowPriceOverrides line by line

PostPosted: Fri Oct 27, 2017 2:59 pm
by DannyC
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

Re: sales order AllowPriceOverrides line by line  Topic is solved

PostPosted: Sat Oct 28, 2017 7:36 pm
by SBarnes
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.

Re: sales order AllowPriceOverrides line by line

PostPosted: Sun Oct 29, 2017 12:59 pm
by Mike.Sheen
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;
}