
    +h
              	       R   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 d dlmZ d dl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mZmZ d d
lmZ er0d 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/  ed       G d ded   ed   ed                Z0y)    )util)CreateableAPIResourceListableAPIResourceUpdateableAPIResourcenested_resource_class_methods)ExpandableField)
ListObject)RequestOptions)StripeObject)class_method_variant)ClassVarDictListOptionalcastoverload)LiteralNotRequired	TypedDictUnpackTYPE_CHECKING)
quote_plus)CreditNoteLineItem)Customer)CustomerBalanceTransaction)Discount)Invoice)Refund)ShippingRate)TaxRatelinec                   v   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er 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 G d$ d%e      Zeed&<   	 eed'<   	 eed(<   	 eed)<   	 ed*   ed+<   	 e ed,      ed-<   	 eed.<   	 e!e	   ed/<   	 e e   ed0<   	 eed1<   	 ed2   ed3<   	 e"d4   ed5<   	 e#ed6<   	 e e   ed7<   	 e e$eef      ed8<   	 eed9<   	 ed   ed:<   	 e e   ed;<   	 eed<<   	 e ed=      ed><   	 e ed?      ed@<   	 e e
   edA<   	 edB   edC<   	 eedD<   	 e e   edE<   	 e!e   edF<   	 eedG<   	 e e   edH<   	 edI   edJ<   	 e e   edK<   	 e%	 	 	 	 dhdMe e   dNe e   dOe e   dPe e   dQe&dR   dSd fdT       Z'e%	 	 	 didMe e   dOe e   dPe e   dQe&dU   dSe"d    f
