Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QBO: Fetch customers by
DisplayName
rather than CompanyName
We were fetching by `CompanyName` and then filtering with `pluck_customer_id_by_currency()`, because QBO doesn't allow filtering by `currencyRef`. A simpler way to achieve that is by filtering on `DisplayName`, since `create_customer()` includes the currency there. Its nice to simplify the code like this, but the main reason for this change was to fix a problem where a WCEU invoice for WPML couldn't be approved. `get_customer()` returned id `4` when it should have returned id `3878`. `4` was created manually with the `USD` currency, and doesn't have the currency in the `DisplayName` like the code expects. When that customer was passed to `pluck_customer_id_by_currency()`, it returned `false` because it was looking for a company with the `EUR` currency. So then `probably_get_customer_id()` tried to create a `EUR` customer, but that failed because one already exists with that `DisplayName`. There's about 70 of those manually created customers that are missing the currency in the `DisplayName`, so this will have the side-effect of creating an extra customer for them. There's no tangible problem with having multiple customers with the same currency for the same company, though; we already have a lot of them because `wcb_sponsor` posts are created with slightly different names -- e.g. "WooCommerce" and "WooCommerce LLC". I didn't manually fix the `DisplayName` for the older customers because it would have taken too long to be worth it. https://europe.wordcamp.org/2023/wp-admin/post.php?post=5117&action=edit https://app.qbo.intuit.com/app/customerdetail?nameId=4 https://app.qbo.intuit.com/app/customerdetail?nameId=3878 https://help.developer.intuit.com/s/article/6240-Duplicate-Name-Exists-Error https://help.developer.intuit.com/s/question/0D5G000004Dk7XKKAZ/how-to-query-with-currencyref-condition-in-customerqb-online
- Loading branch information