o
    i*                     @   s   d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
 e
rdd 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mZ d dlm Z  ddgddgdZ!G dd deZ"dS )    )StripeService)sanitize_id)Optionalcast)import_module)TYPE_CHECKING)
CreditNote)CreditNoteLineItemService)CreditNotePreviewLinesService)
ListObject)RequestOptions)CreditNoteCreateParams)CreditNoteListParams)CreditNotePreviewParams)CreditNoteRetrieveParams)CreditNoteUpdateParams)CreditNoteVoidCreditNoteParamsz%stripe._credit_note_line_item_servicer	   z)stripe._credit_note_preview_lines_servicer
   )
line_itemspreview_linesc                	       s  e Zd ZU ded< ded<  fddZdd Z				d/d
ed ded ddfddZ				d/d
ed ded ddfddZ		d0d
dded ddfddZ			d0d
dded ddfddZ
				d/ded
ed ded ddfddZ				d/ded
ed ded ddfddZ				d/ded
ed  ded ddfd!d"Z				d/ded
ed  ded ddfd#d$Z		d0d
d%ded ddfd&d'Z		d0d
d%ded ddfd(d)Z				d/ded
ed* ded ddfd+d,Z				d/ded
ed* ded ddfd-d.Z  ZS )1CreditNoteServicer	   r   r
   r   c                    s   t  | d S N)super__init__)self	requestor	__class__ {/var/www/snowflake_co_dev_github/snow_flake_back_end_deploy/env/lib/python3.10/site-packages/stripe/_credit_note_service.pyr   .   s   zCreditNoteService.__init__c                 C   sN   zt | \}}tt||}t| ||| j t| |W S  ty&   t w r   )_subservicesgetattrr   setattr
_requestorKeyErrorAttributeError)r   nameimport_fromserviceservice_classr   r   r   __getattr__1   s   zCreditNoteService.__getattr__Nparamsr   optionsr   returnListObject[CreditNote]c              	   C      t d| jddd||dS )1
        Returns a list of credit notes.
        r-   get/v1/credit_notesapibase_addressr*   r+   r   _requestr   r*   r+   r   r   r   listA      zCreditNoteService.listc              	      "   t d| jddd||dI dH S )r/   r-   r0   r1   r2   r3   Nr   _request_asyncr7   r   r   r   
list_asyncT      
zCreditNoteService.list_asyncr   r   c              	   C   r.   )  
        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   postr1   r2   r3   r5   r7   r   r   r   createg   s   zCreditNoteService.createc              	      r:   )r?   r   r@   r1   r2   r3   Nr;   r7   r   r   r   create_async   s   
zCreditNoteService.create_asyncidr   c              	   C   &   t d| jddjt|dd||dS )M
        Retrieves the credit note object with the given identifier.
        r   r0   /v1/credit_notes/{id}rC   r2   r3   r   r6   formatr   r   rC   r*   r+   r   r   r   retrieve      	zCreditNoteService.retrievec              	      .   t d| jddjt|dd||dI dH S )rE   r   r0   rF   rG   r2   r3   Nr   r<   rI   r   rJ   r   r   r   retrieve_async      	
z CreditNoteService.retrieve_asyncr   c              	   C   rD   )2
        Updates an existing credit note.
        r   r@   rF   rG   r2   r3   rH   rJ   r   r   r   update   rL   zCreditNoteService.updatec              	      rM   )rQ   r   r@   rF   rG   r2   r3   NrN   rJ   r   r   r   update_async   rP   zCreditNoteService.update_asyncr   c              	   C   r.   )E
        Get a preview of a credit note without creating it.
        r   r0   /v1/credit_notes/previewr2   r3   r5   r7   r   r   r   preview   r9   zCreditNoteService.previewc              	      r:   )rT   r   r0   rU   r2   r3   Nr;   r7   r   r   r   preview_async  r>   zCreditNoteService.preview_asyncr   c              	   C   rD   )
        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}/voidrG   r2   r3   rH   rJ   r   r   r   void_credit_note  rL   z"CreditNoteService.void_credit_notec              	      rM   )rX   r   r@   rY   rG   r2   r3   NrN   rJ   r   r   r   void_credit_note_async/  rP   z(CreditNoteService.void_credit_note_async)NNr   )__name__
__module____qualname____annotations__r   r)   r   r8   r=   rA   rB   strrK   rO   rR   rS   rV   rW   rZ   r[   __classcell__r   r   r   r   r   *   s   
 


"
"






r   N)#stripe._stripe_servicer   stripe._utilr   typingr   r   	importlibr   typing_extensionsr   stripe._credit_noter   %stripe._credit_note_line_item_servicer	   )stripe._credit_note_preview_lines_servicer
   stripe._list_objectr   stripe._request_optionsr   (stripe.params._credit_note_create_paramsr   &stripe.params._credit_note_list_paramsr   )stripe.params._credit_note_preview_paramsr   *stripe.params._credit_note_retrieve_paramsr   (stripe.params._credit_note_update_paramsr   2stripe.params._credit_note_void_credit_note_paramsr   r   r   r   r   r   r   <module>   s2   