dV       Z(e%d1edQe&dW   dSd fdX       Z)e%	 	 	 didMe e   dOe e   dPe e   dQe&dY   dSd f
dZ       Z*e%	 	 	 didMe e   dOe e   dPe e   dQe&d[   dSe"d4   f
d\       Z+e%d1edQe&d]   dSd fd^       Z,e%	 	 	 did1edMe e   dOe e   dPe e   dQe&d_   dSd fd`       Z-e.e/	 	 	 did1edMe e   dOe e   dPe e   dQe&d_   dSd fda              Z0e.	 djdNe e   dQe&d_   dSd fdb       Z0 e1dc      	 djdNe e   dQe&d_   dSd fdd       Z0e%	 	 	 didedMe e   dOe e   dPe e   dQe&de   dSe"d4   fdf       Z2e	e
edgZ3yL)k
CreditNotez
    Issue a credit note to adjust an invoice's amount after the invoice is finalized.

    Related guide: [Credit notes](https://stripe.com/docs/billing/invoices/credit-notes)
    credit_noteOBJECT_NAMEc                   *    e Zd ZU eed<   	 ed   ed<   y)CreditNote.DiscountAmountamountr   discountN)__name__
__module____qualname__int__annotations__r        S/var/www/html/venv/lib/python3.12/site-packages/stripe/api_resources/credit_note.pyDiscountAmountr'   4   s    	 "*--	r0   r2   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
y	)
CreditNote.ShippingCostc                   N    e Zd ZU eed<   	 ded<   	 eed      ed<   	 ee   ed<   y)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*   r+   r,   r-   r.   r   r   r/   r0   r1   Taxr6   ?   sJ    K O
  ("  & %SM)r0   rJ   amount_subtotal
amount_taxamount_totalr   shipping_ratetaxesN)r*   r+   r,   r   rJ   r-   r.   r   r   r   _inner_class_typesr/   r0   r1   ShippingCostr4   >   sn    $	, $	L 	 	 	   ?@@	 S	""	 &s^r0   rQ   c                   `    e Zd ZU eed<   	 eed<   	 ed   ed<   	 eed      ed<   	 ee   ed<   y)	CreditNote.TaxAmountr(   	inclusiver    tax_rater8   rH   rI   N)	r*   r+   r,   r-   r.   boolr   r   r   r/   r0   r1   	TaxAmountrS   {   s\    	 	 "),,	 $
 	
&	 !%	r0   rW   c                       e Zd ZU ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 eed<   	 ed   ed	<   	 ed
   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed
   ed<   	 ed   ed<   	 ed   ed<   y)CreditNote.CreateParamsr-   r(   credit_amounteffective_at	List[str]expandinvoicez!List[CreditNote.CreateParamsLine]linesstrmemoDict[str, str]metadataout_of_band_amountLLiteral['duplicate', 'fraudulent', 'order_change', 'product_unsatisfactory']reasonrefundrefund_amount#CreditNote.CreateParamsShippingCostshipping_costNr*   r+   r,   r   r.   r`   r/   r0   r1   CreateParamsrY      s    && 'u-- &e,,  ,, L BCC e$$ ""233 !,E 22  ^   && 'u-- ''LMMr0   rl   c                       e Zd ZU ed   ed<   y)ri   r`   rN   Nr*   r+   r,   r   r.   r/   r0   r1   CreateParamsShippingCostz#CreditNote.CreateParamsShippingCost       &u--r0   ro   c                       e Zd ZU ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed	   ed
<   	 ed   ed<   	 ed   ed<   y)CreditNote.CreateParamsLiner-   r(   r`   descriptioninvoice_line_itemquantityLiteral['']|List[str]	tax_ratescustom_line_itemrt   typeunit_amountunit_amount_decimalNr*   r+   r,   r   r.   r   r/   r0   r1   CreateParamsLinerr          && %U++  +511 "%(( ##:;; ABB %U++ "-U!33r0   r~   c                   x    e Zd ZU ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed	<   y
)CreditNote.ListParamsr`   customerending_beforer\   r]   r^   r-   limitstarting_afterNrn   r/   r0   r1   
ListParamsr     sl    !%(( 'u--  ,, !'' u%% (..r0   r   c                   B    e Zd ZU ed   ed<   	 ed   ed<   	 ed   ed<   y)CreditNote.ModifyParamsr\   r]   r`   ra   rb   rc   Nrn   r/   r0   r1   ModifyParamsr     s7    ,, e$$ ""233r0   r   c                       e Zd ZU ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 eed<   	 ed   ed	<   	 ed
   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed
   ed<   	 ed   ed<   	 ed   ed<   y)CreditNote.PreviewParamsr-   r(   rZ   r[   r\   r]   r^   z"List[CreditNote.PreviewParamsLine]r_   r`   ra   rb   rc   rd   re   rf   rg   rh   $CreditNote.PreviewParamsShippingCostrj   Nrk   r/   r0   r1   PreviewParamsr   -  s    && 'u-- &e,,  ,, L CDD e$$ ""233 !,E 22  ^   && 'u-- ''MNNr0   r   c                       e Zd ZU ed   ed<   y)r   r`   rN   Nrn   r/   r0   r1   PreviewParamsShippingCostz$CreditNote.PreviewParamsShippingCoste  rp   r0   r   c                       e Zd ZU ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed	   ed
<   	 ed   ed<   	 ed   ed<   y)CreditNote.PreviewParamsLiner-   r(   r`   rs   rt   ru   rv   rw   rx   rz   r{   r|   Nr}   r/   r0   r1   PreviewParamsLiner   k  r   r0   r   c                   &   e Zd ZU ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 eed	<   	 ed   ed
<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   y)CreditNote.PreviewLinesParamsr-   r(   rZ   r[   r`   r   r\   r]   r^   r   z'List[CreditNote.PreviewLinesParamsLine]r_   ra   rb   rc   rd   re   rf   rg   rh   )CreditNote.PreviewLinesParamsShippingCostrj   r   Nrk   r/   r0   r1   PreviewLinesParamsr     s&   && 'u-- &e,, 'u--  ,, L u%% HII e$$ ""233 !,E 22  ^   && 'u-- ';  (..r0   r   c                       e Zd ZU ed   ed<   y)r   r`   rN   Nrn   r/   r0   r1   PreviewLinesParamsShippingCostz)CreditNote.PreviewLinesParamsShippingCost  rp   r0   r   c                       e Zd ZU ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   	 ed	   ed
<   	 ed   ed<   	 ed   ed<   y)!CreditNote.PreviewLinesParamsLiner-   r(   r`   rs   rt   ru   rv   rw   rx   rz   r{   r|   Nr}   r/   r0   r1   PreviewLinesParamsLiner     r   r0   r   c                       e Zd ZU ed   ed<   y)CreditNote.RetrieveParamsr\   r]   Nrn   r/   r0   r1   RetrieveParamsr         ,,r0   r   c                       e Zd ZU ed   ed<   y)CreditNote.VoidCreditNoteParamsr\   r]   Nrn   r/   r0   r1   VoidCreditNoteParamsr     r   r0   r   c                   T    e Zd ZU ed   ed<   	 ed   ed<   	 ed   ed<   	 ed   ed<   y)	CreditNote.ListLinesParamsr`   r   r\   r]   r-   r   r   Nrn   r/   r0   r1   ListLinesParamsr     sH    &u--  ,, u%% (..r0   r   r(   amount_shippingcreatedcurrencyr   r   r   customer_balance_transactiondiscount_amountdiscount_amountsr[   idr   r^   r   r_   livemodera   rc   numberobjectrd   pdf)	duplicate
fraudulentorder_changeproduct_unsatisfactoryrf   r   rg   rj   )issuedvoidstatussubtotalsubtotal_excluding_taxtax_amountstotaltotal_excluding_tax)post_paymentpre_paymentrz   	voided_atNapi_keyidempotency_keystripe_versionstripe_accountparamsrY   returnc                 `    t        d| j                  d| j                         |||||            S )a+  
        Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces
        its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result
        in any combination of the following:


        Refund: create a new refund (using refund_amount) or link an existing refund (using refund).
        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).


        For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.

        You may issue multiple credit notes for an invoice. Each credit note will increment the invoice's pre_payment_credit_notes_amount
        or post_payment_credit_notes_amount depending on its status at the time of credit note creation.
        r#   post)r   _static_request	class_url)clsr   r   r   r   r   s         r1   createzCreditNote.create  s=    2 
 	
r0   r   c                     | j                  d| j                         ||||      }t        |t              s!t	        dt        |      j                  z        |S )z1
        Returns a list of credit notes.
        getr   r   r   r   z%Expected list object from API, got %s)r   r   
isinstancer	   	TypeErrorrz   r*   )r   r   r   r   r   results         r1   listzCreditNote.list  sf     $$MMO)) % 
 &*-7<((* 
 r0   r   c                 z    | j                         dt        |      }t        d| j                  d||            S )z2
        Updates an existing credit note.
        /r#   r   )r   )r   r   r   r   )r   r   r   urls       r1   modifyzCreditNote.modify  s=     *R.9F;
 	
r0   r   c                 D    t        d| j                  dd||||            S )zE
        Get a preview of a credit note without creating it.
        r#   r   z/v1/credit_notes/previewr   )r   r   r   r   r   r   r   s        r1   previewzCreditNote.preview  s9     *--   

 
	
r0   r   c                 R    t        t        d   | j                  dd||||            S )z
        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   z/v1/credit_notes/preview/linesr   )r   r	   r   r   s        r1   preview_lineszCreditNote.preview_lines  s?     +,0--   

 
	
r0   r   c                 8     | |fi |}|j                          |S )zM
        Retrieves the credit note object with the given identifier.
        )refresh)r   r   r   instances       r1   retrievezCreditNote.retrieve  s$     r$V$r0   r   c                     t        d| j                  ddj                  t        j                  |            ||||            S )
        Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
        r#   r   /v1/credit_notes/{id}/voidr   r   )r   r   formatr   sanitize_id)r   r   r   r   r   r   s         r1   _cls_void_credit_notez CreditNote._cls_void_credit_note   sR     ,33t7G7G7K3L--   

 
	
r0   c                      yr   Nr/   )r   r   r   r   r   s        r1   void_credit_notezCreditNote.void_credit_note8  s     	r0   c                      yr   r/   selfr   r   s      r1   r   zCreditNote.void_credit_noteF  s     	r0   r   c                     t        d| j                  ddj                  t        j                  | j                  d                  ||            S )r   r#   r   r   r   r   )r   r   )r   _requestr   r   r   r   r   s      r1   r   zCreditNote.void_credit_noteQ  sY     MM,33''7 4  !0  

 
	
r0   r   c                     t        t        d   | j                  ddj                  t	        j
                  |            ||||            S )z
        When retrieving a credit note, you'll get a lines property containing the the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
        r   r   z$/v1/credit_notes/{credit_note}/lines)r$   r   )r   r	   r   r   r   r   )r   r$   r   r   r   r   s         r1   
list_lineszCreditNote.list_linesf  s_     +,6== $ 0 0 = >   --   	
 	
r0   )r   rj   r   )NNNN)NNN)N)4r*   r+   r,   __doc__r%   r   r   r.   r   r2   rQ   rW   r   r
   rl   r   ro   r~   r   r   r   r   r   r   r   r   r   r   r   r-   r`   r   r   r   r	   rV   r   classmethodr   r   r   r   r   r   r   r   r   staticmethodr   r   r   rP   r/   r0   r1   r#   r#   &   s    5BK'-01A ;,| ;,z&L &P 6	> 6	p	y 	 	y  	D	 	4	> 	6	N 6	p		 	 		  	DD	 D	L	Y 	 	Y  	D	^ 		> 		n 	$ K  L M j)) #+45#   >** 3- 	G Y'' *++ N 3- tCH~&& K M"" !% 
