コード例 #1
0
def invoice(order):
    os.environ["INVOICE_LANG"] = "en"

    info = UserAddress.objects.get(user=order.client)
    info_seller = UserAddress.objects.get(user=User.objects.get(
        username='******'))
    client = Client('{}'.format(info.company_name),
                    '{} {}'.format(info.home_number, info.local_number),
                    '{} {}'.format(info.post, info.city))
    provider = Provider('{}'.format(info_seller.company_name),
                        '{} {}'.format(info_seller.home_number,
                                       info_seller.local_number),
                        '{} {}'.format(info_seller.post, info_seller.city),
                        bank_account='00000',
                        bank_code='0000')
    creator = Creator('Shop')

    invoice = Invoice(client, provider, creator)
    invoice.currency_locale = 'en_US.UTF-8'
    for item in order.product_list.product_list.all():
        invoice.add_item(
            Item('{}'.format(item.amount),
                 '{}'.format(item.product.price),
                 description="{}".format(item.product.name)))

    pdf = SimpleInvoice(invoice)
    pdf.gen("pro-forma.pdf")
コード例 #2
0
ファイル: actions.py プロジェクト: Amanul-Haque/FoodBot
    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker,
            domain: Dict) -> List[EventType]:
        items = tracker.get_slot("dish")
        quant = tracker.get_slot("quant")
        id = tracker.get_slot("email")
        import os

        from tempfile import NamedTemporaryFile

        from InvoiceGenerator.api import Invoice, Item, Client, Provider, Creator

        os.environ["INVOICE_LANG"] = "en"

        client = Client('Valuable Customer')
        provider = Provider('XYZEE', bank_account='00000', bank_code='0000')
        creator = Creator('Amanul Haque')

        invoice = Invoice(client, provider, creator)
        invoice.currency_locale = 'en_US.UTF-8'
        for item, quantity in zip(items, quant):
            invoice.add_item(Item(quantity, 00, description=item))

        from InvoiceGenerator.pdf import SimpleInvoice

        pdf = SimpleInvoice(invoice)
        pdf.gen("D:\GoBaskt-Intern\Food CB\invoices\invoice.pdf",
                generate_qr_code=True)

        dispatcher.utter_message(text='Invoice Created')
        return []
コード例 #3
0
    def test_price(self):
        invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))
        items = [Item(1, 500), Item(2, 500), Item(3, 500)]
        for item in items:
            invoice.add_item(item)

        self.assertEqual(sum([item.total for item in items]), invoice.price)
コード例 #4
0
    def test_add_item(self):
        invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))

        self.assertRaises(AssertionError, invoice.add_item, '')

        for item in [Item(1, 500), Item(2, 500), Item(3, 500)]:
            invoice.add_item(item)

        self.assertEquals(3, len(invoice.items))
コード例 #5
0
 def pdf_data(self):
     invoice = Invoice(client, provider, creator)
     invoice.currency_locale = 'en_IN.UTF-8'
     fire_data = self.firebase.get('/' + self.email + '/' + self.date, None)
     for x, y in fire_data.items():
         invoice.add_item(
             Item(y['quantity'], y['price'], description=y['name']))
     pdf = SimpleInvoice(invoice)
     pdf.gen("invoice.pdf", generate_qr_code=True)
コード例 #6
0
def setClient(clientName, clientAddress, clientPostCode, clientAdditionalData):
    client = Client(clientName, clientAddress, clientPostCode,
                    clientAdditionalData)
    invoice = Invoice(client,
                      provider,
                      creator,
                      number=datetime.datetime.now().strftime("%d-%m-%y"))
    invoice.currency_locale = 'pl_PL.UTF-8'
    invoice.use_tax = True
    return invoice
コード例 #7
0
    def test_price_tax(self):
        invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))
        items = [
            Item(1, 500, tax='99.9'),
            Item(2, 500, tax='99.9'),
            Item(3, 500, tax='99.9'),
        ]
        for item in items:
            invoice.add_item(item)

        self.assertEqual(5997, invoice.price_tax)
コード例 #8
0
    def test_generate_with_vat(self):
        invoice = Invoice(Client('Kkkk'), Provider('Pupik'), Creator('blah'))
        invoice.add_item(Item(32, 600))
        invoice.add_item(Item(60, 50, tax=10))
        invoice.add_item(Item(50, 60, tax=5))
        invoice.add_item(Item(5, 600, tax=50))

        tmp_file = NamedTemporaryFile()

        pdf = SimpleInvoice(invoice)
        pdf.gen(tmp_file.name)
コード例 #9
0
ファイル: test_api.py プロジェクト: willsim/InvoiceGenerator
    def test_price_tax(self):
        invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))
        items = [
            Item(1, 500, tax='99.9'),
            Item(2, 500, tax='99.9'),
            Item(3, 500, tax='99.9'),
        ]
        for item in items:
            invoice.add_item(item)

        self.assertEqual(5997, invoice.price_tax)
コード例 #10
0
ファイル: test_pdf.py プロジェクト: tvieira/InvoiceGenerator
    def test_generate_with_vat(self):
        invoice = Invoice(Client('Kkkk'), Provider('Pupik'), Creator('blah'))
        invoice.add_item(Item(32, 600))
        invoice.add_item(Item(60, 50, tax=10))
        invoice.add_item(Item(50, 60, tax=5))
        invoice.add_item(Item(5, 600, tax=50))
        invoice.currency_locale = 'en_US.UTF-8'

        tmp_file = NamedTemporaryFile(delete=False)

        pdf = SimpleInvoice(invoice)
        pdf.gen(tmp_file.name)
