
    u(i#                     $   d dl mZmZmZ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y# e$ r	 d dlmZ Y fw xY w)    )ColumnIntegerStringFloatText
ForeignKeyDateTimeBoolean)relationship)func)Basec                   
   e Zd ZdZdZ eeddd      Z eeddd      Z e e	d      d      Z
 e ed	       ej                         
      Z e ed	       ej                          ej                               Zd Zy)Companyz*Company model to store company information	companiesTprimary_keyindexautoincrementFuniquenullabler      r   timezoneserver_defaultr   onupdatec                 V    d| j                    d| j                   d| j                   dS )Nz<Company(id=z, company_id=, name='')>)id
company_idcompany_nameselfs    G/var/www/html/hubwallet-dev/src/smart_inventory/apps/products/models.py__repr__zCompany.__repr__   .    dggYmDOO3DHTM^M^L__bcc    N)__name__
__module____qualname____doc____tablename__r   r   r#   r$   r   r%   r	   r   now
created_at
updated_atr)    r+   r(   r   r   
   s    4M	TT	JBuDIJ&+6L$/
KJ$/
U]UYU]U]U_`Jdr+   r   c                      e Zd ZdZdZ eeddd      Z ee ed      dd      Z	 eeddd      Z
 e ed	      d
      Z e ed      d
      Z eed
      Z e ed      d
      Z ee ed      d
      Z eed      Z eed      Z eed      Z eed      Z e ed      d
      Z e ed       ej4                               Z e ed       ej4                          ej4                               Z ede	g      Z edd      Z eddd      Z  eddd      Z! eddd      Z"d Z#y)Productz*Product model to store product informationproductsTr   companies.company_idFr   r   r   i  r   r   zcategories.category_id)defaulti  r   r   r   r   foreign_keysCategoryback_populatesProductVendorproductall, delete-orphanr?   cascadeProductLocationProductPricec                 V    d| j                    d| j                   d| j                   dS )Nz<Product(id=, product_id=r!   r"   )r#   
product_idproduct_namer&   s    r(   r)   zProduct.__repr__:   r*   r+   N)$r,   r-   r.   r/   r0   r   r   r#   r   r$   rI   r   rJ   
short_namer   description
brand_namefk_product_category_idr
   eligible_for_returndisplay_on_posdisplay_on_online_storeis_perishable
image_pathr	   r   r1   r2   r3   r   companycategoryproduct_vendorsproduct_locationsproduct_pricesr)   r4   r+   r(   r6   r6      sk   4M	TT	JB,B!Ce[_`JuDIJ&+6Lsd3J-Ksd3J#GZ8P-Q\`a !%8GU3N$We<7E2M tt4J$/
KJ$/
U]UYU]U]U_`J 9J<@GJzBH"?9VjkO$%6yZno!.ThiNdr+   r6   c                   X   e Zd ZdZdZ eeddd      Z ee ed      dd      Z	 eeddd      Z
 e ed	      d
      Z e ed       ej                               Z e ed       ej                          ej                               Z ede	g      Z edd      Zd Zy)r=   z4Category model to store product category information
categoriesTr   r8   Fr9   r   r   r   r   r   r   r   r;   r6   rU   r>   c                 V    d| j                    d| j                   d| j                   dS )Nz<Category(id=z, category_id=r!   r"   )r#   category_idcategory_namer&   s    r(   r)   zCategory.__repr__N   1    twwi~d6F6F5GxPTPbPbOccfggr+   N)r,   r-   r.   r/   r0   r   r   r#   r   r$   r\   r   r]   r	   r   r1   r2   r3   r   rT   r7   r)   r4   r+   r(   r=   r=   >   s    > M	TT	JB,B!Ce[_`JTJK6#;7M$/
KJ$/
U]UYU]U]U_`J 9J<@GIjAHhr+   r=   c                   6   e Zd ZdZdZ eeddd      Z ee ed      dd      Z	 eeddd      Z
 ee ed	      dd      Z ee ed
      dd      Z eed      Z eed      Z eed      Z eed      Z eedd      Z e ed      d      Z e ed      d      Z e ed       ej0                               Z e ed       ej0                          ej0                               Z ede	g      Z edd      Z ed      Zd Zy)rF   z.Product prices table for location-wise pricingrX   Tr   r8   Fr9   r   products.product_idlocations.location_idr   r   )r   r:   2   r   r   r   r   r;   r6   r>   Locationc                 V    d| j                    d| j                   d| j                   dS )Nz<ProductPrice(id=rH   , location_id=)>)r#   rI   location_idr&   s    r(   r)   zProductPrice.__repr__m   s/    "477)=8IX\XhXhWiikllr+   N) r,   r-   r.   r/   r0   r   r   r#   r   r$   product_price_idrI   rg   r   cost_price_per_unitmarkup_valuemargin_valueretail_price_excl_taxcompare_at_pricer   markup_type_namemargin_type_namer	   r   r1   r2   r3   r   rT   rA   locationr)   r4   r+   r(   rF   rF   R   sD   8$M	TT	JB,B!Ce[_`JgdU$O,A!BUZ^_J*-D"EPU]abK !6%$/L%$/L"548edA>fRj48fRj48$/
