eileenmcnaughton / nz.co.fuzion.civixero

Synchronisation between CiviCRM & Xero
7 stars 14 forks source link

scheduled job errors #125

Open Upperholme opened 1 year ago

Upperholme commented 1 year ago

I've been seeing potential issues since moving to version 2.1.0. Installing the master codebase a couple of weeks back appears to have helped somewhat, and I've just now updated to version 2.1.1.

I thought it might be helpful to report what I'm seeing in my scheduled job logs. I would welcome any feedback to help me resolve these errors.

The log entry for the contact pull job:

Parameters raw (from db settings): 
plugin=xero
start_date=yesterday

Parameters parsed (and passed to API method): 
a:3:{s:7:"version";i:3;s:6:"plugin";s:4:"xero";s:10:"start_date";s:9:"yesterday";}

Full message: 
Finished execution of CiviXero Contact Pull Job with result: Failure, Error message: DB Error: already exists

From the contact push job:

Parameters raw (from db settings): 
plugin=xero

Parameters parsed (and passed to API method): 
a:2:{s:7:"version";i:3;s:6:"plugin";s:4:"xero";}

Full message: 
Finished execution of CiviXero Contact Push Job with result: Failure, Error message: Not all contacts were saved

This is followed by a fairly long list of contacts with problems. Looks like two different types:

I have entries that look like this:

Contact Push failed
    [28] => Failed to push  (9322059d-7b44-4851-b861-13a9bf9da2d6 ) with error Expected one Contact but found 25

and I have some where a contact name is given and reporting that the name is already assigned to another contact. I'm guessing this is due to records in Civi or Xero (probably in Civi) getting merged, so the job is attempting to push a contact where in Xero the matching record is already synced with a different Civi record (i.e the one that deleted as a result of the merge?). With some of these rows the contact ID is given, in others it isn't (guessing that this might be useful info but not sure why). I did raise a query about record merging some while back: https://github.com/eileenmcnaughton/nz.co.fuzion.civixero/issues/88

I also have some rows that are reporting that "The specified contact details matched an archived contact. Archived contacts cannot currently be edited via the API." I'm guessing that in these cases the contact ID is matched up to a Xero contact that has been archived (again as a result of a merge on the Xero end)?

The most recent run of this job reports 137 errors in all, but the Contact Errors page at civicrm/accounting/errors/contacts lists nothing.

The invoice pull job reports the following:

Parameters raw (from db settings): 
plugin=xero
start_date=yesterday

Parameters parsed (and passed to API method): 
a:3:{s:7:"version";i:3;s:6:"plugin";s:4:"xero";s:10:"start_date";s:9:"yesterday";}

Full message: 
Finished execution of CiviXero Invoice Pull Job with result: Failure, Error message: Not all records were savedArray
(
    [0] => Failed to store 23.03.010 (f5628fe6-2e92-4289-b040-2ac6c9deac55) with error contribution_id is not a valid integerInvoice Pull failed
    [1] => Failed to store 23.01.009 (5a2264be-6897-45cb-a33d-34928d2548f6) with error contribution_id is not a valid integerInvoice Pull failed
)

My guess is that some invoices that are created at the Xero end, with these slightly odd looking invoice numbers (e.g. 23.03.010) are leading to these errors, as the invoice pull job can't cope with the non-standard invoice numbering? Can it only work with integers?

Lastly the invoice push job is failing with the following:

Parameters raw (from db settings): 
plugin=xero

Parameters parsed (and passed to API method): 
a:2:{s:7:"version";i:3;s:6:"plugin";s:4:"xero";}

Full message: 
Finished execution of CiviXero Invoice Push Job with result: Failure, Error message: Not all records were savedArray
(
    [0] => Failed to store 6131 () with error '0' is not a valid option for field accounts_status_idArray
(
)
Invoice Push failed
    [1] => Failed to store 6261 () with error '0' is not a valid option for field accounts_status_idArray
(
)
Invoice Push failed
    [2] => Failed to store 6241 () with error '0' is not a valid option for field accounts_status_idArray
(
    [0] => A validation exception occurred
    [1] => An existing contact could not be found using the specified contact details. The contact name field is required to create a new contact.
)
Invoice Push failed
    [3] => Failed to store 6262 () with error '0' is not a valid option for field accounts_status_idArray
(
    [0] => A validation exception occurred
    [1] => An existing contact could not be found using the specified contact details. The contact name field is required to create a new contact.
)
Invoice Push failed
)

accounts_status_id is a field in the civicrm_account_invoice table described as 'Status in accounts system (mapped to civicrm definition)' . Looking at the four contribution records in Civi with these four IDs, they are all marked as having a contribution status of 'Failed'.

No invoice errors are being reported at civicrm/accounting/errors/invoices

eileenmcnaughton commented 1 year ago

@mattwire can you comment? My first thought is this might be increased noisiness

eileenmcnaughton commented 1 year ago

" with error '0' is not a valid option for field accounts_status_id"

There is a setting on the CiviXero page that specifies what that should be - maybe re-save the form?

Upperholme commented 1 year ago

Thx, I'll take a look at that.