feat: implement billing system with Pally integration
- Added billing models and repository for handling bills. - Introduced BillingService to manage payment initiation and bill creation. - Updated user service to remove ticket-related functionality. - Refactored settings to include new billing-related fields. - Removed ticket-related handlers and schemas. - Added new billing handlers for processing payments. - Updated database schema with new bills table and status enum. - Enhanced utility functions to calculate prices considering discounts. - Introduced prehandling for non-private messages. - Updated main application to initialize new billing services and repositories.
This commit is contained in:
@@ -170,14 +170,18 @@ def convert_duration_to_timedelta(duration: SubscriptionDuration) -> timedelta:
|
||||
|
||||
|
||||
def calculate_price(subscription: SubscriptionPlan):
|
||||
return (
|
||||
(subscription.devices * settings.per_device_cost)
|
||||
+ (
|
||||
int(subscription.whitelists) * settings.whitelist_cost
|
||||
if subscription.devices < settings.whitelist_device_threshold
|
||||
else 0
|
||||
return math.ceil(
|
||||
(
|
||||
(subscription.devices * settings.per_device_cost)
|
||||
+ (
|
||||
int(subscription.whitelists) * settings.whitelist_cost
|
||||
if subscription.devices < settings.whitelist_device_threshold
|
||||
else 0
|
||||
)
|
||||
)
|
||||
) * convert_duration_to_int(subscription.duration)
|
||||
* convert_duration_to_int(subscription.duration)
|
||||
* subscription.discount
|
||||
)
|
||||
|
||||
|
||||
def get_discount(months) -> float:
|
||||
|
||||
Reference in New Issue
Block a user