Page 1 of 1

JiwaCollection violates constraint error

PostPosted: Wed Jan 08, 2020 2:14 am
by Riyaz
Hi There'

When I try to process the salesorder am getting the below error, the error triggers on the line SalesOrder.Process(), can you pls kindly advise on this

GenericArguments[0], 'JiwaFinancials.Jiwa.JiwaCashBook.CashBookTransaction', on 'JiwaFinancials.Jiwa.JiwaApplication.JiwaCollection`1[T]' violates the constraint of type parameter 'T'.

Code used is as below

Using JiwaCon As New SqlConnection(_Login.JiwaConnectionString)
Dim manager As New JiwaFinancials.Jiwa.JiwaApplication.Manager()
manager.Logon(JiwaCon.DataSource, JiwaCon.Database, JiwaFinancials.Jiwa.JiwaODBC.database.AuthenticationModes.JiwaAuthentication, _Login.UserName, _Login.Password)
SalesOrder = manager.BusinessLogicFactory.CreateBusinessLogic(Of JiwaSales.SalesOrder.SalesOrder)(Nothing)
SalesOrder.Read(_InvoiceID)
SalesOrder.Process()
End Using

Re: JiwaCollection violates constraint error

PostPosted: Wed Jan 08, 2020 6:37 am
by SBarnes
Hi Riyaz,

Processing a sales order shouldn't go anywhere near the cash book, is there the possibility that your code is causing another plugin to fire?

I would suggest trying the sales order processing code against a demo database and see if you get the same error as you may find the error is particular to the database you are using.

Also look at the stack trace for the exception that is being thrown that is giving you the error as this might give you more a clue to the source.

Re: JiwaCollection violates constraint error

PostPosted: Thu Jan 09, 2020 3:23 pm
by DannyC
Is there a payment on the sales order?

Re: JiwaCollection violates constraint error  Topic is solved

PostPosted: Sun Jan 12, 2020 7:21 pm
by Mike.Sheen
DannyC wrote:Is there a payment on the sales order?


Payments on sales orders do create a cash book entry or append to an existing one (depending on dates and the presence of a cash book entry for the same date and also system settings), and so it does create a cash book object when processing a sales order.

The error is interesting - it indicates to me perhaps mismatched Jiwa assemblies - the cash book assembly being used is not what is expected by the factory of the JiwaApplication.

The version of Jiwa being used will be helpful to know - and also if this is a non-clean environment (as in a dev environment - often dev environments have multiple versions of Jiwa assemblies laying around) the version of the JiwaApplication and JiwaCashBook assemblies will be of use - if they are different then that could be a problem.