
    Z+j$!                       d dl mZ d dlmZmZ d dlmZ d dlmZmZ d dl	m
Z
 d dlmZmZmZ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 G d de          Z G d de          Z G d de          Z G d d e          Zd!S )"    )annotations)datedatetime)Decimal)AnyLiteral)UUID)	BaseModelField
ConfigDictfield_validatorc                  &    e Zd Z ed          ZdS )ApiModelforbid)extraN)__name__
__module____qualname__r   model_config     app/models.pyr   r      s         :H---LLLr   r   c                      e Zd ZU ded<   dZded<   dZded<   dZded	<   dZded
<   dZded<   dZ	ded<   dZ
ded<   dZded<   dZded<   dS )PartyInstrdisplay_nameotherzeLiteral['own_company', 'supplier', 'customer', 'channel', 'warehouse', 'person', 'platform', 'other']
party_typeN
str | None
legal_name
short_nametax_noaddresscontact_personphone_maskedemail_maskednotes)r   r   r   __annotations__r   r    r!   r"   r#   r$   r%   r&   r'   r   r   r   r   r      s         qxJxxxx!J!!!!!J!!!!FG!%N%%%%#L#####L####Er   r   c                      e Zd ZU ded<   dZded<   dZded<   dZded<   dZded<   dZded	<   dZ	ded
<   dZ
ded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dS )	ProductInr   standard_nameNr   sku_coderaw_name_defaultcategoryspecdefault_unit
barcode_69
guobo_codebrandseriesmodelcolor_stylepackage_specDecimal | Nonetax_rate
list_price
cost_pricer'   )r   r   r   r(   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r9   r:   r;   r'   r   r   r   r*   r*      s/        H#'''''HD#L####!J!!!!!J!!!!EFE"K""""#L#####H####!%J%%%%!%J%%%%Er   r*   c                      e Zd ZU ded<   dZded<   dZded<   dZded<   dZded	<   dZded
<   dZ	ded<   dZ
ded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dS )SourceFileInr   original_filenameNr   stored_pathsource_cache_pathsha256z
int | None	byte_size	mime_typer   z~Literal['contract', 'purchase_order', 'supplemental_demand', 'shipment_signoff', 'ledger', 'extraction_csv', 'image', 'other']material_typedatetime | Nonereceived_atsource_platformuploaderreceived_statusoriginal_source_pathbool | Nonefile_existsr'   )r   r   r   r(   r?   r@   rA   rB   rC   rD   rF   rG   rH   rI   rJ   rL   r'   r   r   r   r=   r=   0   s        "K""""$(((((F I     I     NUM  U  U  U  U#'K''''"&O&&&&H"&O&&&&'+++++#K####Er   r=   c                  (   e Zd ZU ded<   dZded<   dZded<    ed          Zd	ed
<    ed          Zd	ed<   dZ	ded<   dZ
ded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<    ed
ddddd          ed                         ZdS )ChannelAllocationInr   standard_channelNr   raw_channelUUID | Nonechannel_party_id0r   original_quantityadjustment_quantityplannedallocation_typer8   planned_quantityconfirmed_quantityshipped_quantitysigned_quantityadjustment_reasonevidence_noter'   c                4    ||dk     rt          d          |S )Nr   zquantity cannot be negative
ValueErrorclsvs     r   non_negative_or_nonez(ChannelAllocationIn.non_negative_or_noneP   s%     =QUU:;;;r   )r   r   r   r(   rP   rR   r   rT   rU   rW   rX   rY   rZ   r[   r\   r]   r'   r   classmethodrd   r   r   r   rN   rN   A   sQ        "K""""$(((((!(----#*73<<////"+O++++'+++++)-----'+++++&*O****$((((( $M$$$$E_()>?QRfgy  {L  M  M  [ M  M  r   rN   c                     e Zd ZU dZded<   ded<   dZded<   ded	<   dZded
<   dZded<   dZded<   dZ	ded<   dZ
ded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<    ee          Zd ed!<    ed	ddddd          ed"                         ZdS )#OrderLineInNrQ   
product_idr   product_name_rawr   product_name_standard_draftr   quantityunitr8   
unit_priceamountmaterialline_external_noproduct_code_rawbarcode_69_rawspec_rawr6   r7   r9   delivery_quantityreceived_quantityreturned_quantityarrival_statusdate | Noneexpected_arrival_startexpected_arrival_endr]   r'   default_factoryzlist[ChannelAllocationIn]channel_allocationsc                4    ||dk     rt          d          |S Nr   z numeric value cannot be negativer_   ra   s     r   rd   z OrderLineIn.non_negative_or_noner   %     =QUU?@@@r   )r   r   r   rh   r(   rj   rl   rm   rn   ro   rp   rq   rr   rs   r6   r7   r9   rt   ru   rv   rw   ry   rz   r]   r'   r   listr}   r   re   rd   r   r   r   rg   rg   X   s        "J"""".22222D!%J%%%%!F!!!!H#'''''#'''''!%N%%%%H"K""""#L#####H####(,,,,,(,,,,,(,,,,,!%N%%%%*.....(,,,,, $M$$$$E5:U45P5P5PPPPP_ZX6IJ]^qrr  [ sr  r   rg   c                  p   e Zd ZU dZded<   dZded<   ded<   dZded	<   dZded
<   dZded<   dZ	ded<   dZ
ded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<    ee          Zd ed!<   dS )"PurchaseOrderInNrQ   
project_iddocument_idznLiteral['downstream_supplier_purchase', 'upstream_customer_order', 'internal_transfer', 'supplemental_demand']
order_sideformal_orderzbLiteral['formal_order', 'contract_order', 'no_document_supplement', 'replenishment', 'adjustment']
order_typebuyer_party_idseller_party_idr   order_norx   
order_dateexternal_contract_nosupplier_contract_no_on_ordercustomer_contract_no_on_ordersettlement_methodry   rz   expected_arrival_textdelivery_addressreceiver_namereceiver_phone_maskedlogistics_companytracking_nopayment_statusfulfillment_statusr'   r{   zlist[OrderLineIn]lines)r   r   r   r   r(   r   r   r   r   r   r   r   r   r   r   ry   rz   r   r   r   r   r   r   r   r   r'   r   r   r   r   r   r   r   r   z   s        "J""""#K####{{{{qJ"&N&&&&#'O''''H"J""""'+++++04!444404!4444$(((((*.....(,,,,,(,,,,,#''''' $M$$$$(,,,,,$((((("K""""!%N%%%%%)))))E$uT:::E::::::r   r   c                  x   e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   dZded<   dZded<   dZded<   dZded<   dZded<   dZ	ded<   dZ
ded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded <   dZded!<   dZded"<    ed
d          ed#                         ZdS )$StockMovementInr	   stock_item_idr   movement_datezLiteral['in', 'out']	directionzLiteral['purchase_in', 'self_stock_in', 'shipment_out', 'claim_out', 'return_in', 'gift_out', 'transfer_out', 'transfer_in', 'adjustment', 'scrap_out']movement_typer   rk   Nr   rl   rQ   handler_party_idcounterparty_idpurposerK   
returnabler8   unit_cost_tax_includedsource_document_idevidence_file_idsource_order_line_idrx   expected_return_dateactual_return_datesignoff_statusr   r   r   r   r   r'   c                4    ||dk     rt          d          |S r   r_   ra   s     r   rd   z$StockMovementIn.non_negative_or_none   r   r   )r   r   r   r(   rl   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r'   r   re   rd   r   r   r   r   r      s        """" b  b  b  bD$(((((#'O''''G"J""""-11111&*****$((((((,,,,,(,,,,,&*****!%N%%%%$((((("K""""#''''' $M$$$$(,,,,,E_Z 899  [ :9  r   r   c                      e Zd ZU dZded<   ded<   ded<   dZded	<   dZded
<   dZded<   dZded<   dZ	ded<   dZ
ded<   dZded<   dZded<   dS )ShipmentLineInNrQ   rh   r   product_namer   rk   r   rl   stock_movement_idpendingz(Literal['pending', 'signed', 'rejected']sign_statusr8   rZ   r[   rejected_quantityrejection_reasonr'   )r   r   r   rh   r(   rl   r   r   rZ   r[   r   r   r'   r   r   r   r   r      s         "J""""D%))))):CKCCCC'+++++&*O****(,,,,,#'''''Er   r   c                  .   e Zd ZU dZded<   dZded<   dZded<   dZded<   dZded	<   d
Z	ded<   dZ
ded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<    ee          Zded<   dS )ShipmentSignoffInNrQ   r   shipper_party_idreceiver_party_idrx   	ship_dater   r   draftz/Literal['draft', 'sent', 'signed', 'cancelled']statusr   r   r   r   r   r   ry   rz   rE   	signed_atsigner_namesigner_contact_maskedr'   r{   zlist[ShipmentLineIn]r   )r   r   r   r   r(   r   r   r   r   r   r   r   r   r   r   r   ry   rz   r   r   r   r'   r   r   r   r   r   r   r   r      sk        "J""""$(((((%)))))!I!!!!G;BFBBBB&*****$((((("K""""#''''' $M$$$$(,,,,,*.....(,,,,,!%I%%%%"K""""(,,,,,E"'%"="="=E======r   r   c                  n    e Zd ZU dZded<   dZded<   dZded	<   dZd
ed<   dZded<   ded<   dZ	d
ed<   dS )ValidationIssueInr   zLiteral['missing_field', 'conflict', 'quantity_mismatch', 'channel_mismatch', 'duplicate_file', 'unknown_product', 'unknown_party', 'negative_stock', 'other']
issue_typewarningz#Literal['info', 'warning', 'error']severityNr   related_tablerQ   
related_id
field_namer   messagesource_file_id)
r   r   r   r   r(   r   r   r   r   r   r   r   r   r   r      s          jqJ  q  q  q  q2;H;;;; $M$$$$"J""""!J!!!!LLL"&N&&&&&&r   r   c                  ,    e Zd ZU dZded<   dZded<   dS )ReconciliationRunInNrQ   r   r   r'   )r   r   r   r   r(   r'   r   r   r   r   r      s4         "J""""Er   r   c                  6    e Zd ZU dZded<   dZded<   ded<   dS )	WriteEnvelopeunknownr   actor_profileNr   idempotency_keyzdict[str, Any]payload)r   r   r   r   r(   r   r   r   r   r   r      s@         "M"""""&O&&&&r   r   N)
__future__r   r   r   decimalr   typingr   r   uuidr	   pydanticr
   r   r   r   r   r   r*   r=   rN   rg   r   r   r   r   r   r   r   r   r   r   <module>r      s   " " " " " " # # # # # # # #                     B B B B B B B B B B B B. . . . .y . . .
 
 
 
 
h 
 
 
       (    8   "    (   .    (   D; ; ; ; ;h ; ; ;6    h   B    X   > > > > > > > >,' ' ' ' ' ' ' '    (   
    H     r   