Exemple #1
0
class ListTest(unittest.TestCase):
    def setUp(self):
        self.client = SFClient(LOGIN, APIKEY)

    def testListAllInvoices(self):
        self.assertGreater(len(self.client.list_invoices()), 0)

    def testListClientsInvoices(self):
        self.assertGreater(len(self.client.list_invoices_by_client(90827)), 0)

    def testListDueInvoices(self):
        self.assertGreater(len(self.client.list_due_invoices()), 0)

    def testListUnpaidInvoices(self):
        self.assertGreater(len(self.client.list_unpaid_invoices()), 0)

    def testListPartiallyPaidInvoices(self):
        self.assertGreater(len(self.client.list_partially_paid_invoices()), 0)

    def testListPaidInvoices(self):
        self.assertGreater(len(self.client.list_paid_invoices()), 0)
# -*- coding: utf-8 -*-
from pysuperfaktura.SFClient import SFClient
from pysuperfaktura.invoice import SFInvoiceClient, SFInvoice, SFInvoiceItem
from pysuperfaktura.expense import SFExpenseClient, SFExpense, SFExpenseItem
import datetime

api_client = SFClient('<email>', '<api_key>')
""" filtr: bezna, minuly mesic (hodnota 5) """
invfilter = {'created': '5', 'type': 'regular', 'per_page': '1000'}
expfilter = {'created': '5', 'per_page': '1000'}

invs = api_client.list_invoices(invfilter)
exps = api_client.list_expenses(expfilter)

total_amount = 0
total_vat = 0
kha5_amount = 0
kha5_vat = 0
kha4 = []
if (invs is not None):
    for inv in invs:
        item = inv.params.get("Invoice")
        item_name = item.get("name")
        item_invoiceno = item.get("invoice_no_formatted")
        item_amount = round(float(item.get("amount")), 2)
        item_vat = round(float(item.get("vat")), 2)
        item_dic = inv.params.get("Client").get("ic_dph")
        if (item_dic[:2] != "CZ"):
            print(u'Invalid DIC ({0})!'.format(item_dic))
        item_delivery = item.get("delivery").split()[0]
        dictitem = {