KJ$/
U]UYU]U]U_`J 9J<@G95EFGJ'Hmr+   rF   c                   Z   e Zd ZdZdZ eeddd      Z ee ed      dd      Z	 eeddd      Z
 e ed	      d
      Z e ed       ej                               Z e ed       ej                          ej                               Z ede	g      Z eddd      Zd Zy)rc   z,Location model to store location information	locationsTr   r8   Fr9   r   r   r   r   r   r   r   r;   rE   rp   rB   rC   c                 V    d| j                    d| j                   d| j                   dS )Nz<Location(id=re   r!   r"   )r#   rg   location_namer&   s    r(   r)   zLocation.__repr__   r^   r+   N)r,   r-   r.   r/   r0   r   r   r#   r   r$   rg   r   rt   r	   r   r1   r2   r3   r   rT   rW   r)   r4   r+   r(   rc   rc   q   s    6M	TT	JB,B!Ce[_`JTJK6#;7M$/
KJ$/
U]UYU]U]U_`J 9J<@G$%6z[ophr+   rc   c                   z   e Zd ZdZdZ eeddd      Z ee ed      dd      Z	 eeddd      Z
 e ed	      d
      Z e ed      d
      Z e ed       ej                                Z e ed       ej                           ej                                Z ede	g      Z eddd      Zd Zy)Vendorz(Vendor model to store vendor informationvendorsTr   r8   Fr9   r   r   r   d   r   r   r   r   r;   r@   vendorrB   rC   c                 V    d| j                    d| j                   d| j                   dS )Nz<Vendor(id=, vendor_id=r!   r"   )r#   	vendor_idvendor_namer&   s    r(   r)   zVendor.__repr__   s.    TWWI\$..1A$JZJZI[[^__r+   N)r,   r-   r.   r/   r0   r   r   r#   r   r$   r|   r   r}   vendor_coder	   r   r1   r2   r3   r   rT   rV   r)   r4   r+   r(   rv   rv      s    2M	TT	JB,B!Ce[_`Jwte4HIu5Kt4K$/
KJ$/
U]UYU]U]U_`J 9J<@G"?8UijO`r+   rv   c                      e Zd ZdZdZ eeddd      Z ee ed      dd      Z	 ee ed      d	      Z
 ee ed
      d	      Z e ed       ej                               Z ede	g      Z edd      Z edd      Zd Zy)r@   z6Many-to-many relationship between products and vendorsrV   Tr   r8   Fr9   r`   r   zvendors.vendor_idr   r   r   r;   r6   r>   rv   c                 <    d| j                    d| j                   dS )Nz<ProductVendor(product_id=r{   rf   )rI   r|   r&   s    r(   r)   zProductVendor.__repr__   s"    +DOO+<LHXXZ[[r+   N)r,   r-   r.   r/   r0   r   r   r#   r   r$   rI   r|   r	   r   r1   r2   r   rT   rA   ry   r)   r4   r+   r(   r@   r@      s    @%M	TT	JB,B!Ce[_`J,A!BUSJw
+> ?%PI$/
KJ 9J<@G95FGG(3DEF\r+   r@   c                      e Zd ZdZdZ eeddd      Z ee ed      dd      Z	 ee ed      d	      Z
 ee ed
      d	      Z e ed       ej                               Z ede	g      Z edd      Z edd      Zd Zy)rE   z8Many-to-many relationship between products and locationsrW   Tr   r8   Fr9   r`   r   ra   r   r   r   r;   r6   r>   rc   c                 <    d| j                    d| j                   dS )Nz<ProductLocation(product_id=re   rf   )rI   rg   r&   s    r(   r)   zProductLocation.__repr__   s$    -doo->nTM]M]L^^`aar+   N)r,   r-   r.   r/   r0   r   r   r#   r   r$   rI   rg   r	   r   r1   r2   r   rT   rA   rp   r)   r4   r+   r(   rE   rE      s    B'M	TT	JB,B!Ce[_`J,A!BUSJ*-D"EPUVK$/
KJ 9J<@G95HIGJ7JKHbr+   rE   N)
sqlalchemyr   r   r   r   r   r   r	   r
   sqlalchemy.ormr   sqlalchemy.sqlr   src.utils.dbr   ImportErrorutils.dbr   r6   r=   rF   rc   rv   r@   rE   r4   r+   r(   <module>r      s    Z Z Z ' !
dd d !dd !dHht h(m4 m>ht h(`T `*\D \(bd bQ  s   B BB