def get_customer_payment(self,response): """This method parses the given response and returns customer payments object. Args: response(dict): Response containing json object for customer payments. Returns: instance: Customer payments object. """ payment=response['payment'] customer_payment=CustomerPayment() customer_payment.set_payment_id(payment['payment_id']) customer_payment.set_customer_id(payment['customer_id']) customer_payment.set_customer_name(payment['customer_name']) customer_payment.set_payment_mode(payment['payment_mode']) customer_payment.set_date(payment['date']) customer_payment.set_account_id(payment['account_id']) customer_payment.set_account_name(payment['account_name']) customer_payment.set_exchange_rate(payment['exchange_rate']) customer_payment.set_amount(payment['amount']) customer_payment.set_bank_charges(payment['bank_charges']) customer_payment.set_tax_account_id(payment['tax_account_id']) customer_payment.set_tax_account_name(payment['tax_account_name']) customer_payment.set_tax_amount_withheld(\ payment['tax_amount_withheld']) customer_payment.set_description(payment['description']) customer_payment.set_reference_number(payment['reference_number']) invoices=[] for value in payment['invoices']: invoice=Invoice() invoice.set_invoice_number(value['invoice_number']) invoice.set_invoice_payment_id(value['invoice_payment_id']) invoice.set_invoice_id(value['invoice_id']) invoice.set_amount_applied(value['amount_applied']) invoice.set_tax_amount_withheld(value['tax_amount_withheld']) invoice.set_total(value['total']) invoice.set_balance(value['balance']) invoice.set_date(value['date']) invoice.set_due_date(value['due_date']) invoices.append(invoice) customer_payment.set_invoices(invoices) return customer_payment
def credit_to_invoice(self,response): """This method parses the given response and returns invoices object. Args: response(dict): Responses containing json object for credit to invoice. Returns: instance: Invoice List object. """ invoices = InvoiceList() for value in response['apply_to_invoices']['invoices']: invoice=Invoice() invoice.set_invoice_id(value['invoice_id']) invoice.set_amount_applied(value['amount_applied']) invoices.set_invoices(invoice) return invoices
invoice_id = credit_notes_api.list_invoices_credited(credit_note_id).get_invoices_credited()[0].get_invoice_id() ''' creditnote_invoice_id = credit_notes_api.list_invoices_credited( credit_note_id)[0].get_creditnotes_invoice_id() # List invoices credited print credit_notes_api.list_invoices_credited(credit_note_id) # Credit to an invoice invoices = [] invoice = Invoice() invoice.set_invoice_id(invoice_id) invoice.set_amount_applied(10.0) invoices.append(invoice) print credit_notes_api.credit_to_invoice(credit_note_id, invoices) # Delete invoice credited print credit_notes_api.delete_invoices_credited(credit_note_id, creditnote_invoice_id) ''' #----------------------------------------------------------------------------------------- ''' # Refund credit_note_id = credit_notes_api.list_credit_note_refunds( ).get_creditnote_refunds()[0].get_creditnote_id() creditnote_refund_id = credit_notes_api.list_refunds_of_credit_note( credit_note_id).get_creditnote_refunds()[0].get_creditnote_refund_id()
# Apply to invoices invoice_id = credit_notes_api.list_invoices_credited(credit_note_id).get_invoices_credited()[0].get_invoice_id() ''' creditnote_invoice_id = credit_notes_api.list_invoices_credited(credit_note_id)[0].get_creditnotes_invoice_id() # List invoices credited print credit_notes_api.list_invoices_credited(credit_note_id) # Credit to an invoice invoices=[] invoice=Invoice() invoice.set_invoice_id(invoice_id) invoice.set_amount_applied(10.0) invoices.append(invoice) print credit_notes_api.credit_to_invoice(credit_note_id,invoices) # Delete invoice credited print credit_notes_api.delete_invoices_credited(credit_note_id,creditnote_invoice_id) ''' #----------------------------------------------------------------------------------------- ''' # Refund credit_note_id = credit_notes_api.list_credit_note_refunds().get_creditnote_refunds()[0].get_creditnote_id() creditnote_refund_id = credit_notes_api.list_refunds_of_credit_note(credit_note_id).get_creditnote_refunds()[0].get_creditnote_refund_id() # List credit note refunds sort_column='refund_mode'