
    ;&i                     \    d Z ddlZddlZddlZddlZddlmZmZ 	 d	ded   dee   defdZ	y)
z.
ID Generation utilities for the application.
    N)OptionalLiteralid_typecustomeruinmerchantusertransactioninvoicecontactnamereturnc           	         dddddddd}| |vr(t        d	|  d
t        |j                                      ||    }dt        |      z
  }| dv r|r|j	                  dd      j                         dd }t        |      dk  r|j                  dd      }|}t        t        t        j                         dz              dd }t        j                         j                  dd j                         }| | | | }	nct        t        t        j                         dz              dd }t        j                         j                  dd j                         }| | | }	t        |	      dk7  rt        d|	 dt        |	       d      |	S )u;  Generate a unique ID based on the specified type.
    
    All generated IDs are guaranteed to be exactly 15 characters long.
    
    Args:
        id_type: The type of ID to generate ('customer', 'uin', 'merchant', 'user', 'transaction', 'invoice', 'contact')
        name: Optional name to base the ID on
        
    Returns:
        A unique alphanumeric ID with the appropriate prefix and format (exactly 15 characters)
        
    Examples:
        generate_id('customer', 'John Doe') → 'ACCJOH123456789' (15 chars)
        generate_id('uin', 'Jane Smith') → 'UINJAN1234567890' (15 chars)
        generate_id('merchant', 'Test Corp') → 'MERTES123456789' (15 chars)
        generate_id('contact', 'John Doe') → 'CONJOH123456789' (15 chars)
        generate_id('transaction') → 'TXN12345678ABCD' (15 chars)
    ACCUINMERUSRTXNINVCONr   zUnsupported ID type: z. Supported types:    )r   r   r	   r
   r     N   Xi  ii   zGenerated ID 'z' has length z, expected 15 characters.)
ValueErrorlistkeyslenreplaceupperljuststrinttimeuuiduuid4hex)
r   r   prefixesprefixremaining_lengthstripped_name	name_parttimestamp_part	uuid_partgenerated_ids
             P/var/www/html/hwPaymentPortal-be-dev/hw-payment-portal-api/src/core/functions.pygenerate_idr4      s   0 H h0	9LTRZR_R_RaMbLcdeegFCK' DDS"-335bq9}!)//37M!	 St!345bc:JJL$$Ra(..0	 )^,<YKH St!345bc:JJL$$Ra(..0	 .!1)= <B>,}SEVDWWpqrr    )N)
__doc__stringrandomr(   r'   typingr   r   r%   r4    r5   r3   <module>r;      sM        $
 A_`A
3-A 	Ar5   