コード例 #11
0
    def _get_invoice(self, order, clientName):
        client = Client(clientName)
        provider = Provider(os.getenv("company"), bank_account=os.getenv("bank_account"),
                            bank_code=os.getenv("bank_code"))
        creator = Creator(os.getenv("creator"))

        invoice = Invoice(client, provider, creator)
        for snapshot in order.snapshots:
            invoice.add_item(Item(count=snapshot.quantity, price=snapshot.price, description=snapshot.name,
                                  tax=int(os.getenv("Vat")), unit='$'))
        invoice.currency = '$'
        return invoice
コード例 #12
0
ファイル: test_pdf.py プロジェクト: Fizzmint/InvoiceGenerator
    def test_generate_with_vat(self):
        invoice = Invoice(Client('Kkkk'), Provider('Pupik'), Creator('blah'))
        invoice.add_item(Item(32, 600))
        invoice.add_item(Item(60, 50, tax=10))
        invoice.add_item(Item(50, 60, tax=5))
        invoice.add_item(Item(5, 600, tax=50))

        tmp_file = NamedTemporaryFile()

        pdf = SimpleInvoice(invoice)
        pdf.gen(tmp_file.name)
コード例 #13
0
def setProvider(clientName, clientAddress, clientPostCode,
                clientAdditionalData):
    provider = Provider(clientName, clientAddress, clientPostCode,
                        clientAdditionalData)
    client = Client('AS Lomza',
                    'Niewodowo 50',
                    "18-421 Piątnica",
                    bank_account='2600420569',
                    bank_code='2010')
    invoice = Invoice(client,
                      provider,
                      creator,
                      number=datetime.datetime.now().strftime("%d-%m-%y"))
    invoice.currency_locale = 'pl_PL.UTF-8'
    invoice.use_tax = True
    return invoice
コード例 #14
0
    def test_check_attrs(self):
        attrs = ('title', 'variable_symbol', 'specific_symbol', 'paytype',
                 'currency', 'date', 'payback', 'taxable_date')

        invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))

        for attr in attrs:
            self.assertTrue(hasattr(invoice, attr))
コード例 #15
0
ファイル: routes.py プロジェクト: tariqumd/hms
def invoice():
    pat = request.form.get('patient')
    idn = request.form.get('id')
    name = pat + "_" + idn
    client = Client(name)
    addr = Address(add)
    provider = Provider('ABC HOSPITAL',
                        bank_account='2600420569',
                        bank_code='2010')
    creator = Creator('DESK EXECUTIVE')
    bed = request.form.get('bedcost')
    med = request.form.get('medcost')
    dia = request.form.get('diacost')
    tot = request.form.get('total')
    d = request.form.get('Days')

    invoice = Invoice(client, provider, creator)
    invoice.currency = 'Rs'
    invoice.add_item(Item(d, bed, description="Bed cost"))
    invoice.add_item(Item(1, med, description="Medicine"))
    invoice.add_item(Item(1, dia, description="Diagnosis"))

    pdf = SimpleInvoice(invoice)
    url = "application/invoice/" + pat + "_" + idn + ".pdf"
    pdf.gen(url, generate_qr_code=True)

    patient_up = db.session.query(Patient).get(idn)
    patient_up.status = "discharged"
    db.session.commit()
    flash("Patient Discharged , Invoice generated in Invoice folder",
          "success")
    return redirect('/billing')
コード例 #16
0
def booking_invoice(request, booking_id):
    if request.method == 'POST':
        form = CreateInvoiceForm(request.POST or None)
        if form.is_valid():
            booking = Booking.objects.get(id=booking_id)
            gs = GuestBooking.objects.filter(booking=booking).first()
            items = RoomServiceBooking.objects.filter(booking=booking).all()
            os.environ["INVOICE_LANG"] = "en"
            client = Client(xstr(gs.guest.name) + " " + xstr(gs.guest.surname),
                            phone=xstr(gs.guest.phone),
                            email=xstr(gs.guest.email),
                            vat_id=xstr(gs.guest.id_number),
                            address=xstr(gs.guest.address),
                            zip_code=xstr(gs.guest.zip_code))
            provider = Provider(
                'Yahomas',
                bank_account='22946662932',
                bank_code='210',
                city="Istanbul",
                zip_code="34700",
                phone="+9002122443262",
                # logo_filename="/home/tugcan/Dropbox/SWE/Yahomas/yahomas_stamp_small.png"
            )
            creator = Creator(
                'Yahomas',
                # stamp_filename="/home/tugcan/Dropbox/SWE/Yahomas/YahomasStamp.png"
            )
            invoice = Invoice(client, provider, creator)
            invoice.currency = "$"
            invoice.number = str(booking_id)[:13]
            days = abs((booking.start_date - booking.end_date).days)
            if days <= 0:
                days = 1
            invoice.add_item(
                Item(days,
                     booking.room.price *
                     (100 - float(form.cleaned_data['discount'])) / 100,
                     description="Room 1"))
            for item in items:
                invoice.add_item(
                    Item(1, item.item.price, description=item.item.name))

            pdf = SimpleInvoice(invoice)
            file_path = f"{djangoSettings.STATIC_ROOT}/{str(booking_id)}.pdf"
            pdf.gen(file_path, generate_qr_code=True)

            with open(file_path, 'rb') as file:
                response = HttpResponse(file.read(),
                                        content_type='application/pdf')
                response[
                    'Content-Disposition'] = 'attachment; filename=invoice.pdf'
                return response
