
    _jYg              	          d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZmZ d d	lmZmZmZmZmZmZ d d
lmZmZmZ erfd dlmZ d dlmZ d dl m!Z! d dl"m#Z# d dl$m%Z% d dl&m'Z( d dl)m*Z* d dl+m,Z, d dl-m.Z. d dl/m0Z0 d dl1m2Z2 d dl3m4Z4 d dl5m6Z6 d dl7m8Z8 d dl9m:Z: d dl;m<Z< d dl=m>Z>  e	d           G d ded         ed         ed                               Z?dS )     )CreateableAPIResource)ExpandableField)
ListObject)ListableAPIResource)nested_resource_class_methods)StripeObject)UpdateableAPIResource)class_method_variantsanitize_id)ClassVarDictListOptionalcastoverload)LiteralUnpackTYPE_CHECKING)CreditNoteLineItem)Customer)CustomerBalanceTransaction)Discount)Invoice)Refund)ShippingRate)TaxRate)CreditBalanceTransaction)CreditNoteCreateParams)CreditNoteListLinesParams)CreditNoteListParams)CreditNoteModifyParams)CreditNotePreviewLinesParams)CreditNotePreviewParams)CreditNoteRetrieveParams)CreditNoteVoidCreditNoteParamslinec                      e Zd ZU dZdZeed                  ed<    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eed<   	 eed<   	 eed<   	 eed<   	 ed         ed<   	 ee         ed<   	 eed                  ed<   	 eed<   	 ee	         ed<   	 ee         ed<   	 eed<   	 ed         ed<   	 ed         ed<   	 eed<   	 ee         ed <   	 eeeef                  ed!<   	 eed"<   	 ed         ed#<   	 ee         ed$<   	 eed%<   	 eed&<   	 eed'<   	 ee
         ed(<   	 eed)                  ed*<   	 ee         ed+<   	 ee         ed,<   	 ed-         ed.<   	 eed/<   	 ee         ed0<   	 eed1<   	 ee         ed2<   	 eee                  ed3<   	 ed4         ed5<   	 ee         ed6<   	 ed7ed8         d9d fd:            Zed7ed8         d9d fd;            Zed7ed<         d9ed          fd=            Zed7ed<         d9ed          fd>            Zeded7ed?         d9d fd@            Zeded7ed?         d9d fdA            Zed7edB         d9d fdC            Zed7edB         d9d fdD            Zed7edE         d9ed         fdF            Z ed7edE         d9ed         fdG            Z!eded7edH         d9d fdI            Z"eded7edH         d9d fdJ            Z#eded7edK         d9d fdL            Z$e%e&ded7edK         d9d fdM                        Z'e%d7edK         d9d fdN            Z' e(dO          d7edK         d9d fdP            Z'eded7edK         d9d fdQ            Z)e%e&ded7edK         d9d fdR                        Z*e%d7edK         d9d fdS            Z* e(dT          d7edK         d9d fdU            Z*eded7edV         d9ed         fdW            Z+eded7edV         d9ed         fdX            Z,e	e
eeedYZ-dZS )[
CreditNotez
    Issue a credit note to adjust an invoice's amount after the invoice is finalized.

    Related guide: [Credit notes](https://docs.stripe.com/billing/invoices/credit-notes)
    credit_noteOBJECT_NAMEc                   2    e Zd ZU eed<   	 ed         ed<   dS )CreditNote.DiscountAmountamountr   discountN)__name__
__module____qualname__int__annotations__r        W/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/stripe/_credit_note.pyDiscountAmountr,   <   s7         	 "*----	 	r5   r7   c                   z    e Zd ZU eed<   	 eed                  ed<   	 eed                  ed<   	 ed         ed<   dS )	CreditNote.PretaxCreditAmountr-   r   credit_balance_transactionr   r.   )r:   r.   typeN)r/   r0   r1   r2   r3   r   r   r   r4   r5   r6   PretaxCreditAmountr9   F   s|         	 %-67%
 	
 	
 	
	 ?:67777	 >????	 	r5   r<   c                       e Zd ZU  G d de          Zeed<   	 ee         ed<   	 ed         ed<   	 ee	d                  ed<   	 deiZ
