
    -6i;                     :   d Z ddlmZ ddlmZmZmZ ddlmZ ddlm	Z	m
Z
mZmZmZ ddlmZ ddlmZ ddlmZ  G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zy)z3
Product schema definitions for common operations.
    )datetime)OptionalListUnion)Query)Field
ConfigDictfield_validatormodel_validator	BaseModel)
BaseSchema)FileResponseSchema)ProductTypesc                       e Zd ZU dZ edd      Zeed<    eddd      Zeed	<    edd
      Z	eed<    edd      Z
ee   ed<    edd      Zee   ed<    edd      Zeed<    edd      Zee   ed<   y)ProductCategoryBasezBase product category schema..zCategory namedescriptionname   zCategory code
max_lengthr   codezCategory slugslugNzCategory descriptionr   zCategory display orderorderTzWhether the category is active	is_activezParent category ID	parent_id)__name__
__module____qualname____doc__r   r   str__annotations__r   r   r   r   r   intr   boolr        ^/var/www/html/hwPaymentPortal-be-dev/hw-payment-portal-api/src/apps/products/schemas/common.pyr   r      s    'c7D#7ccGD#Gc7D#7!&t9O!PK#P 3KLE8C=LD.NOItO$T7KLIx}Lr&   r   c                       e Zd ZU dZ ed      Z edd      Zee	d<    edd	      Z
ee   e	d
<    edd      Zee	d<    edd      Zee   e	d<    edd      Zee   e	d<   y)ProductCategoryResponseSchemaz!Product category response schema.Tfrom_attributes.zCategory's unique identifierr   idNAssociated merchant IDmerchant_idzWhen the category was created
created_atz"When the category was last updated
updated_atz"When the category was soft deleted
deleted_at)r   r   r   r    r	   model_configr   r,   r#   r"   r.   r   r/   r   r0   r1   r%   r&   r'   r)   r)      sw    +d3LC%CDBD!&t9Q!RK#R 2QRJR%*4=a%bJ"b%*4=a%bJ"br&   r)   c                   F   e Zd ZU dZ edd      Zeed<    edd      Zeed<    edd	      Z	e
e   ed
<    eddd      Zeed<    eddd      Ze
e   ed<    edd      Ze
e   ed<    edd      Zeed<    edd      Zeed<    edd      Ze
e   ed<    edd      Zeed<    edd      ed                Zed!efd"       Z edd#      Ze
e   ed$<    eddd%      Ze
e   ed&<    edd'      Ze
e   ed(<    edd)      Ze
e   ed*<    edd+      Ze
e   ed,<    ed-dd.      Zeed/<    edd0      Z e
e   ed1<    eddd2      Z!e
e   ed3<    edd4      Z"e
e   ed5<    edd6      Z#e
e   ed7<    edd8      Z$e
e   ed9<    ed-dd:      Z%eed;<    eddd<      Z&e
e   ed=<    eddd>      Z'e
e   ed?<    eddd@      Z(e
e   edA<    edddB      Z)e
e   edC<    edddD      Z*e
e   edE<    eddF      Z+e,edG<    eddH      Z-e
e,   edI<   y)JProductBasez'Base product schema with common fields..Product namer   r   zProduct SKU (unique)skuNProduct coder   r   Product unit priceger   
unit_priceProduct sale price
sale_priceProduct descriptionr   TWhether the product is activer   F$Whether the product is marked as newis_new$Date until product is considered new	new_untilproduct!Item type: 'service' or 'product'	item_typebeforemodec                     t        |t              r-|j                         dv r|j                         S t        d      t        |t              r|t        j
                  k(  rdS dS t        d      z.Validate and normalize item type to lowercase.servicerD   (Item type must be 'service' or 'product'rM   rD   
isinstancer!   lower
ValueErrorr   SERVICEclsvs     r'   validate_item_typezProductBase.validate_item_type5   sc     awwy22wwy  !KLL<( !\%9%9 99HyHGHHr&   returnc                     | j                   S z%Get human-readable item type display.rF   selfs    r'   type_displayzProductBase.type_displayC        ~~r&   Whether product is for purchaseis_purchasePurchase MSRPpurchase_msrp Purchase manufacture part number purchase_manufacture_part_numberPurchase supplier SKUpurchase_supplier_skuPurchase descriptionpurchase_descriptiong        Calculated purchase tax ratecalculated_purchase_tax_rateWhether product is for sellis_sell	Sell MSRP	sell_msrpSell manufacture part numbersell_manufacture_part_numberSell supplier SKUsell_supplier_skuSell descriptionsell_descriptionCalculated sell tax ratecalculated_sell_tax_rateProduct lengthlengthProduct heightheightProduct widthwidthProduct weightweightProduct depthdepthProduct category IDcategory_idr-   r.   ).r   r   r   r    r   r   r!   r"   r6   r   r   r;   floatr=   r   r   r$   rA   rC   r   rF   r
   classmethodrW   propertyr^   ra   rc   re   rg   ri   rk   rm   ro   rq   rs   ru   rw   ry   r{   r}   r   r   r   r#   r.   r%   r&   r'   r4   r4   '   s   1c~6D#6S&<=C=.AD(3-Aca5IJJJ"'@T"UJU!&t9N!OK#OD.MNItN,RSFDS$)$<b$cIx!c92UVIsV[x0
I  1
I c  
 #(;\"]K$]%*4A?%SM8E?S6;DNp6q$hsmq+0CZ+[8C=[*/BX*Y(3-Y*/Hf*g %g $E7TUGXd^U!&t{!KIxK27Jh2i (3-i',T?R'Sx}S&+D>P&QhsmQ&+DQD^&_e_ $DQ<LMFHUOM#DQ<LMFHUOM"4A?KE8E?K#DQ<LMFHUOM"4A?KE8E?K S.CDKD!&t9Q!RK#Rr&   r4   c                   l   e Zd ZU dZ ed      Z edd      Zee	d<    edd      Z
ee	d	<    edd
      Zee	d<    edd      Zee	d<    edd      Zee   e	d<    edd      Zee   e	d<    edd      Zee   e	d<    edd      Zee   e	d<    edd      Zeee      e	d<   edefd       Zy)ProductResponseSchemazProduct response schema.Tr*   .Product's unique identifierr   r,   Product slugr   rE   rF   When the product was createdr/   Nz!When the product was last updatedr0   z!When the product was soft deletedr1   Product categorycategoryProduct thumbnail image	thumbnailzProduct attachment filesproduct_attachmentsrX   c                     | j                   S rZ   r[   r\   s    r'   r^   z"ProductResponseSchema.type_displayu   r_   r&   )r   r   r   r    r	   r2   r   r,   r#   r"   r   r!   rF   r/   r   r0   r   r1   r   r)   r   r   r   r   r   r^   r%   r&   r'   r   r   d   s    "d3LC%BCBCc~6D#63,OPIsP 2PQJQ%*4=`%aJ"a%*4=`%aJ"a 9>dPb8cHh45c.3DF_.`Ix*+`>CDVp>q$'9":;qc  r&   r   c                       e Zd ZU dZ eddd      Zeed<    eddd      Zeed<    ed	
      Z	e