H O	
 
 _X.// L)) $%% M %SM) i  J "#& /
00 }  "&)-(,(,#
##
 "##
 !	#

 !#
 23#
 
#
 #
J  "&(,(,	# ! !	
 01 
L	! 6 



 &'@ A

	

 

  "&(,(,	
#
 !
 !	

 34
 

 
,  "&(,(,	
#
 !
 !	

 89
 
(	)
 
,  &'B C	   "&(,(,

 #
 !	

 !
 :;
 

 
.  "&(,(,	

#
 !
 !	

 :;
 

  
  *.!# :; 
	  12 *.
!#
 :;
 
	
 3
(  "&(,(,

 #
 !	

 !
 56
 
(	)
 
4 +% r0   r#   N)1striper   stripe.api_resources.abstractr   r   r   r   %stripe.api_resources.expandable_fieldr    stripe.api_resources.list_objectr	   stripe.request_optionsr
   stripe.stripe_objectr   stripe.utilr   typingr   r   r   r   r   r   typing_extensionsr   r   r   r   r   urllib.parser   *stripe.api_resources.credit_note_line_itemr   stripe.api_resources.customerr   1stripe.api_resources.customer_balance_transactionr   stripe.api_resources.discountr   stripe.api_resources.invoicer   stripe.api_resources.refundr   "stripe.api_resources.shipping_rater   stripe.api_resources.tax_rater    r#   r/   r0   r1   <module>r     s      B 7 1 - , A A  $M6 742?5 v&],'%,'] ']r0   