library-fine-calculator 0.1.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.
- library_fine_calculator-0.1.0/PKG-INFO +39 -0
- library_fine_calculator-0.1.0/README.md +32 -0
- library_fine_calculator-0.1.0/library_fine_calculator.egg-info/PKG-INFO +39 -0
- library_fine_calculator-0.1.0/library_fine_calculator.egg-info/SOURCES.txt +8 -0
- library_fine_calculator-0.1.0/library_fine_calculator.egg-info/dependency_links.txt +1 -0
- library_fine_calculator-0.1.0/library_fine_calculator.egg-info/top_level.txt +1 -0
- library_fine_calculator-0.1.0/library_pkg/ActualTask.py.py +54 -0
- library_fine_calculator-0.1.0/library_pkg/__init__.py.py +4 -0
- library_fine_calculator-0.1.0/pyproject.toml +15 -0
- library_fine_calculator-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: library-fine-calculator
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python package for calculating library fines
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
\# Library Fine Calculator
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
A Python package for calculating library fines.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
\## Features
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
\- Calculate overdue days
|
|
21
|
+
|
|
22
|
+
\- Calculate library fines
|
|
23
|
+
|
|
24
|
+
\- Generate payment summaries
|
|
25
|
+
|
|
26
|
+
\- Calculate book due dates
|
|
27
|
+
|
|
28
|
+
\- Calculate discounted fines
|
|
29
|
+
|
|
30
|
+
\- Check book return status
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
\## Installation
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
pip install library-fine-calculator
|
|
39
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
\# Library Fine Calculator
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
A Python package for calculating library fines.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
\## Features
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
\- Calculate overdue days
|
|
14
|
+
|
|
15
|
+
\- Calculate library fines
|
|
16
|
+
|
|
17
|
+
\- Generate payment summaries
|
|
18
|
+
|
|
19
|
+
\- Calculate book due dates
|
|
20
|
+
|
|
21
|
+
\- Calculate discounted fines
|
|
22
|
+
|
|
23
|
+
\- Check book return status
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
\## Installation
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
pip install library-fine-calculator
|
|
32
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: library-fine-calculator
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python package for calculating library fines
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
\# Library Fine Calculator
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
A Python package for calculating library fines.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
\## Features
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
\- Calculate overdue days
|
|
21
|
+
|
|
22
|
+
\- Calculate library fines
|
|
23
|
+
|
|
24
|
+
\- Generate payment summaries
|
|
25
|
+
|
|
26
|
+
\- Calculate book due dates
|
|
27
|
+
|
|
28
|
+
\- Calculate discounted fines
|
|
29
|
+
|
|
30
|
+
\- Check book return status
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
\## Installation
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
pip install library-fine-calculator
|
|
39
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
library_fine_calculator.egg-info/PKG-INFO
|
|
4
|
+
library_fine_calculator.egg-info/SOURCES.txt
|
|
5
|
+
library_fine_calculator.egg-info/dependency_links.txt
|
|
6
|
+
library_fine_calculator.egg-info/top_level.txt
|
|
7
|
+
library_pkg/ActualTask.py.py
|
|
8
|
+
library_pkg/__init__.py.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
library_pkg
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from datetime import datetime, timedelta
|
|
2
|
+
|
|
3
|
+
def overdue_days(due_date, return_date):
|
|
4
|
+
"""Calculate late days using YYYY-MM-DD dates."""
|
|
5
|
+
try:
|
|
6
|
+
due = datetime.strptime(due_date, "%Y-%m-%d").date()
|
|
7
|
+
returned = datetime.strptime(return_date, "%Y-%m-%d").date()
|
|
8
|
+
except ValueError:
|
|
9
|
+
raise ValueError("Dates must be valid and use YYYY-MM-DD format.")
|
|
10
|
+
return max((returned - due).days, 0)
|
|
11
|
+
|
|
12
|
+
def calculate_fine(days, fine_per_day=2):
|
|
13
|
+
"""Calculate the basic fine."""
|
|
14
|
+
if not isinstance(days, int) or isinstance(days, bool) or days < 0:
|
|
15
|
+
raise ValueError("Overdue days must be a non-negative whole number.")
|
|
16
|
+
if not isinstance(fine_per_day, (int, float)) or isinstance(fine_per_day, bool) or fine_per_day < 0:
|
|
17
|
+
raise ValueError("Fine per day must be a non-negative number.")
|
|
18
|
+
return round(days * fine_per_day, 2)
|
|
19
|
+
|
|
20
|
+
def payment_summary(book_title, days, fine_per_day=2, discount_percent=0):
|
|
21
|
+
"""Create a dictionary containing the payment details."""
|
|
22
|
+
if not isinstance(book_title, str) or not book_title.strip():
|
|
23
|
+
raise ValueError("Book title cannot be empty.")
|
|
24
|
+
basic = calculate_fine(days, fine_per_day)
|
|
25
|
+
final = calculate_discounted_fine(basic, discount_percent)
|
|
26
|
+
return {
|
|
27
|
+
"book_title": book_title.strip(), "overdue_days": days,
|
|
28
|
+
"fine_per_day": fine_per_day, "basic_fine": basic,
|
|
29
|
+
"discount_percent": discount_percent, "total_fine": final
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def calculate_due_date(issue_date, loan_period=14):
|
|
33
|
+
"""Calculate due date from issue date and allowed loan days."""
|
|
34
|
+
try:
|
|
35
|
+
issued = datetime.strptime(issue_date, "%Y-%m-%d").date()
|
|
36
|
+
except ValueError:
|
|
37
|
+
raise ValueError("Issue date must be valid and use YYYY-MM-DD format.")
|
|
38
|
+
if not isinstance(loan_period, int) or isinstance(loan_period, bool) or loan_period <= 0:
|
|
39
|
+
raise ValueError("Loan period must be a positive whole number.")
|
|
40
|
+
return (issued + timedelta(days=loan_period)).isoformat()
|
|
41
|
+
|
|
42
|
+
def calculate_discounted_fine(fine, discount_percent=0):
|
|
43
|
+
"""Apply a membership discount percentage."""
|
|
44
|
+
if not isinstance(fine, (int, float)) or isinstance(fine, bool) or fine < 0:
|
|
45
|
+
raise ValueError("Fine must be a non-negative number.")
|
|
46
|
+
if not isinstance(discount_percent, (int, float)) or isinstance(discount_percent, bool) or not 0 <= discount_percent <= 100:
|
|
47
|
+
raise ValueError("Discount must be between 0 and 100.")
|
|
48
|
+
return round(fine * (1 - discount_percent / 100), 2)
|
|
49
|
+
|
|
50
|
+
def get_return_status(days):
|
|
51
|
+
"""Return whether the book was returned on time or late."""
|
|
52
|
+
if not isinstance(days, int) or isinstance(days, bool) or days < 0:
|
|
53
|
+
raise ValueError("Overdue days must be a non-negative whole number.")
|
|
54
|
+
return "Returned on time. No fine." if days == 0 else "Book returned late. Fine payable."
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
[build-system]
|
|
3
|
+
requires = ["setuptools>=61.0"]
|
|
4
|
+
build-backend = "setuptools.build_meta"
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
name = "library-fine-calculator"
|
|
8
|
+
version = "0.1.0"
|
|
9
|
+
description = "A Python package for calculating library fines"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
|
|
13
|
+
[tool.setuptools.packages.find]
|
|
14
|
+
where = ["."]
|
|
15
|
+
include = ["library_pkg*"]
|