コード例 #17
0
ファイル: create.py プロジェクト: sravani-k17/ASE-1-WcMS
def create_invoice(user, order):
    os.environ["INVOICE_LANG"] = "en"

    client_address = user.customer.street + ',<br/>' + user.customer.area
    client_zip_code = user.customer.zipcode
    client_phone = str(user.customer.phone)
    client_email = user.email

    provider_address = 'No.185, Bellman Ford St.' + ',<br/>' + 'T. Nagar'
    provider_zip_code = '600056'
    provider_phone = '044-42353988'
    provider_email = '*****@*****.**'
    payment_method = order.get_payment_type_display()

    client = Client(
        summary=user.customer.fullname,
        address=client_address,
        zip_code=client_zip_code,
        phone=client_phone,
        email=client_email,
    )
    provider = Provider(
        summary='The Water Company',
        address=provider_address,
        zip_code=provider_zip_code,
        phone=provider_phone,
        email=provider_email,
        payment_method=payment_method,
    )
    creator = Creator('TWC')

    invoice = Invoice(client, provider, creator, str(order.id))
    invoice.currency_locale = 'en.UTF-8'
    items = OrderItem.objects.filter(order=order)
    for item in items:
        invoice.add_item(
            Item(item.quantity, item.price, description=item.product.name))

    pdf = SimpleInvoice(invoice)
    pdf.gen(MEDIA_ROOT + '/orders/' + str(order.id) + ".pdf",
            generate_qr_code=False)
コード例 #18
0
    def test_generate_breakdown_vat_table(self):
        invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))
        invoice.add_item(Item(1, 500, tax=50))
        invoice.add_item(Item(3, 500, tax=50))
        invoice.add_item(Item(500, 5, tax=0))
        invoice.add_item(Item(5, 500, tax=0))

        expected = [(0.00, 5000.0, 5000.0, 0),(50.0, 2000.0, 3000.0, 1000.0)]

        self.assertEquals(expected, invoice.generate_breakdown_vat_table())
コード例 #19
0
def gen_receipt(car_no='HR 02 AK 9064',mins = 50):
    os.environ["INVOICE_LANG"] = "en"
    client = Client("R/C Number: "+car_no)
    provider = Provider('Tez Parking', bank_account='2600420569', bank_code='2010',address='Tez Parking\n NIT Jalandhar', city='Jalandhar\n Punjab', zip_code='144001', phone='9138121216', email='*****@*****.**',  logo_filename='think.png')
    creator = Creator('Parking Operator')
    now = time()
    now = int(now)
    now = str(now)
    invoice = Invoice(client, provider, creator)
    invoice.currency_locale = 'en_US.UTF-8'
    rate =0.5
    if mins <= 60:
        rate = 20/60
    elif mins >60 and mins <= 180:
        rate = 40/60
    elif mins > 180 and mins <=300:
        rate = 50/60
    elif mins > 300 and mins <= 480:
        rate = 60/60
    elif mins > 480 and mins <= 720:
        rate = 80/60
    elif mins > 720 and mins <= 1440:
        rate = 100/60

    invoice_no = now+car_no[-4:]
    invoice.add_item(Item(mins, rate, description="Parking slot booking"))
    invoice.number = invoice_no

    pdf = SimpleInvoice(invoice)
    pdf.gen(invoice_no+".pdf", generate_qr_code=True)
    return invoice_no
コード例 #20
0
ファイル: test_api.py プロジェクト: willsim/InvoiceGenerator
 def test_price_tax_rounding(self):
     """
     Test, that the price that sums up to 1756.5 gets rounded according to rounding strategy.
     """
     invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))
     invoice.add_item(Item(5, 290, tax=21))
     invoice.rounding_result = True
     invoice.use_tax = True
     self.assertEqual(1754, invoice.price_tax)
     invoice.rounding_strategy = decimal.ROUND_HALF_UP
     self.assertEqual(1755, invoice.price_tax)
コード例 #21
0
    def test_generate_breakdown_vat(self):
        invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))
        invoice.add_item(Item(1, 500, tax=50))
        invoice.add_item(Item(3, 500, tax=50))
        invoice.add_item(Item(500, 5, tax=0))
        invoice.add_item(Item(5, 500, tax=0))

        expected = {
            0.0: {'total': 5000.0, 'total_tax': 5000.0, 'tax': 0.0},
            50.0: {'total': 2000.0, 'total_tax': 3000.0, 'tax': 1000}}

        self.assertEquals(expected, invoice.generate_breakdown_vat())
コード例 #22
0
def invoice():
    form = InvoiceForm()
    print(form)
    if form.validate_on_submit():
        client = form.client.data
        creator = form.creator.data
        item_name = form.item_name.data
        price = form.price.data
        quantity = form.quantity.data
        a = current_user
        client = Client(client)
        provider = Provider(a.name, bank_account=a.gstnumber, bank_code='2018')
        creator = Creator(creator)
        os.environ["INVOICE_LANG"] = "en"
        invoice = Invoice(client, provider, creator)
        invoice.currency_locale = "en_US.UTF_8"

        invoice.add_item(Item(quantity, price, item_name))
        from InvoiceGenerator.pdf import SimpleInvoice
        pdf = SimpleInvoice(invoice)
        pdf.gen("invoice.pdf", generate_qr_code=False)
        return send_file("invoice.pdf")
    return render_template('invoice.html', form=form)
