Page 1 of 2

Pricing Scheme Ignored

PostPosted: Tue Jun 02, 2015 10:02 am
by neil.interactit
Hey guys,

I have an obscure issue (but instead of getting personal, lets talk programming!) ...

When an invoice is imported into JIWA from the Job Manager utility the pricing scheme is ignored. Also once the invoice is imported into JIWA and we manually add additional items to the invoice the pricing scheme is also ignored.

Code: Select all
Manager.Instance.Logon(Servername, Database, database.AuthenticationModes.JiwaAuthentication, Username, password);
var salesOrder = Manager.Instance.BusinessLogicFactory.CreateBusinessLogic<SalesOrder>(null);
var inventory = new JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory();
[CLIP]
var debtor = new JiwaFinancials.Jiwa.JiwaApplication.Entities.Debtor.Debtor();
debtor.ReadRecord(debtorId);
[CLIP]
salesOrder.CreateNew(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder.NewSalesOrderTypes.e_NewSalesOrder, debtor.DebtorID);
salesOrder.OrderNo = jobs.Project;
salesOrder.InitiatedDate = initiatedDate;
salesOrder.WholeSaleInvoice = false;
[CLIP]
foreach (var row in rows)
{
   inventory.ReadRecordFromPartNo(row["JobCode"].ToString());
   salesOrder.SalesOrderLines.AddInventoryItem(inventory.InventoryID, JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLineCollection.SalesOrderLineInventorySeedTypes.e_SalesOrderLineInventoryID, ref newKey);
   salesOrder.SalesOrderLines[newKey].ScheduledDate = DateTime.Parse(row["AppointmentTime"]);
   salesOrder.SalesOrderLines[newKey].QuantityOrdered = Decimal.Parse(row["BilledHours"]);
   salesOrder.SalesOrderLines[newKey].DoLineCalculationsFromExGSTSellPrice();
   var details = row["Description"].Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
   foreach (string detail in details) salesOrder.SalesOrderLines.AddCommentLine(detail, ref newKey);
}
salesOrder.Save();

(c# strong typing specific code removed to make more readable)

This is implemented in an external EXE, referencing JiwaApplication,JiwaODBC,JiwaSales. It would appear that sales orders created through this do not observe the pricing scheme applied.

Cheers,
Neil

Re: Pricing Scheme Ignored

PostPosted: Tue Jun 02, 2015 10:24 am
by Scott.Pearce
So have you tested by adding the exact same part to the sales order manually? (To ensure that the price scheme is working under normal circumstances)

Re: Pricing Scheme Ignored

PostPosted: Tue Jun 02, 2015 10:29 am
by neil.interactit
Yep. It has been done manually until now - all working. However with imported invoices the behaviour seem different.

Re: Pricing Scheme Ignored

PostPosted: Tue Jun 02, 2015 10:37 am
by Scott.Pearce
Try *not* doing the line:

Code: Select all
salesOrder.SalesOrderLines[newKey].DoLineCalculationsFromExGSTSellPrice();

Re: Pricing Scheme Ignored

PostPosted: Tue Jun 02, 2015 10:41 am
by neil.interactit
Will do. Slightly off topic ... when I ran in VS this morning - on first Jiwa access, I am getting

The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security.


This is with no code change from previous successful running. Have you seen this before?

Re: Pricing Scheme Ignored

PostPosted: Tue Jun 02, 2015 10:55 am
by Scott.Pearce
Yes I have.

Dealing with event logs in .Net is crappy.

Jiwa (or a plugin) is probably trying to create an event source for whatever reason. To create an event source, all the logs have to be searched to ensure that the event source name we want to create is unique - the .net method for creating the event source does this for us automatically. The message you are getting is saying that you don't have permissions to read the "Security" logs, so .Net couldn't look there to check for uniqueness. It's just a warning.

By memory, you can avoid this exception by either running VS as admin, or you can manually create the event source yourself (this means that Jiwa wont have to create it, and therefore wont need to check for uniqueness, and therefore wont need to touch the Security logs).

We had to have our event sources created at install time to avoid this issue!

Re: Pricing Scheme Ignored

PostPosted: Tue Jun 02, 2015 12:01 pm
by neil.interactit
Thanks, running as admin fixed the event log error. Now the ACTUAL error has me stumped ... this all compiled/ran perfectly last week, and without any changes this week I am now getting:

ex.Message
"Object reference not set to an instance of an object."
ex.StackTrace
at JiwaFinancials.Jiwa.JiwaApplication.Manager.HandleApplicationManagerPluginExceptions()
at JiwaFinancials.Jiwa.JiwaApplication.Manager.Logon(String ServerName, String DatabaseName, AuthenticationModes AuthenticationMode, String JiwaUserName, String JiwaPassword)


I have confirmed all the params passed are not null (and correct).

Also, just to rule out an introduced issue, I quickly rebuilt a new project from scratch, added the 3 Jiwa DLL refs ... same result.

Any ideas?

Re: Pricing Scheme Ignored

PostPosted: Tue Jun 02, 2015 12:43 pm
by Scott.Pearce
That looks like a plugin exception.

Try disabling all plugins in the system (UPDATE SY_Plugin SET IsEnabled = 0) and run your exe again.

Re: Pricing Scheme Ignored

PostPosted: Tue Jun 02, 2015 1:10 pm
by neil.interactit
DUH! Absolutely right! Didn't even need to disable plugins ... just running Jiwa (which I hadn't yet today) recompiled the plugins and fixed the issue.

Note to self: Read the BLINKIN error message!

Re: Pricing Scheme Ignored

PostPosted: Tue Jun 02, 2015 1:18 pm
by Scott.Pearce
;-)