traisl date end

This commit is contained in:
CHIEFSOFT\ameye
2025-08-30 09:12:31 -04:00
parent 037ef64694
commit a604aeba8a
4 changed files with 15 additions and 4 deletions
+2
View File
@@ -48,6 +48,8 @@ ALTER TABLE members ADD stripe_customer_id VARCHAR(100)
ALTER TABLE members ADD profile_completed timestamp without time zone DEFAULT NULL; ALTER TABLE members ADD profile_completed timestamp without time zone DEFAULT NULL;
ALTER TABLE members ADD option_name VARCHAR(100) REFERENCES subscription_options(option_name); ALTER TABLE members ADD option_name VARCHAR(100) REFERENCES subscription_options(option_name);
ALTER TABLE members ADD next_billing timestamp without time zone; ALTER TABLE members ADD next_billing timestamp without time zone;
ALTER TABLE members ADD trial_end timestamp without time zone;
CREATE TABLE members_profile( CREATE TABLE members_profile(
id SERIAL, id SERIAL,
+1 -1
View File
@@ -59,7 +59,7 @@ class AccountService(BaseService):
bill_style=" next_billing " bill_style=" next_billing "
else: else:
option_name = "Free Trial" option_name = "Free Trial"
next_bill = "End: 10/10/202" next_bill = f"Ends: {member_data.trial_end}"
view_sub = "Upgrade Account" view_sub = "Upgrade Account"
bill_style = " billing " bill_style = " billing "
+1 -1
View File
@@ -126,7 +126,7 @@ class SubscriptionsService(BaseService):
'post events', 'post events',
'Cancel Anytime' 'Cancel Anytime'
], ],
"next_payment": '2025-10-15 11:00:07.47214' "next_payment": member_data.next_billing if member_data.next_billing!=None else member_data.trial_end,
}, },
'stripe_customer_id': member_data.stripe_customer_id, 'stripe_customer_id': member_data.stripe_customer_id,
"options": res_options "options": res_options
+11 -2
View File
@@ -1,4 +1,4 @@
from datetime import datetime, timezone from datetime import datetime, timezone, timedelta
from app.extensions import db from app.extensions import db
from sqlalchemy.sql import func from sqlalchemy.sql import func
from sqlalchemy.exc import IntegrityError from sqlalchemy.exc import IntegrityError
@@ -25,6 +25,7 @@ class Members(db.Model):
stripe_customer_id = db.Column(db.String(100), nullable=True) stripe_customer_id = db.Column(db.String(100), nullable=True)
option_name = db.Column(db.String(100), nullable=True) option_name = db.Column(db.String(100), nullable=True)
next_billing= db.Column(db.DateTime(timezone=False)) next_billing= db.Column(db.DateTime(timezone=False))
trial_end = db.Column(db.DateTime(timezone=False))
def to_dict(self): def to_dict(self):
return { return {
@@ -45,6 +46,7 @@ class Members(db.Model):
"lastname": self.lastname, "lastname": self.lastname,
'option_name': self.option_name, 'option_name': self.option_name,
"next_billing": self.next_billing, "next_billing": self.next_billing,
"trial_end": self.trial_end,
"stripe_customer_id": self.stripe_customer_id "stripe_customer_id": self.stripe_customer_id
} }
@@ -80,7 +82,13 @@ class Members(db.Model):
@classmethod @classmethod
def add_member(cls, firstname, lastname, email, username,password, country): def add_member(cls, firstname, lastname, email, username,password, country, trials_days = 90):
# Get the current date and time
current_date = datetime.now()
# Calculate the date "next_billing_days" days from now
trial_end = current_date + timedelta(days=trials_days)
# Save the response # Save the response
member_data = cls( member_data = cls(
@@ -91,6 +99,7 @@ class Members(db.Model):
email=email, email=email,
country=country, country=country,
password=password, password=password,
trial_end=trial_end,
added=datetime.now(timezone.utc), added=datetime.now(timezone.utc),
updated=datetime.now(timezone.utc) updated=datetime.now(timezone.utc)
) )