コード例 #23
0
    def invoicing(self, c, lines, iva=21, invoice_num=None):
        if not invoice_num:
            invoice_num = "F000001"
        else:
            invoice_num = 'F{}'.format(str(invoice_num).zfill(6))
        # choose catalan language
        os.environ["INVOICE_LANG"] = "ca"

        client = Client(
            c.name, address=c.direccio, zip_code=c.cp, phone=c.phone, email=c.email, vat_id=c.cif,
        )
        name, cp, address, city, email, phone = self.get_config_file_info()

        provider = Provider(
            name, zip_code=cp, address=address, city=city, email=email, phone=phone, vat_id='E17087289',
            logo_filename=ICONS + '/logo_factura.jpg'
        )

        creator = Creator(name)

        invoice = Invoice(client, provider, creator)
        os.environ["INVOICE_LANG"] = "ca"
        invoice.currency_locale = 'ca_ES.UTF-8'
        invoice.currency = '€'
        invoice.number = invoice_num
        invoice.use_tax = True
        invoice.date = datetime.now()
        for line_product in lines:
            price_without_iva = self.extract_iva(line_product.price, iva)
            invoice.add_item(
                Item(
                    count=line_product.quant, price=float(price_without_iva), description=line_product.name, tax=iva
                )
            )

        f = NamedTemporaryFile(delete=False, suffix='.pdf')
        pdf_path = f.name
        pdf = SimpleInvoice(invoice)
        pdf.gen(pdf_path, generate_qr_code=False)

        return pdf_path
コード例 #24
0
def bill_generator(request):
    try:
        global bill_no
        fs = FileSystemStorage()
        os.environ["INVOICE_LANG"] = "en"
        table_no = request.data["no"]
        client = Client('Table ' + str(table_no))
        clerk = request.data["email"]
        provider = Provider('Restaurant',
                            bank_account='2600420569',
                            bank_code='2010')
        creator = Creator(clerk)
        invoice = Invoice(client, provider, creator)

        data = request.data["order"]  # quantity,price, name

        invoice.currency_locale = 'en_IN'
        invoice.currency = "INR"
        invoice.number = bill_no
        balance = list(Variable.objects.all().values())[0]["balance"]
        bill_no += 1

        for item in data:
            invoice.add_item(
                Item(item[1], item[2] / item[1], description=item[0], tax=14))
            my_custom_sql(
                "insert into sales(item_code,quantity) values({},{})".format(
                    int(item[3]), item[1]))
            balance += item[2]
            #print("select count(*) from sales where (item_code = {} && date >= {});".format(item[3], str((datetime.today() - timedelta(days=3)).strftime("%Y-%d,%Y"))))
            # count = my_custom_sql("select count(*) from sales where (item_code = {} && date >= {});".format(item[3], str((datetime.today() - timedelta(days=3)).strftime("%Y-%m-%d"))))[0][0]

        Variable.objects.all().delete()
        Variable(balance=balance).save()
        filename = "invoice" + str(bill_no) + ".pdf"
        pdf = SimpleInvoice(invoice)
        pdf.gen(filename, generate_qr_code=True)
        t = Thread(target=calculateThreshold, args=(data, ))
        t.start()

        if fs.exists(filename):
            with fs.open(filename) as pdf:
                response = HttpResponse(pdf, content_type='application/pdf')
                #response['Content-Disposition'] = 'attachment; filename="mypdf.pdf"' #user will be prompted with the browser’s open/save file
                response['Content-Disposition'] = 'inline; filename={}'.format(
                    filename
                )  #user will be prompted display the PDF in the browser
                return response

    except FileNotFoundError:
        raise Http404()
コード例 #25
0
 def test_price_tax_rounding(self):
     """
     Test, that the price that sums up to 1756.5 gets rounded according to rounding strategy.
     """
     invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))
     invoice.add_item(Item(5, 290, tax=21))
     invoice.rounding_result = True
     invoice.use_tax = True
     self.assertEqual(1754, invoice.price_tax)
     invoice.rounding_strategy = decimal.ROUND_HALF_UP
     self.assertEqual(1755, invoice.price_tax)
コード例 #26
0
    def test_generate(self):
        provider = Provider('Pupik')
        provider.address = 'Kubelikova blah blah blah'
        provider.zip = '12655465'
        provider.city = 'Frantisek'
        provider.vat_id = 'CZ8590875682'
        provider.ir = '785684523'
        provider.email = '*****@*****.**'
        provider.bank_account = '56484984968/68'
        provider.bank_name = 'RB'
        provider.note = u'zapsaná v obchodním rejstříku vedeném městským soudem v Praze,\noddíl C, vložka 176551'

        client = Client('Kkkk')
        client.summary = 'Bla blah blah'
        client.address = 'Kubelikova blah blah blah'
        client.zip = '12655465'
        client.city = 'Frantisek'
        client.vat_id = 'CZ8590875682'
        client.ir = '785684523'
        client.phone = '785684523'
        client.email = '*****@*****.**'
        client.note = u'zapsaná v obchodním rejstříku vedeném městským soudem v Praze,\noddíl C, vložka 176551'

        invoice = Invoice(client, provider, Creator('blah'))
        invoice.add_item(Item(32, 600, tax=50))
        invoice.add_item(Item(32, 600, tax=0))
        invoice.specific_symbol = 666
        invoice.taxable_date = '1.1.1979'
        invoice.variable_symbol = '000000001'
        invoice.currency = u'Kč'


        tmp_file = NamedTemporaryFile()

        pdf = SimpleInvoice(invoice)
        pdf.gen(tmp_file.name)
コード例 #27
0
def create_invoice(provider_name, provider_address, provider_postcode, client_name, client_address, client_postcode, items_list):
    provider = Provider(provider_name, provider_address, provider_postcode, bank_account='2600420569', bank_code='2010')
    creator = Creator('')
    client = Client(client_name, client_address, client_postcode)

    invoice = Invoice(client, provider, creator, number=datetime.datetime.now().strftime("%d-%m-%y"))
    invoice.currency_locale = 'pl_PL.UTF-8'
    invoice.use_tax = False
    for i in range(0,len(items_list),3):
        item_count = items_list[i]
        item_price = items_list[i+1]
        item_name = items_list[i+2]
        invoice.add_item(Item(item_count, item_price, description=item_name))
    pdf = ProformaInvoice(invoice)
    pdf.gen("Proforma.pdf", generate_qr_code=False)
