Validation Exception during Save() operation on SalesInvoice - Cash Account ID cannot be an empty string - With my fix

Greetings all,

I was getting the above error seemingly randomly with 1 specific customer that we have our product integrated with. I racked my brain and the keyboard for hours trying to figure out why this error was being generated.

Long story short, this customer had upgraded their Sage 50 from a relatively old version to the 2014, which I believe had an affect.

I could actually post SalesInvoice for a new customer that I had created, but I was not able to post for existing customers. I dove deeper in to the customer records in the Sage interface. (I could create and save Invoices for the same Inventory item in the Sage 50 interface fine, and I could create Sales Invoices for new customers I programmatically created fine.)

I noticed that in the Payments & Credit tab for the Customer, that under the Credit Card section, the 2 address fields had the word "False" printed in (this is only for customers that were imported from an earlier version of Sage). It's weird since if you try to save the Customer in Sage 50 with the fields set like that, Sage would throw an error saying it was not valid. I ended up deleting the word "False" from the 2 address fields, saving the customer, and then pushing the Invoice from our product in to Sage and it worked fine. (Thankfully this user only had about 50 Customers in their Sage 50 database, else this could have been a lot of button pushing.)

Net net: if you end up getting weird "Cash Account ID" errors when doing a .Save() operation a SalesInvoice, check in the Customer record. Even a bad value that has nothing to do with your SalesInvoice can have an affect.

Hopefully this saves someone else many hours of banging their heads on walls.