%%{init: {"themeCSS": ".edgeLabel { font-size: 35px !important; }"}}%%
flowchart TD

    A["Customer Base"] --> B["Is the customer active?"]

    B -- "Yes" --> AA["Is it B2C?"]
    B -- "No" --> NQ["Not Qualified"]

    AA -- "Yes" --> C["Do we have consent to contact?"]
    AA -- "No" --> NQ

    C -- "Yes" --> E["Is the customer either PHC, VIP, or has multiple active contracts?"]
    C -- "No" --> NQ

    E -- "Yes" --> NQ
    E -- "No" --> H["Does the contract have at least a 5 month billing history? (incl. associated MRC, Discount, List price)"]

    H -- "Yes" --> I["Has the contract suffered any changes in the last 5 months?"]
    H -- "No" --> NQ

    I -- "Yes" --> NQ
    I -- "No" --> L["Addressable Customer Base"]

    %% FINAL OUTPUT
    %% RAW-DATA INPUT CALLOUTS
    RAW_ACTIVE["Check the reference month;<br/>active when estado = '1'<br/><i>h_afiliado: contrato, anho, mes, estado</i>"] -.-> B
    RAW_B2C["Include RESIDENCIAL or CONDOMINIO only<br/><i>sig_afiliado: contrato, desc_tipocliente</i>"] -.-> AA
    RAW_CONSENT["Select latest fecha_creacion, then highest id;<br/>consent when aceptacion_consentimiento = 'S'<br/><i>consentimiento_contratos_pdf: contrato, aceptacion_consentimiento, fecha_creacion, id</i>"] -.-> C
    RAW_PHC["Exclude when current value is not 'NO_PHC'<br/><i>tbl_pr_billing_ingresos_residencial_ajustado: CONTRATO, TIPO_CLIENTE_POR_CUENTA_CONTABLE</i>"] -.-> E
    RAW_VIP["Exclude when desc_vip is populated<br/><i>sig_afiliado: contrato, cod_vip, desc_vip</i>"] -.-> E
    RAW_MULTIPLE["Exclude when one contrato maps to more than one cedula<br/><i>h_afiliado: contrato, cedula, anho, mes, estado</i>"] -.-> E
    RAW_HISTORY["Require positive valid credit in each of prior 5 calendar months<br/><i>transac: contrato, fecha, credito, multa, f_anula</i>"] -.-> H
    RAW_MRC["Sum current configured service prices per contract<br/><i>sig_detalle_servicio: contrato, cod_servicio, monto_servicio, monto_catalogo</i>"] -.-> H
    RAW_PROMO["Deduct only active promotions: meses_por_aplicar &gt; 0<br/><i>sig_promociones_clientes: contrato, cod_servicio, meses_por_aplicar, porc_descuento</i>"] -.-> H
    RAW_CHANGE["Exclude if service-code portfolio changes in last 5 months<br/><i>hdet_serv: CONTRATO, Anho, Mes, CODIGO_SER</i>"] -.-> I
    RAW_GROSS_ADD["Exclude PREVENTA installations in last 5 months<br/><i>view_reporte_ventas_por_fecha_finanzas: contrato, instalacion, tipo_afili, grupo_servicio</i>"] -.-> I

    classDef raw fill:#EAF3FF,stroke:#2563EB,color:#0F172A,stroke-width:1px;
    classDef default font-size:35px;
    class RAW_ACTIVE,RAW_B2C,RAW_CONSENT,RAW_PHC,RAW_VIP,RAW_MULTIPLE,RAW_HISTORY,RAW_MRC,RAW_PROMO,RAW_CHANGE,RAW_GROSS_ADD raw;
    linkStyle default stroke-width:4px;