o
    if                     @   s  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rd 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 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                   @   s  e Zd ZU dZdZeed  ed< 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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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d/< 	 eed0< 	 ee ed1< 	 eee  ed2< 	 ed3 ed4< 	 ee ed5< 	 ed6ed7 d8d fd9d:Zed6ed7 d8d fd;d<Zed6ed= d8ed  fd>d?Zed6ed= d8ed  fd@dAZeded6edB d8d fdCdDZeded6edB d8d fdEdFZed6edG d8d fdHdIZed6edG d8d fdJdKZed6edL d8ed fdMdNZ ed6edL d8ed fdOdPZ!eded6edQ d8d fdRdSZ"eded6edQ d8d fdTdUZ#eded6edV d8d fdWdXZ$e%e&ded6edV d8d fdYdZZ'e%d6edV d8d fd[dZZ'e(d\d6edV d8d fd]dZZ'eded6edV d8d fd^d_Z)e%e&ded6edV d8d fd`daZ*e%d6edV d8d fdbdaZ*e(dcd6edV d8d fdddaZ*eded6ede d8ed fdfdgZ+eded6ede d8ed fdhdiZ,e	e
eeedjZ-dkS )l
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                   @   s$   e Zd ZU eed< 	 ed ed< dS )zCreditNote.DiscountAmountamountr   discountN)__name__
__module____qualname__int__annotations__r    r0   r0   s/var/www/snowflake_co_dev_github/snow_flake_back_end_deploy/env/lib/python3.10/site-packages/stripe/_credit_note.pyDiscountAmount<   s
   
 r2   c                   @   sH   e Zd ZU eed< 	 eed  ed< 	 eed  ed< 	 ed ed< dS )	zCreditNote.PretaxCreditAmountr)   r   credit_balance_transactionr   r*   )r3   r*   typeN)r+   r,   r-   r.   r/   r   r   r   r0   r0   r0   r1   PretaxCreditAmountF   s   
 r5   c                   @   s^   e Zd ZU G d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 )
zCreditNote.Refundc                   @   s    e Zd ZU eed< 	 eed< dS )z%CreditNote.Refund.PaymentRecordRefundpayment_recordrefund_groupNr+   r,   r-   strr/   r0   r0   r0   r1   PaymentRecordRefund[   s
   
 r:   amount_refundedpayment_record_refundRefundResourcerefund)r<   r>   r4   N)r+   r,   r-   r   r:   r.   r/   r   r   r   _inner_class_typesr0   r0   r0   r1   r   Z   s   
 
r   c                   @   sh   e Zd ZU G d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 )
zCreditNote.ShippingCostc                   @   s@   e Zd ZU eed< 	 ded< 	 eed  ed< 	 ee ed< dS )z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   r0   r0   r0   r1   Taxx   s   
 rR   amount_subtotal
amount_taxamount_totalr   shipping_ratetaxesN)r+   r,   r-   r   rR   r.   r/   r   r   r   r?   r0   r0   r0   r1   ShippingCostw   s   
 &rX   c                   @   sv   e Zd ZU G d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 )zCreditNote.TotalTaxc                   @   s   e Zd ZU eed< dS )z"CreditNote.TotalTax.TaxRateDetailstax_rateNr8   r0   r0   r0   r1   TaxRateDetails   s   
 rZ   r)   )	exclusive	inclusivetax_behaviortax_rate_details)rA   not_availablerB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   r4   N)
