o
    ȟ1iH
                     @   s<  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
 d dlmZ d dlmZ d dlmZmZmZ d dlmZ G d	d
 d
eZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd  d eZ d!S )"    )date)ListAny)Optional)	BaseModelField
ConfigDictmodel_validator)
joinedload)get_db)ParticipantUserCourse)GenericResponsec                   @   s8   e Zd ZU eed< eed< eed< eddZeed< dS )BursaryDiscountInfoacademic_year_id
start_dateend_dateFdefault
is_enabledN)	__name__
__module____qualname__int__annotations__r   r   r   bool r   r   /app/schema/bursary_discount.pyr      s
   
 r   c                   @       e Zd ZU eed< eddZdS )AcademicYeartitleTfrom_attributesN)r   r   r   strr   r   model_configr   r   r   r   r          
 r    c                   @   sR   e Zd ZU eed< eed< eed< eed< eddZeed< e	ed< e
d	d
ZdS )BursaryDiscountInstanceidr   r   r   Fr   r   academic_yearTr"   N)r   r   r   r   r   r   r   r   r   r    r   r%   r   r   r   r   r'      s   
 r'   c                   @      e Zd ZU ee ed< dS )BursaryDiscountInfoListResponsedataN)r   r   r   r   r'   r   r   r   r   r   r+   #      
 r+   c                   @   r   )BursaryDiscountInfoResponser(   Tr"   N)r   r   r   r   r   r   r%   r   r   r   r   r.   '   r&   r.   c                   @   s   e Zd ZU eed< dS )BursaryDiscountInfoUpdateSchemar(   N)r   r   r   r   r   r   r   r   r   r/   ,   s   
 r/   c                   @   s"   e Zd ZU eed< ee ed< dS )CreateBursaryApplicationr   participant_idN)r   r   r   r   r   r   r   r   r   r   r0   0      
 r0   c                   @   sF   e Zd ZU eed< eed< dZee ed< eed< dZee	 ed< dS )ApplicationParticipant
first_name	last_nameNemailr(   dob)
r   r   r   r$   r   r6   r   r   r7   r   r   r   r   r   r3   4   s   
 r3   c                   @   s|   e Zd ZU eed< eed< eed< eed< eed< ee ed< dZee ed< eed	< e	ed
< dZ
ee ed< eddZdS )ApplicationInstanceapplication_numberr(   r   r1   is_parent_useris_fully_allocatedFis_approved
created_byr)   NparticipantTr"   )r   r   r   r$   r   r   r   r   r<   r    r>   r3   r   r%   r   r   r   r   r8   ;   s   
 r8   c                   @   r*   )ApplicationListResponser,   N)r   r   r   r   r8   r   r   r   r   r   r?   J   r-   r?   c                   @   s"   e Zd ZU eed< dZeed< dS )BursaryCourseAllocationBase	course_idg        discount_priceN)r   r   r   r   r   rB   floatr   r   r   r   r@   P   r2   r@   c                   @   s<   e Zd ZU ee ed< eed< eed< edddd Z	dS )	BursaryCourseAllocationCreatecoursebursary_discount_application_idr;   after)modec                 C   st   t  -}| jD ] }|t|j}|jstd|j|j	k r'td|j qW d    | S 1 s3w   Y  | S )NzCourse not a bursary productz<Discount amount must be less than or equal to course amount )
r   rE   queryr   getrA   is_bursary_product
ValueErroramountrB   )selfdbrowZcourse_instancer   r   r   validateX   s   

		z&BursaryCourseAllocationCreate.validateN)
r   r   r   r   r@   r   r   r   r	   rQ   r   r   r   r   rD   T   s   
 rD   N)!datetimer   typingr   r   r   pydanticr   r   r   r	   sqlalchemy.ormr
   core.configr   modelsr   r   r   schemar   r   r    r'   r+   r.   r/   r0   r3   r8   r?   r@   rD   r   r   r   r   <module>   s(    
