Repository: fossasia/open-event-server

Issue:
Add isBillingEnabled to order object
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
In redesigning the order review page, we need to know is billing was enabled for that particular order or not
Currently there is no way to know this.

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->
Adding `isBillingEnabled` field to the `order` can allow us to get this info

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
Working on it


Discussion:

Resolving patch:
diff --git a/app/api/schema/orders.py b/app/api/schema/orders.py
--- a/app/api/schema/orders.py
+++ b/app/api/schema/orders.py
@@ -63,6 +63,7 @@ def initial_values(self, data):
                             validate=validate.OneOf(choices=["free", "stripe", "paypal", "bank", "cheque", "onsite"]),
                             allow_none=True)
     paid_via = fields.Str(dump_only=True)
+    is_billing_enabled = fields.Boolean(default=False)
     brand = fields.Str(dump_only=True)
     exp_month = fields.Str(dump_only=True)
     exp_year = fields.Str(dump_only=True)
diff --git a/app/models/order.py b/app/models/order.py
--- a/app/models/order.py
+++ b/app/models/order.py
@@ -55,6 +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)
     brand = db.Column(db.String)
     exp_month = db.Column(db.Integer)
     exp_year = db.Column(db.Integer)
@@ -88,6 +89,7 @@ def __init__(self,
                  tax_business_info=None,
                  transaction_id=None,
                  paid_via=None,
+                 is_billing_enabled=False,
                  user_id=None,
                  discount_code_id=None,
                  event_id=None,
@@ -110,6 +112,7 @@ def __init__(self,
         self.event_id = event_id
         self.transaction_id = transaction_id
         self.paid_via = paid_via
+        self.is_billing_enabled = is_billing_enabled
         self.created_at = datetime.datetime.now(datetime.timezone.utc)
         self.discount_code_id = discount_code_id
         self.status = status
@@ -158,6 +161,7 @@ def serialize(self):
             'taxBusinessInfo': self.tax_business_info,
             'transaction_id': self.transaction_id,
             'paid_via': self.paid_via,
+            'isBillingEnabled': self.is_billing_enabled,
             'payment_mode': self.payment_mode,
             'brand': self.brand,
             'exp_month': self.exp_month,
diff --git a/migrations/versions/565ea5bc3937_.py b/migrations/versions/565ea5bc3937_.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/565ea5bc3937_.py
@@ -0,0 +1,27 @@
+"""empty message
+
+Revision ID: 565ea5bc3937
+Revises: 91ee86a38001
+Create Date: 2019-02-18 15:50:18.809478
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '565ea5bc3937'
+down_revision = '91ee86a38001'
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('orders', sa.Column('is_billing_enabled', sa.Boolean()), server_default='False')
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.drop_column('orders', 'is_billing_enabled')
+    # ### end Alembic commands ###


Test patch: