Repository: saleor/saleor

Issue:
SaleInput should use Date rather than DateTime 
### What I'm trying to achieve
To improve API consistency and eliminate potential client-side bugs by changing `startDate` and `endDate` types from `DateTime` to `Date`. Currently, this input is prone to timezone differences and inconsistent with `Sale` type, which returns `Date`.


Discussion:
Same goes for `VoucherInput`

Resolving patch:
diff --git a/saleor/graphql/discount/mutations.py b/saleor/graphql/discount/mutations.py
--- a/saleor/graphql/discount/mutations.py
+++ b/saleor/graphql/discount/mutations.py
@@ -82,9 +82,9 @@ class VoucherInput(graphene.InputObjectType):
         description='Voucher type: product, category shipping or value.')
     name = graphene.String(description='Voucher name.')
     code = graphene.String(decription='Code to use the voucher.')
-    start_date = graphene.types.datetime.DateTime(
+    start_date = graphene.types.datetime.Date(
         description='Start date of the voucher in ISO 8601 format.')
-    end_date = graphene.types.datetime.DateTime(
+    end_date = graphene.types.datetime.Date(
         description='End date of the voucher in ISO 8601 format.')
     discount_value_type = DiscountValueTypeEnum(
         description='Choices: fixed or percentage.')
@@ -216,9 +216,9 @@ class SaleInput(graphene.InputObjectType):
     collections = graphene.List(
         graphene.ID, description='Collections related to the discount.',
         name='collections')
-    start_date = graphene.types.datetime.DateTime(
+    start_date = graphene.types.datetime.Date(
         description='Start date of the sale in ISO 8601 format.')
-    end_date = graphene.types.datetime.DateTime(
+    end_date = graphene.types.datetime.Date(
         description='End date of the sale in ISO 8601 format.')
 
 


Test patch:
diff --git a/tests/api/test_discount.py b/tests/api/test_discount.py
--- a/tests/api/test_discount.py
+++ b/tests/api/test_discount.py
@@ -1,3 +1,5 @@
+from datetime import date
+
 import graphene
 import pytest
 from django_countries import countries
@@ -99,12 +101,14 @@ def test_create_voucher(staff_api_client, permission_manage_discounts):
     mutation  voucherCreate(
         $type: VoucherTypeEnum, $name: String, $code: String,
         $discountValueType: DiscountValueTypeEnum,
-        $discountValue: Decimal, $minAmountSpent: Decimal) {
+        $discountValue: Decimal, $minAmountSpent: Decimal,
+        $startDate: Date, $endDate: Date) {
             voucherCreate(input: {
                     name: $name, type: $type, code: $code,
                     discountValueType: $discountValueType,
                     discountValue: $discountValue,
-                    minAmountSpent: $minAmountSpent}) {
+                    minAmountSpent: $minAmountSpent,
+                    startDate: $startDate, endDate: $endDate}) {
                 errors {
                     field
                     message
@@ -117,17 +121,23 @@ def test_create_voucher(staff_api_client, permission_manage_discounts):
                     name
                     code
                     discountValueType
+                    startDate
+                    endDate
                 }
             }
         }
     """
+    start_date = date(day=1, month=1, year=2018)
+    end_date = date(day=1, month=1, year=2019)
     variables = {
         'name': 'test voucher',
         'type': VoucherTypeEnum.VALUE.name,
         'code': 'testcode123',
         'discountValueType': DiscountValueTypeEnum.FIXED.name,
         'discountValue': 10.12,
-        'minAmountSpent': 1.12}
+        'minAmountSpent': 1.12,
+        'startDate': start_date.isoformat(),
+        'endDate': end_date.isoformat()}
 
     response = staff_api_client.post_graphql(
         query, variables, permissions=[permission_manage_discounts])
@@ -138,6 +148,8 @@ def test_create_voucher(staff_api_client, permission_manage_discounts):
     assert data['name'] == 'test voucher'
     assert data['code'] == 'testcode123'
     assert data['discountValueType'] == DiscountValueType.FIXED.upper()
+    assert data['startDate'] == start_date.isoformat()
+    assert data['endDate'] == end_date.isoformat()
 
 
 def test_update_voucher(
@@ -340,31 +352,44 @@ def test_voucher_remove_no_catalogues(
 def test_create_sale(staff_api_client, permission_manage_discounts):
     query = """
     mutation  saleCreate(
-        $type: DiscountValueTypeEnum, $name: String, $value: Decimal) {
-            saleCreate(input: {name: $name, type: $type, value: $value}) {
-                errors {
-                    field
-                    message
-                }
-                sale {
-                    type
-                    name
-                    value
-                }
+            $type: DiscountValueTypeEnum, $name: String, $value: Decimal,
+            $startDate: Date, $endDate: Date) {
+        saleCreate(input: {
+                name: $name, type: $type, value: $value,
+                startDate: $startDate, endDate: $endDate}) {
+            sale {
+                type
+                name
+                value
+                startDate
+                endDate
+            }
+            errors {
+                field
+                message
             }
         }
+    }
     """
+    start_date = date(day=1, month=1, year=2018)
+    end_date = date(day=1, month=1, year=2019)
     variables = {
         'name': 'test sale',
         'type': DiscountValueTypeEnum.FIXED.name,
-        'value': '10.12'}
+        'value': '10.12',
+        'startDate': start_date.isoformat(),
+        'endDate': end_date.isoformat()}
+
     response = staff_api_client.post_graphql(
         query, variables, permissions=[permission_manage_discounts])
     content = get_graphql_content(response)
     data = content['data']['saleCreate']['sale']
+
     assert data['type'] == DiscountValueType.FIXED.upper()
     assert data['name'] == 'test sale'
     assert data['value'] == 10.12
+    assert data['startDate'] == start_date.isoformat()
+    assert data['endDate'] == end_date.isoformat()
 
 
 def test_update_sale(staff_api_client, sale, permission_manage_discounts):