ee      ed<    edd
      Ze
e   ed<   y)ProductCreateSchemaz"Schema for creating a new product..  zProduct name (required)r   r   z!Product SKU (required and unique)r6   z)Uploaded file ids of optional attachmentsr   attachmentsNzThumbnail id of the attachmentr   )r   r   r   r    r   r   r!   r"   r6   r   r   r   r#   r   r%   r&   r'   r   r   {   sd    , cc7PQD#QSS6YZCZ',?(K$s)$   %T7WXIx}Xr&   r   c                      e Zd ZU dZ eddd      Zee   ed<    eddd      Z	ee   ed<    edd	
      Z
ee   ed<    eddd      Zee   ed<    eddd      Zee   ed<    edd
      Zee   ed<    edd
      Zee   ed<    edd
      Zee   ed<    edd
      Zee   ed<    edd
      Zee   ed<    edd
      Zee   ed<    eddd      Zee   ed<    edd 
      Zee   ed!<    edd"
      Zee   ed#<    edd$
      Zee   ed%<    eddd&      Zee   ed'<    edd(
      Zee   ed)<    eddd*      Zee   ed+<    edd,
      Zee   ed-<    edd.
      Zee   ed/<    edd0
      Zee   ed1<    eddd2      Z ee   ed3<    eddd4      Z!ee   ed5<    eddd6      Z"ee   ed7<    eddd8      Z#ee   ed9<    eddd:      Z$ee   ed;<    eddd<      Z%ee   ed=<    edd
      Zee   ed<    eddd      Zee   ed<    edd 
      Zee   ed!<    edd"
      Zee   ed#<    edd$
      Zee   ed%<    eddd&      Zee   ed'<    edd(
      Zee   ed)<    eddd*      Zee   ed+<    edd,
      Zee   ed-<    edd.
      Zee   ed/<    edd0
      Zee   ed1<    eddd2      Z ee   ed3<    eddd4      Z!ee   ed5<    eddd6      Z"ee   ed7<    eddd8      Z#ee   ed9<    eddd:      Z$ee   ed;<    eddd<      Z%ee   ed=<    edd>
      Z&ee'   ed?<    edd@
      Z(ee'   edA<    e)ddBC      e*dD               Z+y)EProductUpdateSchemazVSchema for updating product information - all fields are optional for partial updates.Nr   r5   r   r   Product SKUr6   r7   r   r   r   r8   r9   r;   r<   r=   r>   r   r?   r   r@   rA   rB   rC   rE   rF   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   r   r-   r.   rG   rH   c                     ||S t        |t              r-|j                         dv r|j                         S t        d      t        |t              r|t        j
                  k(  rdS dS t        d      rK   rO   rT   s     r'   rW   z&ProductUpdateSchema.validate_item_type   sm     9Hawwy22wwy  !KLL<( !\%9%9 99HyHGHHr&   ),r   r   r   r    r   r   r   r!   r"   r6   r   r;   r   r=   r   r   r$   rA   rC   r   rF   ra   rc   re   rg   ri   rk   rm   ro   rq   rs   ru   rw   ry   r{   r}   r   r   r   r#   r.   r
   r   rW   r%   r&   r'   r   r      s^   `  .QD(3-QtOC#O.AD(3-A"'@T"UJU"'@T"UJU!&t9N!OK#O %d8W XIx~X"45[\FHTN\$)$<b$cIx!c$T7Z[Ix}[ #(:["\K$\%*4A?%SM8E?S6;DNp6q$hsmq+0CZ+[8C=[*/BX*Y(3-Y49$1Rp4q (5/q $D6STGXd^T!&t{!KIxK27Jh2i (3-i',T?R'Sx}S&+D>P&QhsmQ05dqNh0ihuoi $DQ<LMFHUOM#DQ<LMFHUOM"4A?KE8E?K#DQ<LMFHUOM"4A?KE8E?K #(:["\K$\%*4A?%SM8E?S6;DNp6q$hsmq+0CZ+[8C=[*/BX*Y(3-Y49$1Rp4q (5/q $D6STGXd^T!&t{!KIxK27Jh2i (3-i',T?R'Sx}S&+D>P&QhsmQ05dqNh0ihuoi $DQ<LMFHUOM#DQ<LMFHUOM"4A?KE8E?K#DQ<LMFHUOM"4A?KE8E?K "'t9N!OK#O!&t9Q!RK#R[x0I  1Ir&   r   c                      e Zd ZU dZ ed      Z edd      Zee	d<    edd      Z
ee	d	<    edd
      Zee	d<    edd      Zee	d<    edd      Zee   e	d<    edd      Zee   e	d<    edd      Zee	d<    edd      Zee	d<    edd      Zee	d<    edd      Zee   e	d<    edd      Zee   e	d<    edd      Zee	d<   edefd        Zy)!ProductListItemSchemaz)Simplified product schema for list views.Tr*   .r   r   r,   r5   r   r   r6   r   r   Nr8   r;   r<   r=   r?   r   r@   rA   rE   rF   r   r   r   r   r   r/   rX   c                     | j                   S rZ   r[   r\   s    r'   r^   z"ProductListItemSchema.type_display   r_   r&   )r   r   r   r    r	   r2   r   r,   r#   r"   r   r!   r6   r   r;   r   r   r=   r   r$   rA   rF   r   r)   r   r   r/   r   r   r^   r%   r&   r'   r   r      s   3d3LC%BCBCc~6D#6Sm4C4c~6D#6"':N"OJO"':N"OJOC-LMItM*PQFDQ3,OPIsP8=dPb8cHh45c.3DF_.`Ix*+` 2PQJQc  r&   r   c                   ^    e Zd ZU dZ eddd      Zee   ed<    e	d      e
d               Zy)	ProductBulkDeleteSchemaz"Schema for bulk deleting products..   zList of product slugs to delete)
min_lengthr   slugsc                 R    |st        d      t        |      dkD  rt        d      |S )zValidate product slugs list.z%At least one product slug is requiredd   z,Cannot delete more than 100 products at once)rR   lenrT   s     r'   validate_slugsz&ProductBulkDeleteSchema.validate_slugs   s/     DEEq6C<KLLr&   N)r   r   r   r    r   r   r   r!   r"   r
   r   r   r%   r&   r'   r   r      s<    ,SQ<]^E49^W  r&   r   c                      e Zd ZU dZ edd      Zee   ed<    edd      Z	ee   ed<    edd      Z
