-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathreceipt.py
65 lines (44 loc) · 3.18 KB
/
receipt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from datetime import datetime
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
class Address(BaseModel):
street: Optional[str] = Field(None, description="Street address")
city: Optional[str] = Field(None, description="City")
state: Optional[str] = Field(None, description="State")
postal_code: Optional[str] = Field(None, description="Postal code")
country: Optional[str] = Field(None, description="Country")
class Item(BaseModel):
description: str = Field(..., description="Description or name of the item")
quantity: Optional[float] = Field(None, description="Quantity of the item")
unit_price: Optional[float] = Field(None, description="Unit price of the item")
total_price: Optional[float] = Field(None, description="Total price of the item")
class PaymentMethod(BaseModel):
type: str = Field(..., description="Type of payment (e.g., cash, credit card, debit card)")
card_last_4: Optional[str] = Field(None, description="Last 4 digits of the card if applicable")
card_type: Optional[str] = Field(None, description="Type of card if applicable")
class Receipt(BaseModel):
receipt_id: Optional[str] = Field(None, description="Unique receipt identifier")
transaction_date: Optional[datetime] = Field(None, description="Date and time of the transaction")
merchant_name: Optional[str] = Field(None, description="Name of the merchant")
merchant_address: Optional[Address] = Field(None, description="Address of the merchant")
merchant_phone: Optional[str] = Field(None, description="Phone number of the merchant")
cashier_name: Optional[str] = Field(None, description="Name of the cashier")
register_number: Optional[str] = Field(None, description="Register or POS terminal number")
customer_name: Optional[str] = Field(None, description="Name of the customer if provided")
customer_id: Optional[str] = Field(None, description="Customer ID or loyalty number if applicable")
items: List[Item] = Field(..., description="Items purchased")
subtotal: Optional[float] = Field(None, description="Subtotal of the purchase")
tax: Optional[float] = Field(None, description="Tax amount")
total: float = Field(..., description="Total amount of the purchase")
currency: str = Field(..., description="Currency of the transaction")
payment_method: PaymentMethod = Field(..., description="Method of payment")
discount_amount: Optional[float] = Field(None, description="Amount of discount applied")
discount_description: Optional[str] = Field(None, description="Description of the discount")
tip_amount: Optional[float] = Field(None, description="Tip amount if applicable")
return_policy: Optional[str] = Field(None, description="Return policy information")
barcode: Optional[str] = Field(None, description="Barcode or QR code data if present")
additional_charges: Optional[List[Dict]] = Field(None, description="Any additional charges (e.g., service fees)")
notes: Optional[str] = Field(None, description="Any additional notes or comments")
others: Optional[Dict[str, Any]] = Field(
None, description="Other information on the receipt not captured by other fields"
)