d	S )
CreditNote.Refundc                   &    e Zd ZU eed<   	 eed<   dS )%CreditNote.Refund.PaymentRecordRefundpayment_recordrefund_groupNr/   r0   r1   strr3   r4   r5   r6   PaymentRecordRefundr@   [   s5           r5   rE   amount_refundedpayment_record_refundRefundResourcerefund)rG   rI   r;   N)r/   r0   r1   r   rE   r2   r3   r   r   r   _inner_class_typesr4   r5   r6   r   r>   Z   s         	 	 	 	 	, 	 	 	 	  ((;<<<<	   01111	 w@ABBBB	 67JKr5   r   c                       e Zd ZU  G d de          Zeed<   	 eed<   	 eed<   	 eed                  ed<   	 ee	e                  ed<   	 deiZ
d	S )
CreditNote.ShippingCostc                   b    e Zd ZU eed<   	 ded<   	 eed                  ed<   	 ee         ed<   dS )CreditNote.ShippingCost.Taxr-   r   rate)customer_exemptnot_collectingnot_subject_to_taxnot_supportedportion_product_exemptportion_reduced_ratedportion_standard_ratedproduct_exemptproduct_exempt_holidayproportionally_ratedreduced_ratedreverse_chargestandard_ratedtaxable_basis_reduced
zero_ratedtaxability_reasontaxable_amountN)r/   r0   r1   r2   r3   r   r   r4   r5   r6   TaxrN   x   sq         KKK OOO
  ("    & %SM))) r5   ra   amount_subtotal
amount_taxamount_totalr   shipping_ratetaxesN)r/   r0   r1   r   ra   r2   r3   r   r   r   rJ   r4   r5   r6   ShippingCostrL   w   s         $	 $	 $	 $	 $	, $	 $	 $	L 	 	 	   ?@@@@	 S	""""	 &s^r5   rg   c                       e Zd ZU  G d de          Zeed<   	 ed         ed<   	 ee         ed<   	 ed         ed<   	 ee         ed	<   	 ed         ed
<   	 deiZ	dS )CreditNote.TotalTaxc                       e Zd ZU eed<   dS )"CreditNote.TotalTax.TaxRateDetailstax_rateNrC   r4   r5   r6   TaxRateDetailsrk      s         MMM r5   rm   r-   )	exclusive	inclusivetax_behaviortax_rate_details)rP   not_availablerQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   r;   N)
r/   r0   r1   r   rm   r2   r3   r   r   rJ   r4   r5   r6   TotalTaxri      s         	 	 	 	 	\ 	 	 	 	 67777	 #>2222	 #
 	
 	
 	
$	 !%%%	 ())))	 1.Ar5   rs   r-   amount_shippingcreatedcurrencyr   customercustomer_accountr   customer_balance_transactiondiscount_amountdiscount_amountseffective_atidr   invoicer   lineslivemodememometadatanumberobjectout_of_band_amountpdfpost_payment_amountpre_payment_amountpretax_credit_amounts)	duplicate
fraudulentorder_changeproduct_unsatisfactoryreasonrefundsshipping_cost)issuedvoidstatussubtotalsubtotal_excluding_taxtotaltotal_excluding_taxtotal_taxes)mixedpost_paymentpre_paymentr;   	voided_atparamsr   returnc                 r    t          d|                     d|                                 |                    S )  
        Issue a credit note to adjust the amount of a finalized invoice. A credit note will first reduce the invoice's amount_remaining (and amount_due), but not below zero.
        This amount is indicated by the credit note's pre_payment_amount. The excess amount is indicated by post_payment_amount, and it can result in any combination of the following:


        Refunds: create a new refund (using refund_amount) or link existing refunds (using refunds).
        Customer balance credit: credit the customer's balance (using credit_amount) which will be automatically applied to their next invoice when it's finalized.
        Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount).


        The sum of refunds, customer balance credits, and outside of Stripe credits must equal the post_payment_amount.

        You may issue multiple credit notes for an invoice. Each credit note may increment the invoice's pre_payment_credit_notes_amount,
        post_payment_credit_notes_amount, or both, depending on the invoice's amount_remaining at the time of credit note creation.
        r(   postr   )r   _static_request	class_urlclsr   s     r6   createzCreditNote.createu  sB    &     
 
 	
r5   c                    K   t          d|                     d|                                 |           d{V           S )r   r(   r   r   N)r   _static_request_asyncr   r   s     r6   create_asynczCreditNote.create_async  sd      & ++ ,        
 
 	
r5   r    c                     |                      d|                                 |          }t          |t                    s$t	          dt          |          j        z            |S )1
        Returns a list of credit notes.
        getr   %Expected list object from API, got %s)r   r   
isinstancer   	TypeErrorr;   r/   r   r   results      r6   listzCreditNote.list  sp     $$MMOO % 
 

 &*-- 	7<<(*  
 r5   c                    K   |                      d|                                 |           d{V }t          |t                    s$t	          dt          |          j        z            |S )r   r   r   Nr   )r   r   r   r   r   r;   r/   r   s      r6   
list_asynczCreditNote.list_async  s       00MMOO 1 
 
 
 
 
 
 
 

 &*-- 	7<<(*  
 r5   r!   c                     |                                  dt          |          }t          d|                     d||                    S )2
        Updates an existing credit note.
        /r(   r   r   )r   r   r   r   r   r}   r   urls       r6   modifyzCreditNote.modify  sX     +b///:    
 
 	
r5   c                    K   |                                  dt          |          }t          d|                     d||           d{V           S )r   r   r(   r   r   N)r   r   r   r   r   s       r6   modify_asynczCreditNote.modify_async  sz       +b///:++ ,        
 
 	
r5   r#   c                 N    t          d|                     dd|                    S )E
        Get a preview of a credit note without creating it.
        r(   r   /v1/credit_notes/previewr   )r   r   r   s     r6   previewzCreditNote.preview  s:     *    
 
 	
r5   c                 ^   K   t          d|                     dd|           d{V           S )r   r(   r   r   r   N)r   r   r   s     r6   preview_asynczCreditNote.preview_async  s\       ++* ,        
 
 	
r5   r"   c                 d    t          t          d         |                     dd|                    S )
        When retrieving a credit note preview, you'll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items.
        r   r   /v1/credit_notes/preview/linesr   )r   r   r   r   s     r6   preview_lineszCreditNote.preview_lines  s@     +,0    
 
 	
r5   c                 t   K   t          t          d         |                     dd|           d{V           S )r   r   r   r   r   N)r   r   r   r   s     r6   preview_lines_asynczCreditNote.preview_lines_async'  sb       +,++0 ,        
 
 	
r5   r$   c                 @     | |fi |}|                                  |S )M
        Retrieves the credit note object with the given identifier.
        )refreshr   r}   r   instances       r6   retrievezCreditNote.retrieve7  s2     3r$$V$$r5   c                 P   K    | |fi |}|                                  d{V  |S )r   N)refresh_asyncr   s       r6   retrieve_asynczCreditNote.retrieve_asyncB  sH       3r$$V$$$$&&&&&&&&&r5   r%   c                     t          d|                     dd                    t          |                    |                    S )
        Marks a credit note as void. Learn more about [voiding credit notes](https://docs.stripe.com/docs/billing/invoices/credit-notes#voiding).
        r(   r   /v1/credit_notes/{id}/voidr}   r   )r   r   formatr   r   r}   r   s      r6   _cls_void_credit_notez CreditNote._cls_void_credit_noteM  sQ     ,33{23GG    
 
 	
r5   c                     dS r   Nr4   r}   r   s     r6   void_credit_notezCreditNote.void_credit_note]  s	     	r5   c                     dS r   r4   selfr   s     r6   r   zCreditNote.void_credit_noteg  s	     	r5   r   c                     t          d|                     dd                    t          |                     d                              |                    S )r   r(   r   r   r}   r   r   )r   _requestr   r   r   r   s     r6   r   zCreditNote.void_credit_notep  sd     MM,33"488D>>22 4      	
 	
 		
r5   c                    K   t          d|                     dd                    t          |                    |           d{V           S )r   r(   r   r   r   r   N)r   r   r   r   r   s      r6   _cls_void_credit_note_asyncz&CreditNote._cls_void_credit_note_async  ss       ++,33{23GG ,        
 
 	
r5   c                 
   K   dS r   r4   r   s     r6   void_credit_note_asyncz!CreditNote.void_credit_note_async  s       	r5   c                 
   K   dS r   r4   r   s     r6   r   z!CreditNote.void_credit_note_async  s       	r5   r   c                    K   t          d|                     dd                    t          |                     d                              |           d{V           S )r   r(   r   r   r}   r   r   N)r   _request_asyncr   r   r   r   s     r6   r   z!CreditNote.void_credit_note_async  s       %%,33"488D>>22 4    &        	
 	
 		
r5   r   c                     t          t          d         |                     dd                    t	          |                    |                    S )
        When retrieving a credit note, you'll get a lines property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
        r   r   $/v1/credit_notes/{credit_note}/linesr)   r   )r   r   r   r   r   r   r)   r   s      r6   
list_lineszCreditNote.list_lines  sb     +,6== +K 8 8 >       	
 	
 		
r5   c                    K   t          t          d         |                     dd                    t	          |                    |           d{V           S )r   r   r   r   r   r   N)r   r   r   r   r   r   s      r6   list_lines_asynczCreditNote.list_lines_async  s       +,++6== +K 8 8 >    ,        	
 	
 		
r5   )r{   r   r   r   r   N).r/   r0   r1   __doc__r*   r   r   r3   r   r7   r<   r   rg   rs   r2   rD   r   r   r   r   boolr   classmethodr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   staticmethodr   r
   r   r   r   r   rJ   r4   r5   r6   r(   r(   .   s{	          5BK'-01AAA           \   (L L L L L L L L:;, ;, ;, ;, ;,| ;, ;, ;,z0B 0B 0B 0B 0B< 0B 0B 0Bd KKK  LLL MMM j)))) sm### #+45#     >**** 3- 	GGG Y'''' *++++ NNN 3- tCH~&&&& KKK M"""" !%%% 
