mix phoenix_kit_crm. import_suppliers_from_catalogue
(PhoenixKitCRM v0.3.3)
Copy Markdown
View Source
Imports catalogue suppliers into CRM companies and grants them the supplier
role. This is a one-time backfill task following the SAP-CVI pattern.
Behaviour
- Dry-run by default: pass
--applyto write changes. - Idempotent: rows with a non-null
crm_company_uuidare skipped and reported asalready-linked. - Catalogue-absent guard: if
phoenix_kit_cat_suppliersdoes not exist the task exits with a clear message rather than crashing. - Inactive suppliers are still imported (they may appear on posted documents); they are flagged in the report.
Matching logic (per supplier row)
- Normalize the candidate email: regex-extract from free-text
contact_info, downcase and trim. - Normalize the website: strip scheme (
https?://) and leadingwww., downcase. - Match an existing CRM company by email first (citext equality), then by normalized website if no email match. Otherwise create a new company.
Usage
mix phoenix_kit_crm.import_suppliers_from_catalogue # dry-run
mix phoenix_kit_crm.import_suppliers_from_catalogue --apply # write
Summary
Functions
Extracts the first email-like token from a free-text contact_info string. Returns the downcased, trimmed email or nil.
Strips https?:// scheme and leading www. from a URL, then downcases.
Returns nil for nil/empty input.
Functions
Extracts the first email-like token from a free-text contact_info string. Returns the downcased, trimmed email or nil.
Strips https?:// scheme and leading www. from a URL, then downcases.
Returns nil for nil/empty input.