is_order_valid added in helper.py

This commit is contained in:
ahmadbilalkhalid 2020-02-20 15:23:15 +05:00
parent bb18f6b0e9
commit 8c353f277c
2 changed files with 22 additions and 0 deletions

View file

@ -1,5 +1,8 @@
import logging
import parsedatetime
from datetime import datetime
from stripe_utils import StripeUtils
@ -64,3 +67,21 @@ def calculate_charges(specification, data):
feature_detail['unit']['value']
)
return one_time_charge, recurring_charge
def is_order_valid(order_timestamp, renewal_period):
"""
Sample Code Usage
>> current_datetime, status = cal.parse('Now')
>> current_datetime = datetime(*current_datetime[:6])
>> print('Is order valid: ', is_order_valid(current_datetime, '1 month'))
>> True
"""
cal = parsedatetime.Calendar()
renewal_datetime, status = cal.parse(renewal_period)
renewal_datetime = datetime(*renewal_datetime[:6])
return order_timestamp <= renewal_datetime

View file

@ -1,3 +1,4 @@
done
stripe
flask
Flask-RESTful