diff --git a/fusion_centralize_billing/models/account_link.py b/fusion_centralize_billing/models/account_link.py
index e8db15a0..d91361ca 100644
--- a/fusion_centralize_billing/models/account_link.py
+++ b/fusion_centralize_billing/models/account_link.py
@@ -46,7 +46,9 @@ class FusionBillingAccountLink(models.Model):
return existing
partner = self.env['res.partner']
if email:
- partner = partner.search([('email', '=', email)], limit=1)
+ # case-insensitive so a pre-existing partner with a differently-cased email
+ # (created via the web UI or another sync) is reused, not duplicated.
+ partner = partner.search([('email', '=ilike', email)], limit=1)
if not partner:
partner = partner.create({'name': name or external_id, 'email': email, **(extra or {})})
return self.create({
diff --git a/fusion_centralize_billing/tests/test_importer.py b/fusion_centralize_billing/tests/test_importer.py
index 849ec152..9ffdcf01 100644
--- a/fusion_centralize_billing/tests/test_importer.py
+++ b/fusion_centralize_billing/tests/test_importer.py
@@ -211,6 +211,29 @@ class TestImporterErrorIsolation(TransactionCase):
self.assertTrue(summary['failed'], "the bad row must be recorded in failed[]")
self.assertTrue(any(f['kind'] == 'user' for f in summary['failed']))
+ def test_unknown_billing_cycle_is_failed_not_silently_monthly(self):
+ data = _fixture()
+ data['subscriptions'][0]['billing_cycle'] = 'annual' # not monthly/yearly
+ summary = self.Wizard._import_rows(data)
+ self.assertFalse(self.env['sale.order'].search(
+ [('x_fc_nexacloud_subscription_id', '=', 's-1')]),
+ "an unrecognized billing_cycle must NOT silently create a monthly sub")
+ self.assertTrue(any(f['kind'] == 'subscription' and f['id'] == 's-1'
+ for f in summary['failed']))
+
+ def test_missing_price_for_cycle_is_failed_not_zero(self):
+ data = _fixture()
+ data['plans'][0]['price_yearly'] = None # s-2 is yearly -> no price for it
+ summary = self.Wizard._import_rows(data)
+ # the yearly sub fails (no silent $0 line); the monthly one still imports
+ self.assertFalse(self.env['sale.order'].search(
+ [('x_fc_nexacloud_subscription_id', '=', 's-2')]),
+ "a missing price for the cycle must NOT silently create a $0 line")
+ self.assertTrue(self.env['sale.order'].search(
+ [('x_fc_nexacloud_subscription_id', '=', 's-1')]))
+ self.assertTrue(any(f['kind'] == 'subscription' and f['id'] == 's-2'
+ for f in summary['failed']))
+
@tagged('post_install', '-at_install')
class TestImporterReadGuard(TransactionCase):
diff --git a/fusion_centralize_billing/views/import_wizard_views.xml b/fusion_centralize_billing/views/import_wizard_views.xml
index a680d1f5..b38eaf3c 100644
--- a/fusion_centralize_billing/views/import_wizard_views.xml
+++ b/fusion_centralize_billing/views/import_wizard_views.xml
@@ -5,6 +5,13 @@
fusion.billing.import.wizard