コード例 #28
0
    def test_difference_rounding(self):
        invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))
        invoice.add_item(Item(1, 2.5, tax=50))

        self.assertEquals(0.25, invoice.difference_in_rounding)
コード例 #29
0
ファイル: test_pdf.py プロジェクト: creckx/InvoiceGenerator
    def test_generate_with_vat(self):
        os.environ["INVOICE_LANG"] = "en"
        invoice = Invoice(Client('Kkkk'), Provider('Pupik'), Creator('blah'))
        invoice.number = 'F20140001'
        invoice.use_tax = True
        invoice.add_item(Item(32, 600))
        invoice.add_item(Item(60, 50, tax=10))
        invoice.add_item(Item(50, 60, tax=5))
        invoice.add_item(Item(5, 600, tax=50))
        invoice.currency_locale = 'en_US.UTF-8'
        invoice.currency = 'USD'

        tmp_file = NamedTemporaryFile(delete=False)

        pdf = SimpleInvoice(invoice)
        pdf.gen(tmp_file.name)

        pdf = PdfFileReader(tmp_file)
        pdf_string = pdf.pages[0].extractText()
        self.assertTrue(u"$3,000.00" in pdf_string)
        self.assertTrue(u"Total with tax: $30,150.00" in pdf_string)
        self.assertTrue(u"Creator: blah" in pdf_string)
コード例 #30
0
ファイル: test_pdf.py プロジェクト: creckx/InvoiceGenerator
    def test_generate(self):
        provider = Provider('Pupik')
        provider.address = 'Kubelikova blah blah blah'
        provider.zip_code = '12655465'
        provider.city = 'Frantisek'
        provider.vat_id = 'CZ8590875682'
        provider.ir = '785684523'
        provider.email = '*****@*****.**'
        provider.bank_account = '2600420569'
        provider.bank_code = '2010'
        provider.bank_name = 'RB'
        provider.note = u'zapsaná v obchodním rejstříku vedeném městským soudem v Praze,\noddíl C, vložka 176551'

        client = Client('Kkkk')
        client.summary = 'Bla blah blah'
        client.address = 'Kubelikova blah blah blah'
        client.zip_code = '12655465'
        client.city = 'Frantisek'
        client.vat_id = 'CZ8590875682'
        client.ir = '785684523'
        client.phone = '785684523'
        client.email = '*****@*****.**'
        client.note = u'zapsaná v obchodním rejstříku vedeném městským soudem v Praze,\noddíl C, vložka 176551'

        invoice = Invoice(client, provider, Creator('blah'))
        invoice.use_tax = True
        invoice.title = u"Testovací faktura"
        invoice.add_item(Item(32, 600.6, description=u"Krátký popis", tax=50))
        invoice.add_item(Item(32, 2.5, tax=20))
        invoice.add_item(
            Item(
                5,
                25.42,
                description=u"Dlouhý popis blah blah blah blah blah blah blah blah blah blah blah "
                            u"blah blah blah blah blah blah blah blah blah blah blah blah blah blah "
                            u"blah blah blah blah blah blah blah blah blah blah blah",
                tax=20,
            ),
        )
        for i in range(1, 26):
            invoice.add_item(Item(5, 25.42, description=u"Popis", tax=0))
        invoice.specific_symbol = 666
        invoice.taxable_date = datetime.date.today()
        invoice.variable_symbol = '000000001'
        invoice.number = 'F20140001'
        invoice.payback = datetime.date.today()
        invoice.currency = u'Kč'
        invoice.currency_locale = 'cs_CZ.UTF-8'
        invoice.rounding_result = True

        tmp_file = NamedTemporaryFile(delete=False)
        pdf = SimpleInvoice(invoice)
        pdf.gen(tmp_file.name, True)

        invoice.number = 1
        invoice.reason = u"Položka navíc"
        tmp_file1 = NamedTemporaryFile(delete=False)
        pdf = CorrectingInvoice(invoice)
        pdf.gen(tmp_file1.name)

        pdf = PdfFileReader(tmp_file1)
        pdf_string = pdf.pages[1].extractText()
        self.assertTrue(u"Celkem s DPH: 32⁄255,-⁄K…" in pdf_string)
        self.assertTrue(u"Vytvo‹il: blah" in pdf_string)
コード例 #31
0
    def test_use_tax(self):
        invoice = Invoice(Client('Foo'), Provider('Bar'), Creator('Blah'))
        invoice.add_item(Item(1, 500, tax=99.9))
        invoice.add_item(Item(500, 5))

        self.assertTrue(invoice.use_tax)
コード例 #32
0
 def _build_invoice(self):
     invoice = Invoice(Client("John"), Provider("Doe"), Creator("John Doe"))
     invoice.add_item(Item(42, 666))
     return invoice
