branddrive-python-sdk 0.1.0__py3-none-any.whl
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.
- branddrive/__init__.py +33 -0
- branddrive/client.py +134 -0
- branddrive/config.py +15 -0
- branddrive/dataclasses/__init__.py +118 -0
- branddrive/dataclasses/_utils.py +8 -0
- branddrive/dataclasses/customers.py +66 -0
- branddrive/dataclasses/expenses.py +155 -0
- branddrive/dataclasses/invoices.py +131 -0
- branddrive/dataclasses/payment_links.py +134 -0
- branddrive/dataclasses/pos.py +141 -0
- branddrive/dataclasses/products.py +166 -0
- branddrive/dataclasses/purchase_orders.py +141 -0
- branddrive/dataclasses/services.py +76 -0
- branddrive/dataclasses/vendors.py +48 -0
- branddrive/dataclasses/wallets.py +72 -0
- branddrive/exceptions.py +35 -0
- branddrive/protocols/__init__.py +43 -0
- branddrive/protocols/analytics.py +61 -0
- branddrive/protocols/customers.py +42 -0
- branddrive/protocols/expenses.py +69 -0
- branddrive/protocols/invoices.py +81 -0
- branddrive/protocols/payment_links.py +49 -0
- branddrive/protocols/pos.py +88 -0
- branddrive/protocols/products.py +150 -0
- branddrive/protocols/purchase_orders.py +68 -0
- branddrive/protocols/services.py +56 -0
- branddrive/protocols/vendors.py +39 -0
- branddrive/protocols/wallets.py +52 -0
- branddrive/resources/__init__.py +125 -0
- branddrive/resources/_utils.py +10 -0
- branddrive/resources/analytics.py +198 -0
- branddrive/resources/customers.py +194 -0
- branddrive/resources/expenses.py +209 -0
- branddrive/resources/invoices.py +268 -0
- branddrive/resources/payment_links.py +265 -0
- branddrive/resources/pos.py +353 -0
- branddrive/resources/products.py +612 -0
- branddrive/resources/purchase_orders.py +235 -0
- branddrive/resources/services.py +184 -0
- branddrive/resources/vendors.py +152 -0
- branddrive/resources/wallets.py +204 -0
- branddrive_python_sdk-0.1.0.dist-info/METADATA +132 -0
- branddrive_python_sdk-0.1.0.dist-info/RECORD +45 -0
- branddrive_python_sdk-0.1.0.dist-info/WHEEL +5 -0
- branddrive_python_sdk-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any, Literal, Optional
|
|
5
|
+
|
|
6
|
+
from ._utils import omit_none
|
|
7
|
+
|
|
8
|
+
PaymentLinkSubscriptionDuration = Literal[
|
|
9
|
+
"MONTHLY",
|
|
10
|
+
"YEARLY",
|
|
11
|
+
"HOURLY",
|
|
12
|
+
"DAILY",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class PaymentLinkCategoryCreate:
|
|
18
|
+
"""Fields used to add a category to a payment link."""
|
|
19
|
+
|
|
20
|
+
amount: int | float
|
|
21
|
+
title: str
|
|
22
|
+
description: Optional[str] = None
|
|
23
|
+
|
|
24
|
+
def to_dict(self) -> dict[str, Any]:
|
|
25
|
+
return omit_none({
|
|
26
|
+
"amount": self.amount,
|
|
27
|
+
"title": self.title,
|
|
28
|
+
"description": self.description,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass
|
|
33
|
+
class PaymentLinkCategoryData:
|
|
34
|
+
"""Category fields accepted in a payment link update."""
|
|
35
|
+
|
|
36
|
+
amount: Optional[int | float] = None
|
|
37
|
+
title: Optional[str] = None
|
|
38
|
+
description: Optional[str] = None
|
|
39
|
+
id: Optional[int] = None
|
|
40
|
+
|
|
41
|
+
def to_dict(self) -> dict[str, Any]:
|
|
42
|
+
return omit_none({
|
|
43
|
+
"amount": self.amount,
|
|
44
|
+
"title": self.title,
|
|
45
|
+
"description": self.description,
|
|
46
|
+
"id": self.id,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class PaymentLinkCreate:
|
|
52
|
+
"""Fields used to create a payment link."""
|
|
53
|
+
|
|
54
|
+
is_amount_fixed: bool
|
|
55
|
+
description: str
|
|
56
|
+
title: str
|
|
57
|
+
payment_link_path: str
|
|
58
|
+
categories: str
|
|
59
|
+
redirect_url: Optional[str] = None
|
|
60
|
+
bg_image: Optional[str] = None
|
|
61
|
+
is_sub: Optional[bool] = None
|
|
62
|
+
sub_duration: Optional[PaymentLinkSubscriptionDuration] = None
|
|
63
|
+
sub_interval: Optional[int] = None
|
|
64
|
+
|
|
65
|
+
def to_dict(self) -> dict[str, Any]:
|
|
66
|
+
return omit_none({
|
|
67
|
+
"isAmountFixed": self.is_amount_fixed,
|
|
68
|
+
"description": self.description,
|
|
69
|
+
"title": self.title,
|
|
70
|
+
"paymentLinkPath": self.payment_link_path,
|
|
71
|
+
"categories": self.categories,
|
|
72
|
+
"redirectUrl": self.redirect_url,
|
|
73
|
+
"bgImage": self.bg_image,
|
|
74
|
+
"isSub": self.is_sub,
|
|
75
|
+
"subDuration": self.sub_duration,
|
|
76
|
+
"subInterval": self.sub_interval,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@dataclass
|
|
81
|
+
class PaymentLinkUpdate:
|
|
82
|
+
"""Optional fields accepted when updating a payment link."""
|
|
83
|
+
|
|
84
|
+
is_amount_fixed: Optional[bool] = None
|
|
85
|
+
description: Optional[str] = None
|
|
86
|
+
title: Optional[str] = None
|
|
87
|
+
payment_link_path: Optional[str] = None
|
|
88
|
+
redirect_url: Optional[str] = None
|
|
89
|
+
bg_image: Optional[str] = None
|
|
90
|
+
is_sub: Optional[bool] = None
|
|
91
|
+
sub_duration: Optional[PaymentLinkSubscriptionDuration] = None
|
|
92
|
+
sub_interval: Optional[int] = None
|
|
93
|
+
categories: Optional[list[PaymentLinkCategoryData]] = None
|
|
94
|
+
|
|
95
|
+
def to_dict(self) -> dict[str, Any]:
|
|
96
|
+
categories = (
|
|
97
|
+
[category.to_dict() for category in self.categories]
|
|
98
|
+
if self.categories is not None
|
|
99
|
+
else None
|
|
100
|
+
)
|
|
101
|
+
return omit_none({
|
|
102
|
+
"isAmountFixed": self.is_amount_fixed,
|
|
103
|
+
"description": self.description,
|
|
104
|
+
"title": self.title,
|
|
105
|
+
"paymentLinkPath": self.payment_link_path,
|
|
106
|
+
"redirectUrl": self.redirect_url,
|
|
107
|
+
"bgImage": self.bg_image,
|
|
108
|
+
"isSub": self.is_sub,
|
|
109
|
+
"subDuration": self.sub_duration,
|
|
110
|
+
"subInterval": self.sub_interval,
|
|
111
|
+
"categories": categories,
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@dataclass
|
|
116
|
+
class PaymentLinkPayData:
|
|
117
|
+
"""Customer and amount data for paying through a payment link."""
|
|
118
|
+
|
|
119
|
+
payment_link_code: str
|
|
120
|
+
amount: int | float
|
|
121
|
+
customer_email: str
|
|
122
|
+
first_name: str
|
|
123
|
+
last_name: str
|
|
124
|
+
phone_number: str
|
|
125
|
+
|
|
126
|
+
def to_dict(self) -> dict[str, Any]:
|
|
127
|
+
return {
|
|
128
|
+
"paymentLinkCode": self.payment_link_code,
|
|
129
|
+
"amount": self.amount,
|
|
130
|
+
"customerEmail": self.customer_email,
|
|
131
|
+
"firstName": self.first_name,
|
|
132
|
+
"lastName": self.last_name,
|
|
133
|
+
"phoneNumber": self.phone_number,
|
|
134
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Optional, Any, Iterable
|
|
5
|
+
|
|
6
|
+
from ._utils import omit_none
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _serialize_procurements(procurements: Optional[Iterable[Any]]) -> Optional[list[dict[str, Any]]]:
|
|
10
|
+
if procurements is None:
|
|
11
|
+
return None
|
|
12
|
+
return [procurement.to_dict() for procurement in procurements]
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class POSProcurement:
|
|
16
|
+
id: int
|
|
17
|
+
title: Optional[str] = None
|
|
18
|
+
description: Optional[str] = None
|
|
19
|
+
amount: Optional[str] = None
|
|
20
|
+
|
|
21
|
+
def to_dict(self) -> dict[str, str | int | None]:
|
|
22
|
+
return omit_none({
|
|
23
|
+
"id": self.id,
|
|
24
|
+
"amount": self.amount,
|
|
25
|
+
"title": self.title,
|
|
26
|
+
"description": self.description,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
@dataclass
|
|
30
|
+
class POSPaymentProcurement:
|
|
31
|
+
amount: Optional[int] = None
|
|
32
|
+
category_id: Optional[int] = None
|
|
33
|
+
description: Optional[str] = None
|
|
34
|
+
|
|
35
|
+
def to_dict(self) -> dict[str, Any]:
|
|
36
|
+
return omit_none({
|
|
37
|
+
"amount": self.amount,
|
|
38
|
+
"categoryId": self.category_id,
|
|
39
|
+
"description": self.description,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
@dataclass
|
|
43
|
+
class POSCreate:
|
|
44
|
+
customer_id: int
|
|
45
|
+
mode_of_payment: str
|
|
46
|
+
discount: int
|
|
47
|
+
tax: float
|
|
48
|
+
branch_id: int
|
|
49
|
+
table_id: Optional[int] = None
|
|
50
|
+
procurements: Optional[list[POSProcurement]] = None
|
|
51
|
+
|
|
52
|
+
def to_dict(self) -> dict[str, Any]:
|
|
53
|
+
payload: dict[str, Any] = {
|
|
54
|
+
"customerId": self.customer_id,
|
|
55
|
+
"modeOfPayment": self.mode_of_payment,
|
|
56
|
+
"discount": self.discount,
|
|
57
|
+
"tax": self.tax,
|
|
58
|
+
"branchId": self.branch_id,
|
|
59
|
+
"tableId": self.table_id,
|
|
60
|
+
"procurements": _serialize_procurements(self.procurements),
|
|
61
|
+
}
|
|
62
|
+
return omit_none(payload)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@dataclass
|
|
66
|
+
class PosUpdate:
|
|
67
|
+
customer_id: Optional[int] = None
|
|
68
|
+
mode_of_payment: Optional[str] = None
|
|
69
|
+
discount: Optional[int] = None
|
|
70
|
+
tax: Optional[float] = None
|
|
71
|
+
branch_id: Optional[int] = None
|
|
72
|
+
table_id: Optional[int] = None
|
|
73
|
+
|
|
74
|
+
def to_dict(self) -> dict[str, Any]:
|
|
75
|
+
return omit_none({
|
|
76
|
+
"customerId": self.customer_id,
|
|
77
|
+
"modeOfPayment": self.mode_of_payment,
|
|
78
|
+
"discount": self.discount,
|
|
79
|
+
"tax": self.tax,
|
|
80
|
+
"branchId": self.branch_id,
|
|
81
|
+
"tableId": self.table_id,
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class POSProductProcurement:
|
|
87
|
+
"""Product or service procurement to add to an existing POS order."""
|
|
88
|
+
|
|
89
|
+
quantity: int
|
|
90
|
+
product_id: Optional[int] = None
|
|
91
|
+
service_id: Optional[int] = None
|
|
92
|
+
|
|
93
|
+
def to_dict(self) -> dict[str, int]:
|
|
94
|
+
if (self.product_id is None) == (self.service_id is None):
|
|
95
|
+
raise ValueError("Provide exactly one of product_id or service_id")
|
|
96
|
+
return omit_none({
|
|
97
|
+
"quantity": self.quantity,
|
|
98
|
+
"productId": self.product_id,
|
|
99
|
+
"serviceId": self.service_id,
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@dataclass
|
|
104
|
+
class POSProcurementUpdate:
|
|
105
|
+
"""Quantity update for an existing POS procurement."""
|
|
106
|
+
|
|
107
|
+
quantity: int
|
|
108
|
+
|
|
109
|
+
def to_dict(self) -> dict[str, int]:
|
|
110
|
+
return omit_none({"quantity": self.quantity})
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@dataclass
|
|
114
|
+
class POSVoidData:
|
|
115
|
+
"""Optional POS fields accepted when voiding a POS order."""
|
|
116
|
+
|
|
117
|
+
customer_id: Optional[int] = None
|
|
118
|
+
mode_of_payment: Optional[str] = None
|
|
119
|
+
discount: Optional[int] = None
|
|
120
|
+
tax: Optional[float] = None
|
|
121
|
+
branch_id: Optional[int] = None
|
|
122
|
+
table_id: Optional[int] = None
|
|
123
|
+
has_tax: Optional[bool] = None
|
|
124
|
+
procurements: Optional[list[POSPaymentProcurement]] = None
|
|
125
|
+
|
|
126
|
+
def to_dict(self) -> dict[str, Any]:
|
|
127
|
+
procurements = (
|
|
128
|
+
[procurement.to_dict() for procurement in self.procurements]
|
|
129
|
+
if self.procurements is not None
|
|
130
|
+
else None
|
|
131
|
+
)
|
|
132
|
+
return omit_none({
|
|
133
|
+
"customerId": self.customer_id,
|
|
134
|
+
"modeOfPayment": self.mode_of_payment,
|
|
135
|
+
"discount": self.discount,
|
|
136
|
+
"tax": self.tax,
|
|
137
|
+
"branchId": self.branch_id,
|
|
138
|
+
"tableId": self.table_id,
|
|
139
|
+
"hasTax": self.has_tax,
|
|
140
|
+
"procurements": procurements,
|
|
141
|
+
})
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Optional, Any
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
|
|
6
|
+
from ._utils import omit_none
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class ProcurementData:
|
|
10
|
+
"""A product procurement associated with an invoice."""
|
|
11
|
+
|
|
12
|
+
product_id: int
|
|
13
|
+
description: str
|
|
14
|
+
price: int
|
|
15
|
+
quantity: int
|
|
16
|
+
is_tax_added: bool = False
|
|
17
|
+
tax: int = 0
|
|
18
|
+
|
|
19
|
+
def to_dict(self) -> dict[str, Any]:
|
|
20
|
+
return omit_none({
|
|
21
|
+
"productId": self.product_id,
|
|
22
|
+
"description": self.description,
|
|
23
|
+
"price": self.price,
|
|
24
|
+
"quantity": self.quantity,
|
|
25
|
+
"isTaxAdded": self.is_tax_added,
|
|
26
|
+
"tax": self.tax,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class UpdateProcurementData:
|
|
32
|
+
"""Partial product-procurement fields for a PATCH request."""
|
|
33
|
+
|
|
34
|
+
product_id: Optional[int] = None
|
|
35
|
+
description: Optional[str] = None
|
|
36
|
+
price: Optional[int] = None
|
|
37
|
+
quantity: Optional[int] = None
|
|
38
|
+
is_tax_added: Optional[bool] = None
|
|
39
|
+
tax: Optional[int] = None
|
|
40
|
+
|
|
41
|
+
def to_dict(self) -> dict[str, Any]:
|
|
42
|
+
return omit_none({
|
|
43
|
+
"productId": self.product_id,
|
|
44
|
+
"description": self.description,
|
|
45
|
+
"price": self.price,
|
|
46
|
+
"quantity": self.quantity,
|
|
47
|
+
"isTaxAdded": self.is_tax_added,
|
|
48
|
+
"tax": self.tax,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@dataclass
|
|
53
|
+
class SingleProductCreate:
|
|
54
|
+
"""Fields used to create a single product."""
|
|
55
|
+
|
|
56
|
+
name: str
|
|
57
|
+
category_id: int
|
|
58
|
+
selling_price: int
|
|
59
|
+
cost_price: int
|
|
60
|
+
branch_id: int
|
|
61
|
+
product_type: str = "SINGLE"
|
|
62
|
+
description: Optional[str] = None
|
|
63
|
+
type: str = "SINGLE"
|
|
64
|
+
|
|
65
|
+
def to_dict(self) -> dict[str, Any]:
|
|
66
|
+
return omit_none({
|
|
67
|
+
"type": self.type,
|
|
68
|
+
"productType": self.product_type,
|
|
69
|
+
"name": self.name,
|
|
70
|
+
"categoryId": self.category_id,
|
|
71
|
+
"description": self.description,
|
|
72
|
+
"sellingPrice": self.selling_price,
|
|
73
|
+
"costPrice": self.cost_price,
|
|
74
|
+
"branchId": self.branch_id,
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@dataclass
|
|
79
|
+
class UpdateProductData:
|
|
80
|
+
"""Partial fields used to update a product."""
|
|
81
|
+
|
|
82
|
+
description: Optional[str] = None
|
|
83
|
+
stock: Optional[int] = None
|
|
84
|
+
name: Optional[str] = None
|
|
85
|
+
minimum_stock_alert: Optional[int] = None
|
|
86
|
+
selling_price: Optional[int] = None
|
|
87
|
+
markup: Optional[int] = None
|
|
88
|
+
|
|
89
|
+
def to_dict(self) -> dict[str, Any]:
|
|
90
|
+
return omit_none({
|
|
91
|
+
"description": self.description,
|
|
92
|
+
"stock": self.stock,
|
|
93
|
+
"name": self.name,
|
|
94
|
+
"minimumStockAlert": self.minimum_stock_alert,
|
|
95
|
+
"sellingPrice": self.selling_price,
|
|
96
|
+
"markup": self.markup,
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
@dataclass
|
|
100
|
+
class ProductDistributionCreate:
|
|
101
|
+
damaged_stock: Optional[int] = 0
|
|
102
|
+
health_stock: Optional[int] = 0
|
|
103
|
+
expired_stock: Optional[int] = 0
|
|
104
|
+
returned_stock: Optional[int] = 0
|
|
105
|
+
branch_id: Optional[int] = 0
|
|
106
|
+
discount: Optional[int] = 0
|
|
107
|
+
|
|
108
|
+
def to_dict(self) -> dict[str, Any]:
|
|
109
|
+
|
|
110
|
+
return omit_none({
|
|
111
|
+
"damagedStock": self.damaged_stock,
|
|
112
|
+
"healthStock": self.health_stock,
|
|
113
|
+
"expiredStock": self.expired_stock,
|
|
114
|
+
"returnedStock": self.returned_stock,
|
|
115
|
+
"branchId": self.branch_id,
|
|
116
|
+
"discount": self.discount
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
@dataclass
|
|
120
|
+
class ProductDistributionUpdate(ProductDistributionCreate):
|
|
121
|
+
id: int = 1
|
|
122
|
+
|
|
123
|
+
def to_dict(self) -> dict[str, Any]:
|
|
124
|
+
return omit_none({
|
|
125
|
+
"damagedStock": self.damaged_stock,
|
|
126
|
+
"healthStock": self.health_stock,
|
|
127
|
+
"expiredStock": self.expired_stock,
|
|
128
|
+
"returnedStock": self.returned_stock,
|
|
129
|
+
"branchId": self.branch_id,
|
|
130
|
+
"discount": self.discount,
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
@dataclass
|
|
134
|
+
class ProductVariationCreate:
|
|
135
|
+
amount: Optional[int] = 0
|
|
136
|
+
name: Optional[str] = None
|
|
137
|
+
stock: Optional[int] = 0
|
|
138
|
+
|
|
139
|
+
def to_dict(self) -> dict[str, str | int | None]:
|
|
140
|
+
return omit_none({
|
|
141
|
+
"amount": self.amount,
|
|
142
|
+
"name": self.name,
|
|
143
|
+
"stock": self.stock,
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
@dataclass
|
|
147
|
+
class ProductCategoryCreate:
|
|
148
|
+
name: str
|
|
149
|
+
description: str
|
|
150
|
+
|
|
151
|
+
def to_dict(self) -> dict[str, str]:
|
|
152
|
+
return omit_none({
|
|
153
|
+
"name": self.name,
|
|
154
|
+
"description": self.description,
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
@dataclass
|
|
158
|
+
class ProductCategoryUpdate:
|
|
159
|
+
name: Optional[str] = None
|
|
160
|
+
description: Optional[str] = None
|
|
161
|
+
|
|
162
|
+
def to_dict(self) -> dict[str, str]:
|
|
163
|
+
return omit_none({
|
|
164
|
+
"name": self.name,
|
|
165
|
+
"description": self.description,
|
|
166
|
+
})
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from datetime import date, datetime
|
|
5
|
+
from typing import Any, Literal, Optional
|
|
6
|
+
|
|
7
|
+
from ._utils import omit_none
|
|
8
|
+
|
|
9
|
+
PurchaseOrderPaymentMethod = Literal[
|
|
10
|
+
"BANK TRANSFER",
|
|
11
|
+
"CARD PAYMENT",
|
|
12
|
+
"CHEQUE",
|
|
13
|
+
"USSD",
|
|
14
|
+
"CASH PAYMENT",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _iso_date(value: Optional[date]) -> Optional[str]:
|
|
19
|
+
if isinstance(value, datetime):
|
|
20
|
+
raise TypeError("date fields must use datetime.date, not datetime.datetime")
|
|
21
|
+
if value is not None and not isinstance(value, date):
|
|
22
|
+
raise TypeError("date fields must be datetime.date instances")
|
|
23
|
+
return value.isoformat() if value is not None else None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class PurchaseOrderProduct:
|
|
28
|
+
"""A product procurement included when creating a purchase order."""
|
|
29
|
+
|
|
30
|
+
product_id: int
|
|
31
|
+
add_stock: int
|
|
32
|
+
price: int | float
|
|
33
|
+
|
|
34
|
+
def to_dict(self) -> dict[str, Any]:
|
|
35
|
+
return omit_none({
|
|
36
|
+
"productId": self.product_id,
|
|
37
|
+
"addStock": self.add_stock,
|
|
38
|
+
"price": self.price,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass
|
|
43
|
+
class PurchaseOrderCreate:
|
|
44
|
+
"""Fields used to create a purchase order."""
|
|
45
|
+
|
|
46
|
+
branch_id: int
|
|
47
|
+
vendor_id: int
|
|
48
|
+
payment_methods: PurchaseOrderPaymentMethod
|
|
49
|
+
procurements: list[PurchaseOrderProduct]
|
|
50
|
+
title: str
|
|
51
|
+
note: str
|
|
52
|
+
description: str
|
|
53
|
+
po_number: int
|
|
54
|
+
discount: int
|
|
55
|
+
due_date: date
|
|
56
|
+
purchase_date: date
|
|
57
|
+
|
|
58
|
+
def to_dict(self) -> dict[str, Any]:
|
|
59
|
+
return omit_none({
|
|
60
|
+
"branchId": self.branch_id,
|
|
61
|
+
"vendorId": self.vendor_id,
|
|
62
|
+
"paymentMethods": self.payment_methods,
|
|
63
|
+
"procurements": [
|
|
64
|
+
procurement.to_dict() for procurement in self.procurements
|
|
65
|
+
],
|
|
66
|
+
"title": self.title,
|
|
67
|
+
"note": self.note,
|
|
68
|
+
"description": self.description,
|
|
69
|
+
"PONumber": self.po_number,
|
|
70
|
+
"discount": self.discount,
|
|
71
|
+
"dueDate": _iso_date(self.due_date),
|
|
72
|
+
"purchaseDate": _iso_date(self.purchase_date),
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@dataclass
|
|
77
|
+
class PurchaseOrderUpdate:
|
|
78
|
+
"""Optional fields accepted when updating a purchase order."""
|
|
79
|
+
|
|
80
|
+
branch_id: Optional[int] = None
|
|
81
|
+
vendor_id: Optional[int] = None
|
|
82
|
+
payment_methods: Optional[PurchaseOrderPaymentMethod] = None
|
|
83
|
+
title: Optional[str] = None
|
|
84
|
+
note: Optional[str] = None
|
|
85
|
+
description: Optional[str] = None
|
|
86
|
+
po_number: Optional[int] = None
|
|
87
|
+
discount: Optional[int] = None
|
|
88
|
+
due_date: Optional[date] = None
|
|
89
|
+
purchase_date: Optional[date] = None
|
|
90
|
+
|
|
91
|
+
def to_dict(self) -> dict[str, Any]:
|
|
92
|
+
return omit_none({
|
|
93
|
+
"branchId": self.branch_id,
|
|
94
|
+
"vendorId": self.vendor_id,
|
|
95
|
+
"paymentMethods": self.payment_methods,
|
|
96
|
+
"title": self.title,
|
|
97
|
+
"note": self.note,
|
|
98
|
+
"description": self.description,
|
|
99
|
+
"PONumber": self.po_number,
|
|
100
|
+
"discount": self.discount,
|
|
101
|
+
"dueDate": _iso_date(self.due_date),
|
|
102
|
+
"purchaseDate": _iso_date(self.purchase_date),
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@dataclass
|
|
107
|
+
class PurchaseOrderProcurementCreate:
|
|
108
|
+
"""A product procurement added to an existing purchase order."""
|
|
109
|
+
|
|
110
|
+
product_id: int
|
|
111
|
+
product_name: str
|
|
112
|
+
product_cost: int | float
|
|
113
|
+
quantity: int
|
|
114
|
+
|
|
115
|
+
def to_dict(self) -> dict[str, Any]:
|
|
116
|
+
return omit_none({
|
|
117
|
+
"productId": self.product_id,
|
|
118
|
+
"productName": self.product_name,
|
|
119
|
+
"productCost": self.product_cost,
|
|
120
|
+
"quantity": self.quantity,
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@dataclass
|
|
125
|
+
class PurchaseOrderPaymentCreate:
|
|
126
|
+
"""A payment recorded against a purchase order."""
|
|
127
|
+
|
|
128
|
+
payment_date: date
|
|
129
|
+
amount: int | float
|
|
130
|
+
payment_method: PurchaseOrderPaymentMethod
|
|
131
|
+
paid_from: Optional[str] = None
|
|
132
|
+
note: Optional[str] = None
|
|
133
|
+
|
|
134
|
+
def to_dict(self) -> dict[str, Any]:
|
|
135
|
+
return omit_none({
|
|
136
|
+
"paymentDate": _iso_date(self.payment_date),
|
|
137
|
+
"amount": self.amount,
|
|
138
|
+
"paymentMethod": self.payment_method,
|
|
139
|
+
"paidFrom": self.paid_from,
|
|
140
|
+
"note": self.note,
|
|
141
|
+
})
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any, Optional
|
|
5
|
+
|
|
6
|
+
from ._utils import omit_none
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class ServiceCategoryCreate:
|
|
11
|
+
"""Fields used to create a service category."""
|
|
12
|
+
|
|
13
|
+
name: str
|
|
14
|
+
description: Optional[str] = None
|
|
15
|
+
|
|
16
|
+
def to_dict(self) -> dict[str, Any]:
|
|
17
|
+
return omit_none({
|
|
18
|
+
"name": self.name,
|
|
19
|
+
"description": self.description,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class ServiceCategoryUpdate:
|
|
25
|
+
"""Optional fields used to update a service category."""
|
|
26
|
+
|
|
27
|
+
name: Optional[str] = None
|
|
28
|
+
description: Optional[str] = None
|
|
29
|
+
|
|
30
|
+
def to_dict(self) -> dict[str, Any]:
|
|
31
|
+
return omit_none({
|
|
32
|
+
"name": self.name,
|
|
33
|
+
"description": self.description,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass
|
|
38
|
+
class ServiceCreate:
|
|
39
|
+
"""Fields used to create a service."""
|
|
40
|
+
|
|
41
|
+
category_id: Optional[int] = None
|
|
42
|
+
name: Optional[str] = None
|
|
43
|
+
cost: Optional[int | float | str] = None
|
|
44
|
+
description: Optional[str] = None
|
|
45
|
+
service_image: Optional[str] = None
|
|
46
|
+
currency: Optional[float] = None
|
|
47
|
+
|
|
48
|
+
def to_dict(self) -> dict[str, Any]:
|
|
49
|
+
return omit_none({
|
|
50
|
+
"categoryId": self.category_id,
|
|
51
|
+
"name": self.name,
|
|
52
|
+
"cost": self.cost,
|
|
53
|
+
"description": self.description,
|
|
54
|
+
"serviceImage": self.service_image,
|
|
55
|
+
"currency": self.currency,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass
|
|
60
|
+
class UpdateServiceData:
|
|
61
|
+
"""Optional fields used to update a service."""
|
|
62
|
+
|
|
63
|
+
name: Optional[str] = None
|
|
64
|
+
service_image: Optional[str] = None
|
|
65
|
+
cost: Optional[int | float | str] = None
|
|
66
|
+
description: Optional[str] = None
|
|
67
|
+
currency: Optional[float] = None
|
|
68
|
+
|
|
69
|
+
def to_dict(self) -> dict[str, Any]:
|
|
70
|
+
return omit_none({
|
|
71
|
+
"name": self.name,
|
|
72
|
+
"serviceImage": self.service_image,
|
|
73
|
+
"cost": self.cost,
|
|
74
|
+
"description": self.description,
|
|
75
|
+
"currency": self.currency,
|
|
76
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any, Optional
|
|
5
|
+
|
|
6
|
+
from ._utils import omit_none
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class VendorData:
|
|
11
|
+
"""Fields used to create a vendor."""
|
|
12
|
+
|
|
13
|
+
first_name: str
|
|
14
|
+
last_name: str
|
|
15
|
+
email: str
|
|
16
|
+
phone: str
|
|
17
|
+
branch_id: int
|
|
18
|
+
company_name: Optional[str] = None
|
|
19
|
+
address: Optional[str] = None
|
|
20
|
+
|
|
21
|
+
def to_dict(self) -> dict[str, Any]:
|
|
22
|
+
return omit_none({
|
|
23
|
+
"firstname": self.first_name,
|
|
24
|
+
"lastname": self.last_name,
|
|
25
|
+
"email": self.email,
|
|
26
|
+
"phone": self.phone,
|
|
27
|
+
"branchId": self.branch_id,
|
|
28
|
+
"company": self.company_name,
|
|
29
|
+
"address": self.address,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class UpdateVendorData:
|
|
35
|
+
"""Optional fields accepted when updating a vendor."""
|
|
36
|
+
|
|
37
|
+
first_name: Optional[str] = None
|
|
38
|
+
last_name: Optional[str] = None
|
|
39
|
+
phone: Optional[str] = None
|
|
40
|
+
branch_id: Optional[int] = None
|
|
41
|
+
|
|
42
|
+
def to_dict(self) -> dict[str, Any]:
|
|
43
|
+
return omit_none({
|
|
44
|
+
"firstname": self.first_name,
|
|
45
|
+
"lastname": self.last_name,
|
|
46
|
+
"phone": self.phone,
|
|
47
|
+
"branchId": self.branch_id,
|
|
48
|
+
})
|