HHH     23333 O	
   
 &\ L)))) $%%%% MMM %SM))) JJJ "#&&& $x.)))) 8
9999 } 
67
	
 
 
 [
6 
67
	
 
 
 [
6 45	L	!   [& 45	L	!   [& 

 &'? @
	
 
 
 [
  

 &'? @
	
 
 
 [
  
78
	
 
 
 [
 
78
	
 
 
 [
 
<=
	(	)
 
 
 [
 
<=
	(	)
 
 
 [
  &'A B	   [  &'A B	   [ 

 &'G H
	
 
 
 [
 !"BC	   \ X ?@	   X 122
?@
	
 
 
 32
" 

 &'G H
	
 
 
 [
 !"BC	   \ X ?@	   X 788
?@
	
 
 
 98
" 

)/0K)L
	(	)
 
 
 [
" 

)/0K)L
	(	)
 
 
 [
$ +!3% r5   r(   N)@stripe._createable_api_resourcer   stripe._expandable_fieldr   stripe._list_objectr   stripe._listable_api_resourcer   %stripe._nested_resource_class_methodsr   stripe._stripe_objectr   stripe._updateable_api_resourcer	   stripe._utilr
   r   typingr   r   r   r   r   r   typing_extensionsr   r   r   stripe._credit_note_line_itemr   stripe._customerr   $stripe._customer_balance_transactionr   stripe._discountr   stripe._invoicer   stripe._refundr   rH   stripe._shipping_rater   stripe._tax_rater   *stripe.billing._credit_balance_transactionr   (stripe.params._credit_note_create_paramsr   ,stripe.params._credit_note_list_lines_paramsr   &stripe.params._credit_note_list_paramsr    (stripe.params._credit_note_modify_paramsr!   /stripe.params._credit_note_preview_lines_paramsr"   )stripe.params._credit_note_preview_paramsr#   *stripe.params._credit_note_retrieve_paramsr$   2stripe.params._credit_note_void_credit_note_paramsr%   r(   r4   r5   r6   <module>r     s   B A A A A A 4 4 4 4 4 4 * * * * * * = = = = = = O O O O O O . . . . . . A A A A A A : : : : : : : : A A A A A A A A A A A A A A A A < < < < < < < < < < @@@@@@))))))OOOOOO))))))''''''777777222222((((((      POOOOO      LKKKKKOOOOOO                    
 v&&r
 r
 r
 r
 r
,'%,'r
 r
 '&r
 r
 r
r5   