コード例 #33
0
    def test_generate(self):
        provider = Provider('Pupik')
        provider.address = 'Kubelikova blah blah blah'
        provider.zip_code = '12655465'
        provider.city = 'Frantisek'
        provider.vat_id = 'CZ8590875682'
        provider.ir = '785684523'
        provider.email = '*****@*****.**'
        provider.bank_account = '2600420569'
        provider.bank_code = '2010'
        provider.bank_name = 'RB'
        provider.note = u'zapsaná v obchodním rejstříku vedeném městským soudem v Praze,\noddíl C, vložka 176551'

        client = Client('Kkkk')
        client.summary = 'Bla blah blah'
        client.address = 'Kubelikova blah blah blah'
        client.zip_code = '12655465'
        client.city = 'Frantisek'
        client.vat_id = 'CZ8590875682'
        client.ir = '785684523'
        client.phone = '785684523'
        client.email = '*****@*****.**'
        client.note = u'zapsaná v obchodním rejstříku vedeném městským soudem v Praze,\noddíl C, vložka 176551'

        invoice = Invoice(client, provider, Creator('blah'))
        invoice.use_tax = True
        invoice.title = u"Testovací faktura"
        invoice.add_item(Item(32, '600.6', description=u"Krátký popis", tax=15))
        invoice.add_item(Item(32, '2.5', tax=21))
        invoice.add_item(
            Item(
                5, '25.42',
                description=u"Dlouhý popis blah blah blah blah blah blah blah blah blah blah blah "
                            u"blah blah blah blah blah blah blah blah blah blah blah blah blah blah "
                            u"blah blah blah blah blah blah blah blah blah blah blah",
                tax=21,),)
        for i in range(1, 26):
            invoice.add_item(Item(5, '25.42', description=u"Popis", tax=0))
        invoice.specific_symbol = 666
        invoice.taxable_date = datetime.date.today()
        invoice.variable_symbol = '000000001'
        invoice.number = 'F20140001'
        invoice.payback = datetime.date.today()
        invoice.currency = u'Kč'
        invoice.currency_locale = 'cs_CZ.UTF-8'
        invoice.rounding_result = True

        tmp_file = NamedTemporaryFile(delete=False)
        SimpleInvoice(invoice).gen(tmp_file.name)
        xml_string = tmp_file.read()

        root = self.assertXmlDocument(xml_string)
        self.assertXpathValues(
            root,
            './dataPack/dataPackItem/invoice/partnerIdentity/address/street/text()',
            'Kubelikova blah blah blah',
        )
        self.assertXpathValues(
            root,
            './dataPack/dataPackItem/invoice/invoiceHeader/number/numberRequested/text()',
            'F20140001',
        )
        self.assertXpathValues(
            root,
            './dataPack/dataPackItem/invoice/invoiceDetail/invoiceItem/text/text()',
            'Popis',
        )
        self.assertXpathValues(
            root,
            './dataPack/dataPackItem/invoice/invoiceSummary/priceLow/text/text()',
            '22102.080',
        )
        self.assertXpathValues(
            root,
            './dataPack/dataPackItem/invoice/invoiceSummary/priceHighVAT/text/text()',
            '43.4910',
        )
コード例 #34
0
import os

from tempfile import NamedTemporaryFile

from InvoiceGenerator.api import Invoice, Item, Client, Provider, Creator
from InvoiceGenerator.pdf import SimpleInvoice
# choose english as language
os.environ["INVOICE_LANG"] = "en"

client = Client('Client company')
provider = Provider('My company', bank_account='2600420569', bank_code='2010')
creator = Creator('John Doe')

invoice = Invoice(client, provider, creator)
invoice.currency_locale = 'en_US.UTF-8'
invoice.add_item(Item(32, 600, description="Item 1"))
invoice.add_item(Item(60, 50, description="Item 2", tax=21))
invoice.add_item(Item(50, 60, description="Item 3", tax=0))
invoice.add_item(Item(5, 600, description="Item 4", tax=15))

pdf = SimpleInvoice(invoice)
pdf.gen("invoice.pdf", generate_qr_code=True)
コード例 #35
0
locale.setlocale(locale.LC_ALL, '')

client = Client(name=u"Polidea Sp. z o.o.",
                address1=u"Przeskok 2",
                address2=u"00-032 Warszawa",
                nip="7010185832")

provider = Provider(name=u"Polidea Sp. z o.o.",
                    address1=u"Przeskok 2",
                    address2=u"00-032 Warszawa",
                    nip="7010185832",
                    bank_name="Bank",
                    bank_account="11 2222 3333 4444 5555 6666 7777")

invoice_number = u"1/1/2015"
invoice_date = u"23.01.2015"

invoice = Invoice(client, provider, invoice_number, invoice_date)
invoice.add_item(
    Item(name=u"Usługa programistyczna\nusługa B która będzie bardzo długa",
         count=1,
         unit_price=1000,
         tax=23))
invoice.add_item(
    Item(name=u"Usługa programistyczna 2", count=1, unit_price=1500, tax=8))
invoice.add_item(
    Item(name=u"Usługa programistyczna 3", count=1, unit_price=12454, tax=23))

pdf = SimpleInvoice(invoice, 'invoice.pdf')
コード例 #36
0
 def _build_invoice(self):
     invoice = Invoice(Client('John'), Provider('Doe'), Creator('John Doe'))
     invoice.add_item(Item(42, 666))
     return invoice
コード例 #37
0
from InvoiceGenerator.pdf import SimpleInvoice
from tempfile import NamedTemporaryFile

# choose en as language
os.environ["INVOICE_LANG"] = "tr"

client = Client('İşin Başı Reklam Bilgi Teknolojileri ve Ticaret A.Ş')
client.address = 'GÜLBAHÇE GÜLBAHÇE CAD.NO:1/17'
client.city = 'URLA/İZMİR'
client.zip = '35000'
client.vat_id = '4820575342'
client.ir = 'Urla'
provider = Provider('İşin Başı Reklam Bilgi Teknolojileri ve Ticaret A.Ş')
provider.address = 'GÜLBAHÇE GÜLBAHÇE CAD.NO:1/17'
provider.city = 'URLA/İZMİR'
provider.zip = '35000'
provider.vat_id = '4820575342'
provider.ir = 'Urla'
creator = Creator('Workif')