ee   ed	<    edd
      Zee   ed<    edd      Zee   ed<    edd      Zee   ed<    edd      Zeed<    edd      Zeed<    edd      Zeed<    edd      Zeed<    edd      Zee   ed<    ed      Zee   ed<    ed      ed               Z edddd      ed               Zy)ProductListFilterSchemaz*Schema for filtering product list queries.Nz*Search across name, sku, code, descriptionr   searchzFilter by product namer   zFilter by SKUr6   zFilter by coder   zFilter by category IDr   zFilter by merchant IDr.   r   z6Filter by active status (0=all, 1=active, -1=inactive)r   z/Filter by new status (0=all, 1=new, -1=not new)rA   z>Filter by purchase status (0=all, 1=purchase, -1=not purchase)ra   z2Filter by sell status (0=all, 1=sell, -1=not sell)rm   z+Filter by item type: 'service' or 'product'rF   )defaultcost_price_rangec                 h    ||j                         dvrt        d      |r|j                         S |S )zValidate item type filter.rL   rN   )rQ   rR   rT   s     r'   rW   z*ProductListFilterSchema.validate_item_type  s6     =QWWY.DDGHHqwwy$1$r&   c                 $    |dvrt        d      |S )zValidate boolean filter values.)r   r   z8Boolean filters must be -1 (false), 0 (all), or 1 (true))rR   rT   s     r'   validate_boolean_filtersz0ProductListFilterSchema.validate_boolean_filters  s     JWXXr&   )r   r   r   r    r   r   r   r!   r"   r   r6   r   r   r#   r.   r   rA   ra   rm   rF   r   r   r
   r   rW   r   r%   r&   r'   r   r     sA   4!$4`aFHSMa2JKD(3-KtAC#A2BCD(3-C!&t9P!QK#Q!&t9P!QK#Q1*bcIsc'XYFCYQ,lmKm(\]GS]$T7deIx}e&+D&9hsm9[!%  "% [(M9E  Fr&   r   N)r    r   typingr   r   r   fastapi.paramsr   pydanticr   r	   r
   r   r   src.apps.base.schemas.commonr   "src.apps.files.schemas.file_commonr   src.core.utils.enumsr   r   r)   r4   r   r   r   r   r   r   r%   r&   r'   <module>r      s     ( (   S S 3 A -	M* 	M	c$7 	c:S* :SzK .	Y+ 	YPI* PIfJ 0j  i r&   