r+   r,   r-   r   rZ   r.   r/   r   r   r?   r0   r0   r0   r1   TotalTax   s"   
 r`   r)   amount_shippingcreatedcurrencyr   customerr   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_paymentr4   	voided_atparamsr   returnc                 K   s   t d| j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   r0   r0   r1   createn  s   zCreditNote.createc                    s"   t d| jd|  |dI dH S )r   r&   r   r   N)r   _static_request_asyncr   r   r0   r0   r1   create_async  s   
zCreditNote.create_asyncr   c                 K   s4   | j d|  |d}t|tstdt|j |S )1
        Returns a list of credit notes.
        getr   %Expected list object from API, got %s)r   r   
isinstancer   	TypeErrorr4   r+   r   r   resultr0   r0   r1   list  s   
zCreditNote.listc                    s<   | j d|  |dI dH }t|tstdt|j |S )r   r   r   Nr   )r   r   r   r   r   r4   r+   r   r0   r0   r1   
list_async  s   
zCreditNote.list_asyncr    c                 K   s*   d|   t|f }td| jd||dS )2
        Updates an existing credit note.
        %s/%sr&   r   r   )r   r
   r   r   r   ri   r   urlr0   r0   r1   modify  s   zCreditNote.modifyc                    s2   d|   t|f }td| jd||dI dH S )r   r   r&   r   r   N)r   r
   r   r   r   r0   r0   r1   modify_async  s   
zCreditNote.modify_asyncr"   c                 K   s   t d| jdd|dS )E
        Get a preview of a credit note without creating it.
        r&   r   /v1/credit_notes/previewr   )r   r   r   r0   r0   r1   preview  s   zCreditNote.previewc                    s   t d| jdd|dI dH S )r   r&   r   r   r   N)r   r   r   r0   r0   r1   preview_async   s   
zCreditNote.preview_asyncr!   c                 K   s   t td | j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   r0   r0   r1   preview_lines  s   zCreditNote.preview_linesc                    s"   t td | jdd|dI dH S )r   r   r   r   r   N)r   r   r   r   r0   r0   r1   preview_lines_async   s   
zCreditNote.preview_lines_asyncr#   c                 K   s   | |fi |}|   |S )M
        Retrieves the credit note object with the given identifier.
        )refreshr   ri   r   instancer0   r0   r1   retrieve0  s   zCreditNote.retrievec                    s$   | |fi |}|  I dH  |S )r   N)refresh_asyncr   r0   r0   r1   retrieve_async;  s   zCreditNote.retrieve_asyncr$   c                 K   s"   t d| jddjt|d|d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ri   r   )r   r   formatr
   r   ri   r   r0   r0   r1   _cls_void_credit_noteF  s   z CreditNote._cls_void_credit_notec                 K      dS r   Nr0   ri   r   r0   r0   r1   void_credit_noteV  s   zCreditNote.void_credit_notec                 K   r   r   r0   selfr   r0   r0   r1   r   `  s   r   c              	   K   s(   t d| jddjt| dd|dS )r   r&   r   r   ri   r   r   )r   _requestr   r
   r   r   r0   r0   r1   r   i  s   c                    s*   t d| jddjt|d|dI dH S )r   r&   r   r   r   r   N)r   r   r   r
   r   r0   r0   r1   _cls_void_credit_note_async{  s   
z&CreditNote._cls_void_credit_note_asyncc                       dS r   r0   r   r0   r0   r1   void_credit_note_async  s   z!CreditNote.void_credit_note_asyncc                    r   r   r0   r   r0   r0   r1   r     s   r   c              	      s0   t d| jddjt| dd|dI dH S )r   r&   r   r   ri   r   r   N)r   _request_asyncr   r
   r   r   r0   r0   r1   r     s   
r   c                 K   s&   t td | jddjt|d|d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   r0   r0   r1   
list_lines  s   zCreditNote.list_linesc                    s.   t td | jddjt|d|dI dH S )r   r   r   r   r   r   N)r   r   r   r   r
   r   r0   r0   r1   list_lines_async  s   
zCreditNote.list_lines_async)rg   ru   r{   r|   r   N).r+   r,   r-   __doc__r(   r   r   r/   r   r2   r5   r   rX   r`   r.   r9   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   r?   r0   r0   r0   r1   r&   .   s  
 
=/


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   r=   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&   r0   r0   r0   r1   <module>   sD    