invoice = Invoice(client, provider, creator)
invoice.currency_locale = 'tr_TR.UTF-8'
invoice.currency = '₺'
invoice.date = '10-12-2017'
invoice.number = '205123123112'
invoice.add_item(Item(1, 1.24, description="Ödeme Hizmeti Komisyonu"))

tmp_file = NamedTemporaryFile(delete=False)
pdf = SimpleInvoice(invoice)
a = pdf.gen(tmp_file.name)
print(a)
コード例 #38
0
ファイル: invoice.py プロジェクト: gdalvarezr/telegram-bot
from tempfile import NamedTemporaryFile

from InvoiceGenerator.api import Invoice, Item, Client, Provider, Creator
from InvoiceGenerator.pdf import SimpleInvoice


client = Client('Client company')
provider = Provider('My company', bank_account='2600420569/2010')
creator = Creator('John Doe')

invoice = Invoice(client, provider, creator)
invoice.currency_locale = 'en_US.UTF-8'
invoice.add_item(Item(32, 600, description="Item 1"))
invoice.add_item(Item(60, 50, description="Item 2", tax=10))
invoice.add_item(Item(50, 60, description="Item 3", tax=5))
invoice.add_item(Item(5, 600, description="Item 4", tax=50))

tmp_file = NamedTemporaryFile(delete=False)
pdf = SimpleInvoice(invoice)
pdf.gen(tmp_file.name, generate_qr_code=False)
コード例 #39
0
ファイル: mz_invoicing.py プロジェクト: zvolsky/mz-invoicing
    client.address = "Houští 474"
    client.city = "Lanškroun"
    client.zip = "563 01"
    client.phone = "+420777636388"
    client.email = "*****@*****.**"
    client.bank_name = "GE Money Bank"
    client.bank_account = "181553009/0600"
    client.note = "Blablabla"

    item1 = Item()
    item1.name = "Položka 1"
    item1.count = 5
    item1.price = 100
    item2 = Item()
    item2.name = "Položka 2"
    item2.count = 10
    item2.price = 750

    invoice = Invoice()
    invoice.setClient(client)
    invoice.setProvider(provider)
    invoice.setTitle("Faktura")
    invoice.setVS("00001")
    invoice.setCreator("Adam Štrauch")
    invoice.addItem(item1)
    invoice.addItem(item2)

    f = open("test.pdf", "w")
    f.write(invoice.getContent())
    f.close()
コード例 #40
0
ファイル: views.py プロジェクト: kreedyX/group-project
    def post(self, *args, **kwargs):
        form = CheckoutForm(self.request.POST or None)
        if self.request.user.profile.is_warsztat():
            form = WarsztatCheckoutForm(self.request.POST or None)

        try:
            order = Order.objects.get(customer=self.request.user, ordered=False)
            if form.is_valid():
                street_address = form.cleaned_data.get('street_address')
                apartment_address = form.cleaned_data.get('apartment_address')
                country = form.cleaned_data.get('country')
                zip_code = form.cleaned_data.get('zip_code')
                payment_option = form.cleaned_data.get('payment_option')

                checkout_address = CheckoutAddress(
                    user=self.request.user,
                    street_address=street_address,
                    apartment_address=apartment_address,
                    country=country,
                    zip_code=zip_code
                )
                checkout_address.save()
                order.checkout_address = checkout_address
                order.save()

                PAYMENT_OPTIONS = tuple()
                if self.request.user.profile.is_warsztat():
                    PAYMENT_OPTIONS = PAYMENT_WARSZTAT
                else:
                    PAYMENT_OPTIONS = PAYMENT

                for payment_tuple in PAYMENT_OPTIONS:
                    if payment_option == payment_tuple[0]:
                        order.payment_method = payment_tuple[1]
                        order.ordered = True

                        if order.payment_method == 'Faktura':
                            os.environ["INVOICE_LANG"] = "pl"

                            client = Client(order.customer.username + '<br />'
                                            + str(order.customer.email) + '<br />'
                                            + order.customer.profile.street_address + '<br />'
                                            + order.customer.profile.postal_code + ' '
                                            + order.customer.profile.city
                                            )
                            provider = Provider('Auto Parts', bank_account='2600420569', bank_code='2010')
                            creator = Creator('Jan Kowalski')
                            invoice = Invoice(client, provider, creator)
                            invoice.number = order.id
                            invoice.currency = 'PLN'
                            invoice.currency_locale = 'pl_PL.UTF-8'
                            for order_line in order.order_lines.all():
                                invoice.add_item(Item(order_line.quantity, order_line.product.get_discount_price(),
                                                      description=order_line.product.name, tax=23))

                            pdf_name = "invoice" + str(order.id) + ".pdf"
                            pdf = SimpleInvoice(invoice)
                            pdf.gen(pdf_name)
                            with open(pdf_name, 'rb') as f:
                                order.invoice_file.save(pdf_name, File(f))
                            if os.path.exists(pdf_name):
                                os.remove(pdf_name)

                        order.save()
                        return redirect('pages:orders_list')

                messages.warning(self.request, "Niepoprawna metoda płatności")
                return redirect('pages:checkout')

        except ObjectDoesNotExist:
            messages.error(self.request, "Nie masz żadnego zamówienia")
            return redirect("pages:order-summary")
コード例 #41
0
import os
from tempfile import NamedTemporaryFile
from InvoiceGenerator.api import Invoice, Item, Client, Provider, Creator, Address
from InvoiceGenerator.pdf import SimpleInvoice

# choose english as language
os.environ["INVOICE_LANG"] = "en"

