-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: Addition and Updation of billing related fields #6447
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
Changes from 5 commits
fcf6de4
f0641e0
936264a
68ed374
2f50044
249d067
2b65543
ae86e49
5848ae5
12b5842
a4216ad
2d9c08d
9d31d76
d6cfe4f
8ddaa3c
61d2671
67beb26
124f19f
38933b8
df8798d
2db0673
687bd2a
306cdc3
cb7265d
873980c
c74d885
f07085a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,14 +68,17 @@ def is_payment_valid(order, mode): | |
| return (order.paid_via == 'paypal') and order.transaction_id | ||
|
|
||
|
|
||
| def check_billing_info(data): | ||
| if data.get('amount') and data.get('amount') > 0 and not data.get('is_billing_enabled'): | ||
| def is_billing_info(data, order): | ||
|
||
| if order.event.is_billing_info_mandatory and data.get('amount') and data.get('amount') > 0 | ||
kushthedude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| and not data.get('is_billing_enabled'): | ||
kushthedude marked this conversation as resolved.
Outdated
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')): | ||
| raise UnprocessableEntity({'pointer': '/data/attributes/is_billing_enabled'}, | ||
| "Billing information incomplete") | ||
| "Billing information is mandatory for this order.") | ||
|
||
|
|
||
| def check_billing_info(data, order): | ||
kushthedude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if data.get('is_billing_enabled') and not (data.get('company') and data.get('address') | ||
kushthedude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| and data.get('city') and data.get('zipcode') and data.get('country')): | ||
|
||
| raise UnprocessableEntity({'pointer': '/data/attributes/is_billing_enabled'}, | ||
kushthedude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "Billing information is incomplete.") | ||
|
||
|
|
||
|
|
||
| class OrdersListPost(ResourceList): | ||
|
|
@@ -319,8 +322,9 @@ def before_update_object(self, order, data, view_kwargs): | |
| :param view_kwargs: | ||
| :return: | ||
| """ | ||
| if data.get('amount') or data.get('is_billing_enabled'): | ||
| check_billing_info(data) | ||
| if data.get('amount') or data.get('is_billing_enabled') or order.event.is_billing_info_mandatory: | ||
kushthedude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| is_billing_info(data, order) | ||
| check_billing_info(data, order) | ||
kushthedude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
kushthedude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (not has_access('is_coorganizer', event_id=order.event_id)) and (not current_user.id == order.user_id): | ||
| raise ForbiddenException({'pointer': ''}, "Access Forbidden") | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """empty message | ||
| Revision ID: d1c2b8711223 | ||
| Revises: 7c32ba647a18 | ||
| 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 = '7c32ba647a18' | ||
|
|
||
|
|
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.alter_column('events', 'is_billing_info_mandatory', | ||
| existing_type=sa.BOOLEAN(), | ||
| 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 ### | ||
Uh oh!
There was an error while loading. Please reload this page.