
    >:hE                         d dl mZ d dlmZmZmZmZ d dlmZ d dl	Z	d Z
 G d dej                  Z G d d	ej                  ZdS )
    )models)UnidadMedidaClasificacionProductoGrupoProductoSubgrupoProducto)slugifyNc                 v    t          | j        j                  }t          j                            d||          S )Nreferencias_images)r   
referenciaskuospathjoin)instancefilenamesku_slugs      ;C:\Users\a_gir\Desktop\Interacto\siip\referencias\models.pyreferencia_image_upload_pathr   
   s.    x*.//H7<<,hAAA    c                   x   e Zd Zg dZg dZddgZ ej        ddd          Z ej	        d	
          Z
 ej        eej        d          Z ej        dddd          Z ej        ded          Z ej        ded          Z ej        eej        d          Z ej        eej        d          Z ej        eej        d          Z ej        ded          Z ej        dd          Z ej        dddd          Z ej        dddd          Zd  Z G d! d"          Zd# Z e!d$             Z"d%S )&
Referencia))MPzMateria Prima)PPzProducto en Proceso)PTzProducto Terminado))AzA - Alta prioridad)BzB - Media prioridad)CzC - Baja prioridad)MTAz&Make to Availability (Stock constante))MTOzMake to Order (Bajo pedido)2   Tu
   SKU único)
max_lengthuniqueverbose_nameu   Descripción completa)r#   zUnidad de medida)	on_deleter#         r   zStock disponible)
max_digitsdecimal_placesdefaultr#      zTipo de referencia)r!   choicesr#      u   Clasificación ABCu   ClasificaciónGrupoSubgrupo   zTipo de abastecimientoActivo)r)   r#   zPrecio de costo actualzPrecio de venta unitarioc                     ddl m} | j        dv r8 ||           }|r-|| j        k    r$|| _        |                     dg           d S d S d S d S )Nr   )costo_desde_bom)r   r   precio_costo)update_fields)
siip.utilsr2   tipor3   save)selfr2   nuevos      r   refresh_precio_costozReferencia.refresh_precio_costoY   s    ......9###OD))E :$"333$)!		(8	99999	 $#: :33r   c                       e Zd ZdZdZdgZdS )Referencia.Metar   Referenciasr   N)__name__
__module____qualname__r#   verbose_name_pluralordering r   r   Metar<   b   s         #+7r   rD   c                 4    | j          d| j        d d          S )Nz - r    )r   descripcionr8   s    r   __str__zReferencia.__str__g   s$    (66t/4666r   c                 4    | j                                         S )z2Devuelve la primera imagen asociada como principal)imagenesfirstrG   s    r   imagen_principalzReferencia.imagen_principalj   s     }""$$$r   N)#r>   r?   r@   TIPO_REFERENCIA_CHOICESSKU_ABC_CHOICESTIPO_ABASTECIMIENTO_CHOICESr   	CharFieldr   	TextFieldrF   
ForeignKeyr   PROTECTunidadDecimalFieldstockr6   sku_abcr   clasificacionr   grupor   subgrupotipo_abastecimientoBooleanFieldactivor3   precio_venta_unitarior:   rD   rH   propertyrL   rC   r   r   r   r      si           O 	:.#
 &
bL
Q
Q
QC"&"0GHHHKV.'  F
  F'	  E 6')  D
 f)  G
 &F%.%  M
 F.  E
 !v .  H
 +&*+-  
 !V HEEEF&6&-	  L 0F//	  : : :       
7 7 7 % % X% % %r   r   c                       e Zd Z ej        eej        dd          Z ej        e	d          Z
 G d d          Zd Zd	S )
ReferenciaImagenrJ   zReferencia asociada)r$   related_namer#   zArchivo de imagen)	upload_tor#   c                   <    e Zd ZdZdZ ej        dg          gZdS )ReferenciaImagen.MetazImagen de referenciau   Imágenes de referenciasr   )fieldsN)r>   r?   r@   r#   rA   r   IndexindexesrC   r   r   rD   re   {   s4        -8FL///
r   rD   c                      d| j         j         S )NzImagen para )r   r   rG   s    r   rH   zReferenciaImagen.__str__   s    3do1333r   N)r>   r?   r@   r   rR   r   CASCADEr   
ImageFieldr   imagenrD   rH   rC   r   r   ra   ra   o   s        "".*	  J V.(  F

 
 
 
 
 
 
 
4 4 4 4 4r   ra   )	django.dbr   listas_configuracion.modelsr   r   r   r   django.utils.textr   r   r   Modelr   ra   rC   r   r   <module>rq      s                     & % % % % % 				B B B
^% ^% ^% ^% ^% ^% ^% ^%@4 4 4 4 4v| 4 4 4 4 4r   