
    Vj                         d Z ddlmZ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  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)a'  Models for direct, over-the-counter sales and local pricing.

The Mercado Livre sales table represents imported marketplace orders.  Local
sales have a separate header/items structure so a physical receipt can contain
more than one SKU and can be cancelled without touching marketplace records.
    )	BooleanColumnDateTimeFloat
ForeignKeyIntegerStringTextUniqueConstraint)func)Basec                       e Zd ZdZ eed      Z e ed      ddd      Z e ed      d      Z	 e ed	      dd
      Z
 eedd      Z ee ej                               Zy)SalesChannelsales_channelsTprimary_key2   F)nullableuniqueindexx   r      onliner   defaultserver_defaultN)__name__
__module____qualname____tablename__r   r   idr	   keynamechannel_typer   	is_activer   r   now
created_at     D/var/www/hypershopcomercio.com.br/hyper-ai/app/models/local_sales.pyr   r      sk    $M	T	*B
eD
EC&+.D&*uhGLw=I<Jr+   r   c                      e Zd ZdZ eed      Z e ed      dd      Z e ed      ddd	      Z	 e ed      dd      Z
 eed
      Z eedd      Z eedd      Z eedd      Z eedd      Z e ed      dd      Z eed
      Z ee ej.                          ej.                               Z ee ej.                               Z eddd      fZy)LocalProductPricelocal_product_pricesTr      Fr   r   r   localr   r   r   r   g      $@r           r   ready)r   onupdater   skuchannel_key"uq_local_product_price_sku_channel)r%   N)r   r    r!   r"   r   r   r#   r	   r7   r8   ad_idr   selling_pricetarget_margin_percentcalculated_costtax_rate_percentr   is_manual_pricestatusr
   notesr   r   r(   
updated_atr)   r   __table_args__r*   r+   r,   r.   r.      s    *M	T	*B
uD
9CeWDQK6#;T:E551M"55$GUUC@OeeSAWueDOF2J@F4$'EhdhhjQJ<J 	4XYNr+   r.   c                      e Zd ZdZ e ed      d      Z e ed      ddd      Z e ed	      d
      Z e ed      d
      Z	 ee
dd      Z ee
dd      Z ee
dd      Z e ed      ddd      Z eed
      Z eed ej&                         d      Z eed
      Z ee ej&                               Zy)	LocalSalelocal_sales@   Tr   r   Fr2   r3   r0   r   P   r4   r   r   	completed)r   r   r   r   N)r   r    r!   r"   r   r	   r#   r8   customer_namepayment_methodr   subtotaldiscount_amounttotal_amountr@   r
   rA   r   r   r(   completed_atcancelled_atr)   r*   r+   r,   rE   rE   /   s    !M	r
	-BeWDQK6#;6MF2J6NeeS9HUUC@O%%=LF2J4PF4$'E(U8488:UYZL(T2L<Jr+   rE   c                      e Zd ZdZ eed      Z e ed       ed      dd      Z	 e ed      dd      Z
 e ed	      d
      Z e ed      d
      Z e ed      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d      Z eed
      Z ee ej0                               Zy)LocalSaleItemlocal_sale_itemsTr   rG   zlocal_sales.idFr1   r0   i  r   r4   r   r   N)r   r    r!   r"   r   r   r#   r	   r   sale_idr7   product_nametiny_product_idr:   quantityr   
unit_price	unit_costr<   r>   
tax_amount
line_totalr   r   r(   r)   r*   r+   r,   rR   rR   @   s    &M	T	*BVBZ,<!=UYZG
uD
9C&+6LVC[48O6#;.Eg.H.Juuc:I"55#FeeSAs;J.J<Jr+   rR   c                   ^   e Zd ZdZ e ed      d      Z e ed      dd      Z e ed      dd      Z ee	d	      Z
 ee	d	      Z ee	d	      Z e ed      d	      Z e ed      dd      Z e ed
      ddd      Z eed	      Z ee ej(                         d      Zy)InventoryMovementinventory_movementsrG   Tr   r0   Fr1   r   r   r   pendingr3   )r   r   N)r   r    r!   r"   r   r	   r#   r7   movement_typer   quantity_deltaquantity_beforequantity_afterreference_typereference_idsync_statusr
   rA   r   r   r(   r)   r*   r+   r,   r]   r]   S   s    )M	r
	-B
uD
9C6":TBMGe4NWu5OGe4NF2J7N&*uDALeYdSK4$'E4HJr+   r]   N)__doc__
sqlalchemyr   r   r   r   r   r   r	   r
   r   sqlalchemy.sqlr   app.core.databaser   r   r.   rE   rR   r]   r*   r+   r,   <module>rk      sZ    m l l  "=4 = ,= ="=D =&I Ir+   