Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Addition and Updation of billing related fields #6447

Merged
merged 27 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fcf6de4
enh: Addition of billing info related fields
kushthedude Sep 15, 2019
f0641e0
Update rev-2019-09-15-08:29:32-d1c2b8711223_.py
kushthedude Sep 16, 2019
936264a
Update rev-2019-09-15-08:29:32-d1c2b8711223_.py
kushthedude Sep 16, 2019
68ed374
Merge branch 'development' into fields
kushthedude Sep 24, 2019
2f50044
Adding another function
kushthedude Sep 24, 2019
249d067
Update orders.py
kushthedude Sep 24, 2019
2b65543
Merge branch 'development' into fields
kushthedude Sep 25, 2019
ae86e49
Update orders.py
kushthedude Sep 25, 2019
5848ae5
Merge branch 'development' into fields
kushthedude Sep 27, 2019
12b5842
Merge branch 'development' into fields
kushthedude Sep 30, 2019
a4216ad
Merge branch 'development' into fields
iamareebjamal Sep 30, 2019
2d9c08d
Merge branch 'development' into fields
iamareebjamal Oct 1, 2019
9d31d76
Merge branch 'development' into fields
kushthedude Oct 1, 2019
d6cfe4f
Merge branch 'development' into fields
kushthedude Oct 2, 2019
8ddaa3c
Merge branch 'development' into fields
kushthedude Oct 3, 2019
61d2671
Merge branch 'development' into fields
kushthedude Oct 12, 2019
67beb26
Merging the functions
kushthedude Oct 12, 2019
124f19f
Merge branch 'development' into fields
kushthedude Oct 13, 2019
38933b8
Addition of `server_default`
kushthedude Oct 15, 2019
df8798d
Removing unused arg
kushthedude Oct 18, 2019
2db0673
Merge branch 'development' into fields
kushthedude Oct 18, 2019
687bd2a
Merge branch 'development' into fields
kushthedude Nov 19, 2019
306cdc3
Updating migration version
kushthedude Nov 23, 2019
cb7265d
Final fixes
kushthedude Nov 24, 2019
873980c
Merge branch 'development' into fields
kushthedude Nov 24, 2019
c74d885
Hound violation
kushthedude Nov 25, 2019
f07085a
Syntax enhancement
kushthedude Nov 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/api/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def is_payment_valid(order, mode):
def check_billing_info(data):
if data.get('amount') and data.get('amount') > 0 and not data.get('is_billing_enabled'):
kushthedude marked this conversation as resolved.
Show resolved Hide resolved
raise UnprocessableEntity({'pointer': '/data/attributes/is_billing_enabled'},
"Billing information is mandatory for paid orders")
if data.get('is_billing_enabled') and not (data.get('company') and data.get('address') and data.get('city') and
data.get('zipcode') and data.get('country')):
"Billing information is mandatory for this order.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove period from the end

if data.get('is_billing_enabled') and not (data.get('company') and data.get('address')
and data.get('city') and data.get('zipcode') and data.get('country')):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent
indentation contains mixed spaces and tabs
indentation contains tabs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Is it relevant to this issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This are the mandatory checks for billing details hence I have merged the two as suggested .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kushthedude Ok. Change PR title.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this please. The previous format was according to PEP8

raise UnprocessableEntity({'pointer': '/data/attributes/is_billing_enabled'},
"Billing information incomplete")
"Billing information is incomplete.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line over-indented for visual indent
indentation contains mixed spaces and tabs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the period from the end



class OrdersListPost(ResourceList):
Expand Down Expand Up @@ -319,7 +319,7 @@ def before_update_object(self, order, data, view_kwargs):
:param view_kwargs:
:return:
"""
if data.get('amount') or data.get('is_billing_enabled'):
if data.get('amount') or data.get('is_billing_enabled') or order.event.is_billing_info_mandatory:
kushthedude marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a problem, this will require billing info on any paid order, whereas it is explicitly stated in the issue to make it optional unless is_billing_info_mandatory is True.

Skipping this PR for now, will add in minor version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging it after release would be better I guess too.

check_billing_info(data)
if (not has_access('is_coorganizer', event_id=order.event_id)) and (not current_user.id == order.user_id):
raise ForbiddenException({'pointer': ''}, "Access Forbidden")
Expand Down
2 changes: 1 addition & 1 deletion app/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Event(SoftDeletionModel):
payment_currency = db.Column(db.String)
paypal_email = db.Column(db.String)
is_tax_enabled = db.Column(db.Boolean, default=False)
is_billing_info_mandatory = db.Column(db.Boolean, default=False)
is_billing_info_mandatory = db.Column(db.Boolean, default=False, nullable=False)
can_pay_by_paypal = db.Column(db.Boolean, default=False, nullable=False)
can_pay_by_stripe = db.Column(db.Boolean, default=False, nullable=False)
can_pay_by_cheque = db.Column(db.Boolean, default=False, nullable=False)
Expand Down
2 changes: 1 addition & 1 deletion app/models/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Order(SoftDeletionModel):
transaction_id = db.Column(db.String)
paid_via = db.Column(db.String)
payment_mode = db.Column(db.String)
is_billing_enabled = db.Column(db.Boolean)
is_billing_enabled = db.Column(db.Boolean, nullable=False, default=False)
brand = db.Column(db.String)
exp_month = db.Column(db.Integer)
exp_year = db.Column(db.Integer)
Expand Down
40 changes: 40 additions & 0 deletions migrations/versions/rev-2019-09-15-08:29:32-d1c2b8711223_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""empty message

Revision ID: d1c2b8711223
Revises: 9effd270a6ae
Create Date: 2019-09-15 08:29:32.373041

"""

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils


# revision identifiers, used by Alembic.
revision = 'd1c2b8711223'
down_revision = '9effd270a6ae'


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('events', 'is_billing_info_mandatory',
existing_type=sa.BOOLEAN(),
server_default='False',
nullable=False)
kushthedude marked this conversation as resolved.
Show resolved Hide resolved
op.alter_column('orders', 'is_billing_enabled',
existing_type=sa.BOOLEAN(),
server_default='False',
nullable=False)
iamareebjamal marked this conversation as resolved.
Show resolved Hide resolved
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('orders', 'is_billing_enabled',
existing_type=sa.BOOLEAN(),
nullable=True)
op.alter_column('events', 'is_billing_info_mandatory',
existing_type=sa.BOOLEAN(),
nullable=True)
# ### end Alembic commands ###