[#775] Can't filter Gift Card instances by service id

Migrated from Redmine #775 | Author: Brendan Jefferis
Status: Feedback | Priority: Normal | Created: 2021-09-06


Attempting to fetch gift card instances filtered by a service id return the HTML of a 404 page.

When fetching gift card instances without any filters (receiving all the instances successfully) the field service_restrictions is always an empty array even for gift card instances that can only be used on one specific service.

Step to reproduce:

  1. Create a service

  2. Create a gift card and allow it to be used only on that service

  3. Create a new instance

  4. Fetch instance filtered by service id (expect JSON result with 404 or HTTP error, not HTML)

  5. (Steps 1-3 above)

  6. Fetch instances with no filters

  7. Check service_restrictions – expect service_restrictions array to contain service id

Dmytro Bondarev wrote:

Please provide HTTP requests and responces.

Brendan Jefferis wrote:

Dmitry Bondarev wrote:

Please provide HTTP requests and responces.

Request (with filter)

GET /admin/promotions/gift-cards?filter[service_id]=28 HTTP/1.1
Host: user-api-v2.simplybook.me
X-Company-Login: vicinitytest
X-Token:

Response


 ...



  
  ...
  

Request (no filter)
GET /admin/promotions/gift-cards HTTP/1.1
Host: user-api-v2.simplybook.me
X-Company-Login: vicinitytest
X-Token:

Response

{
  "data": [
    {
      "id": 313,
      "promotion": {
        "id": 15,
        "name": "Test",
        "description": "",
        "file_id": null,
        "picture_preview": null,
        "picture_large": null,
        "is_active": true,
        "position": 18,
        "price": 1.0,
        "currency": "AUD",
        "tax": {
          "id": 1,
          "name": "GST",
          "ratio": 0.1,
          "is_default": true
        },
        "promotion_type": "gift_card",
        "discount_type": "fixed_amount",
        "discount": 10.0,
        "duration_type": "month",
        "duration": 1,
        "client_type": "all",
        "allow_usage_count": 1,
        "is_unlimited": false,
        "affect_services": true,
        "affect_products": false,
        "affect_paid_attributes": false,
        "affect_memberships": false,
        "service_restrictions": [],
        "booking_restrictions": [],
        "product_restrictions": [],
        "paid_attribute_restrictions": [],
        "memberships_restrictions": [],
        "print_template_id": 1
      },
      "start_date": "2021-09-06",
      "expired_date": "2021-10-06",
      "is_used": false,
      "can_be_used": true,
      "can_be_used_count": -1,
      "code": "gubyrequ",
      "client_id": null,
      "client": null,
      "user_id": "1",
      "user": {
        "id": 1,
        "login": "admin",
        "firstname": "Dhanushka",
        "lastname": "",
        "email": "dhanushka.krishnajith@vicinity.com.au",
        "phone": "+61420363881",
        "company": {
          "login": "vicinitytest",
          "name": "Vicinity Real Estate Licence Pty Ltd",
          "dashboard_url": "https://vicinitytest.secure.simplybook.me",
          "public_url": "https://vicinitytest.simplybook.me",
          "id": null
        }
      },
      "status": "valid",
      "used_count": "0",
      "used_amount": null,
      "rest_amount": 10.0,
      "allowed_to_use_full_amount": true
    },
    {
      "id": 312,
      "promotion": {
        "id": 7,
        "name": "Porter | 1 Hour",
        "description": "",
        "file_id": null,
        "picture_preview": null,
        "picture_large": null,
        "is_active": true,
        "position": 12,
        "price": 60.0,
        "currency": "AUD",
        "tax": {
          "id": 1,
          "name": "GST",
          "ratio": 0.1,
          "is_default": true
        },
        "promotion_type": "gift_card",
        "discount_type": "percentage",
        "discount": 100.0,
        "duration_type": "year",
        "duration": 5,
        "client_type": "all",
        "allow_usage_count": 1,
        "is_unlimited": false,
        "affect_services": true,
        "affect_products": false,
        "affect_paid_attributes": false,
        "affect_memberships": false,
        "service_restrictions": [],
        "booking_restrictions": [],
        "product_restrictions": [],
        "paid_attribute_restrictions": [],
        "memberships_restrictions": [],
        "print_template_id": 1
      },
      "start_date": "2021-09-06",
      "expired_date": "2026-09-06",
      "is_used": false,
      "can_be_used": true,
      "can_be_used_count": 1,
      "code": "ypymaqun",
      "client_id": null,
      "client": null,
      "user_id": "1",
      "user": {
        "id": 1,
        "login": "admin",
        "firstname": "Dhanushka",
        "lastname": "",
        "email": "dhanushka.krishnajith@vicinity.com.au",
        "phone": "+61420363881",
        "company": {
          "login": "vicinitytest",
          "name": "Vicinity Real Estate Licence Pty Ltd",
          "dashboard_url": "https://vicinitytest.secure.simplybook.me",
          "public_url": "https://vicinitytest.simplybook.me",
          "id": null
        }
      },
      "status": "valid",
      "used_count": "0",
      "used_amount": null,
      "rest_amount": null,
      "allowed_to_use_full_amount": true
    }
  ]
}

Dmytro Bondarev wrote:

will be available soon.