my_paypal = '*****@*****.**'
client_paypal = '*****@*****.**'
client = Client(summary = 'Karelyns Vegan ', address = '100 5th street', city = 'Miami Florida', zip_code = '', note = f'PayPal Email: {client_paypal}')
provider = Provider(summary = 'S.C. BIMP Network S.R.L.', address = 'Str. Crinilor, Nr. 31', city = 'Mircea Voda, Jud. Braila', zip_code = '817095', note = f'PayPal Email: {my_paypal}')
creator = Creator('Rares-Adrian Mosescu')


invoice = Invoice(client, provider, creator)
invoice.currency_locale = 'en_US.UTF-8'
invoice.currency= '$'
number = 1
invoice.number = f'BIMP-{number}'
invoice.add_item(Item(1, 65, description="Instagram Promotion"))

pdf = SimpleInvoice(invoice)
pdf.gen("invoice.pdf")
コード例 #42
0
ファイル: test_pdf.py プロジェクト: tvieira/InvoiceGenerator
    def test_generate_proforma(self):
        provider = Provider('Pupik')
        provider.address = 'Kubelikova blah blah blah'
        provider.zip = '12655465'
        provider.city = 'Frantisek'
        provider.vat_id = 'CZ8590875682'
        provider.ir = '785684523'
        provider.email = '*****@*****.**'
        provider.bank_account = '2600420569/2010'
        provider.bank_name = 'RB'
        provider.note = u'zapsaná v obchodním rejstříku vedeném městským soudem v Praze,\noddíl C, vložka 176551'

        client = Client('Kkkk')
        client.summary = 'Bla blah blah'
        client.address = 'Kubelikova blah blah blah'
        client.zip = '12655465'
        client.city = 'Frantisek'
        client.vat_id = 'CZ8590875682'
        client.ir = '785684523'
        client.phone = '785684523'
        client.email = '*****@*****.**'
        client.note = u'zapsaná v obchodním rejstříku vedeném městským soudem v Praze,\noddíl C, vložka 176551'

        invoice = Invoice(client, provider, Creator('blah'))
        invoice.title = u"Proforma faktura"
        invoice.add_item(Item(32, 600.6, description=u"Krátký popis", tax=50))
        invoice.add_item(Item(32, 2.5, tax=20))
        invoice.add_item(Item(5, 25.42,
                              description=u"Dlouhý popis blah blah blah blah blah blah blah blah blah blah blah "
                                          u"blah blah blah blah blah blah blah blah blah blah blah blah blah blah "
                                          u"blah blah blah blah blah blah blah blah blah blah blah",
                              tax=20))
        for i in range(1, 26):
            invoice.add_item(Item(5, 25.42, description=u"Popis", tax=0))
        invoice.specific_symbol = 666
        invoice.date = datetime.date.today()
        invoice.variable_symbol = '000000001'
        invoice.payback = datetime.date.today()
        invoice.currency = u'Kč'
        invoice.currency_locale = 'cs_CZ.UTF-8'
        invoice.rounding_result = True

        tmp_file = NamedTemporaryFile(delete=False)
        pdf = ProformaInvoice(invoice)
        pdf.gen(tmp_file.name, True)
コード例 #43
0
def generate_invoice(invoice):
    DIR = os.path.dirname(__file__)

    client = Client(
        invoice.company_name,
        division=invoice.company_address_recipient,
        country=invoice.country,
        address=" ".join(
            filter(
                None,
                (invoice.company_address_street,
                 invoice.company_address_street_number),
            )),
        zip_code=str(invoice.company_address_psc or ""),
        city=invoice.company_address_city,
        ir=invoice.company_ico,
        vat_id=invoice.company_dic,
        phone=invoice.telephone,
        email=invoice.email,
        note=invoice.client_note,
    )

    if invoice.order_number:
        client.note += "\nČíslo objednávky: %s" % invoice.order_number

    provider = Provider(
        "AutoMat, z.s.",
        email="*****@*****.**",
        address="Vodičkova 704/36",
        zip_code="110 00",
        city="Praha 1",
        bank_name="Fio banka",
        bank_account="2601085491",
        bank_code="2010",
        vat_id="CZ22670319",
        ir="22670319",
        phone="212 240 666",
        logo_filename=os.path.join(DIR, "static/img/logo_am.png"),
        note=
        "Spolek je veden u Městského soudu v Praze pod spisovou značkou L 18119. "
        "AutoMat - společně s vámi tvoříme město, ve kterém chceme žít."
        "\nhttps://www.auto-mat.cz",
    )

    creator = Creator(
        "Klára Dušáková",
        stamp_filename=os.path.join(DIR, "static/img/podpis.png"),
    )

    invoice_gen = Invoice(client, provider, creator)
    invoice_gen.title = "Faktura %s/%03d" % (
        invoice.exposure_date.year,
        invoice.sequence_number,
    )
    invoice_gen.variable_symbol = invoice.variable_symbol
    invoice_gen.number = invoice.document_number()
    invoice_gen.date = invoice.exposure_date
    invoice_gen.payback = invoice.payback_date
    invoice_gen.taxable_date = invoice.taxable_date
    invoice_gen.rounding_result = True
    invoice_gen.rounding_strategy = decimal.ROUND_HALF_UP
    invoice_gen.use_tax = True
    invoice_gen.currency_locale = "cs_CZ.UTF-8"
    invoice_gen.paytype = "bankovním převodem"

    for payment in invoice.payment_set.order_by(
            "user_attendance__userprofile__user__last_name",
            "user_attendance__userprofile__user__first_name",
    ):
        if invoice.company_pais_benefitial_fee:
            amount = invoice.campaign.benefitial_admission_fee_company
        else:
            amount = payment.amount
        description = "Platba za soutěžící/ho %s" % (
            "" if invoice.anonymize else
            payment.user_attendance.name_for_trusted())
        invoice_gen.add_item(Item(1, amount, description=description, tax=21))
    return invoice_gen