invoicingPDFPDFPDF 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: invoicingPDFPDFPDF
3
+ Version: 1.0.0
4
+ Summary: This package can be used to convert Excel invoices to PDF invoices.
5
+ Home-page: https://example.com
6
+ Author: YYY
7
+ Author-email: a@yyy.com
8
+ License: MIT
9
+ Keywords: invoice,excel,pdf
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Build Tools
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Requires-Dist: pandas
21
+ Requires-Dist: fpdf
22
+ Requires-Dist: openpyxl
23
+ Dynamic: author
24
+ Dynamic: author-email
25
+ Dynamic: classifier
26
+ Dynamic: home-page
27
+ Dynamic: keywords
28
+ Dynamic: license
29
+ Dynamic: requires-dist
30
+ Dynamic: summary
@@ -0,0 +1 @@
1
+ from .invoice import generate
@@ -0,0 +1,81 @@
1
+ import pandas as pd
2
+ import glob
3
+ from fpdf import FPDF
4
+ from pathlib import Path
5
+ import os
6
+
7
+
8
+
9
+ def generate(invoices_path, pdfs_path, image_path, product_id, product_name, amount_purchased, price_per_unit, total_price):
10
+
11
+ """
12
+ This function converts invoice Excel files into PDF invoices.
13
+ :param invoices_path:
14
+ :param pdfs_path:
15
+ :param image_path:
16
+ :param product_id:
17
+ :param product_name:
18
+ :param amount_purchased:
19
+ :param price_per_unit:
20
+ :param total_price:
21
+ :return:
22
+ """
23
+ filepaths = glob.glob(f"{invoices_path}/*.xlsx")
24
+
25
+ for filepath in filepaths:
26
+
27
+ pdf = FPDF(orientation="P", unit="mm", format="A4")
28
+ pdf.add_page()
29
+
30
+ filename = Path(filepath).stem
31
+ invoice_nr, date = filename.split("-")
32
+
33
+ pdf.set_font(family="Times", size=16, style="B")
34
+ pdf.cell(w=50, h=8, txt=f"Invoice nr.{invoice_nr}", ln=1)
35
+
36
+ pdf.set_font(family="Times", size=16, style="B")
37
+ pdf.cell(w=50, h=8, txt=f"Date: {date}", ln=1)
38
+
39
+ df = pd.read_excel(filepath, sheet_name="Sheet 1")
40
+
41
+ # Add a header
42
+ columns = df.columns
43
+ columns = [item.replace("_", " ").title() for item in columns]
44
+ pdf.set_font(family="Times", size=10, style="B")
45
+ pdf.set_text_color(80, 80, 80)
46
+ pdf.cell(w=30, h=8, txt=columns[0], border=1)
47
+ pdf.cell(w=70, h=8, txt=columns[1], border=1)
48
+ pdf.cell(w=30, h=8, txt=columns[2], border=1)
49
+ pdf.cell(w=30, h=8, txt=columns[3], border=1)
50
+ pdf.cell(w=30, h=8, txt=columns[4], border=1, ln=1)
51
+
52
+ # Add rows to the table
53
+ for index, row in df.iterrows():
54
+ pdf.set_font(family="Times", size=10)
55
+ pdf.set_text_color(80, 80, 80)
56
+ pdf.cell(w=30, h=8, txt=str(row[product_id]), border=1)
57
+ pdf.cell(w=70, h=8, txt=str(row[product_name]), border=1)
58
+ pdf.cell(w=30, h=8, txt=str(row[amount_purchased]), border=1)
59
+ pdf.cell(w=30, h=8, txt=str(row[price_per_unit]), border=1)
60
+ pdf.cell(w=30, h=8, txt=str(row[total_price]), border=1, ln=1)
61
+
62
+ total_sum = df["total_price"].sum()
63
+ pdf.set_font(family="Times", size=10)
64
+ pdf.set_text_color(80, 80, 80)
65
+ pdf.cell(w=30, h=8, txt="", border=1)
66
+ pdf.cell(w=70, h=8, txt="", border=1)
67
+ pdf.cell(w=30, h=8, txt="", border=1)
68
+ pdf.cell(w=30, h=8, txt="", border=1)
69
+ pdf.cell(w=30, h=8, txt=str(total_sum), border=1, ln=1)
70
+
71
+ # Add total sum sentence
72
+ pdf.set_font(family="Times", size=10, style="B")
73
+ pdf.cell(w=30, h=8, txt=f"The total price is {total_sum}", ln=1)
74
+
75
+ # Add company name and logo
76
+ pdf.set_font(family="Times", size=14, style="B")
77
+ pdf.cell(w=25, h=8, txt=f"PythonHow")
78
+ pdf.image(image_path, w=10)
79
+
80
+ os.makedirs(pdfs_path, exist_ok=True)
81
+ pdf.output(f"{pdfs_path}/{filename}.pdf")
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: invoicingPDFPDFPDF
3
+ Version: 1.0.0
4
+ Summary: This package can be used to convert Excel invoices to PDF invoices.
5
+ Home-page: https://example.com
6
+ Author: YYY
7
+ Author-email: a@yyy.com
8
+ License: MIT
9
+ Keywords: invoice,excel,pdf
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Build Tools
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Requires-Dist: pandas
21
+ Requires-Dist: fpdf
22
+ Requires-Dist: openpyxl
23
+ Dynamic: author
24
+ Dynamic: author-email
25
+ Dynamic: classifier
26
+ Dynamic: home-page
27
+ Dynamic: keywords
28
+ Dynamic: license
29
+ Dynamic: requires-dist
30
+ Dynamic: summary
@@ -0,0 +1,8 @@
1
+ setup.py
2
+ invoicing/__init__.py
3
+ invoicing/invoice.py
4
+ invoicingPDFPDFPDF.egg-info/PKG-INFO
5
+ invoicingPDFPDFPDF.egg-info/SOURCES.txt
6
+ invoicingPDFPDFPDF.egg-info/dependency_links.txt
7
+ invoicingPDFPDFPDF.egg-info/requires.txt
8
+ invoicingPDFPDFPDF.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ pandas
2
+ fpdf
3
+ openpyxl
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,27 @@
1
+ from setuptools import setup
2
+
3
+
4
+ setup(
5
+ name = 'invoicingPDFPDFPDF', #* Your package will have this name
6
+ packages = ['invoicing'], #* Name the package again
7
+ version = '1.0.0', #* To be increased every time your change your library
8
+ license='MIT', # Type of license. More here: https://help.github.com/articles/licensing-a-repository
9
+ description = 'This package can be used to convert Excel invoices to PDF invoices.', # Short description of your library
10
+ author = 'YYY', # Your name
11
+ author_email = 'a@yyy.com', # Your email
12
+ url = 'https://example.com', # Homepage of your library (e.g. github or your website)
13
+ keywords = ['invoice', 'excel', 'pdf'], # Keywords users can search on pypi.org
14
+ install_requires=['pandas', 'fpdf', 'openpyxl'], # Other 3rd-party libs that pip needs to install
15
+ classifiers=[
16
+ 'Development Status :: 3 - Alpha', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
17
+ 'Intended Audience :: Developers', # Who is the audience for your library?
18
+ 'Topic :: Software Development :: Build Tools',
19
+ 'License :: OSI Approved :: MIT License', # Type a license again
20
+ 'Programming Language :: Python :: 3.8', # Python versions that your library supports
21
+ 'Programming Language :: Python :: 3.9',
22
+ 'Programming Language :: Python :: 3.10',
23
+ 'Programming Language :: Python :: 3.11',
24
+ 'Programming Language :: Python :: 3.12',
25
+ 'Programming Language :: Python :: 3.13'
26
+ ],
27
+ )