«

POST /api/admin/vouchers - Admin tạo voucher-book cho phường

  • Header: X-Tenant
  • Request body: """ { "clanCode"(): "string", "code"(): "string", "title"(): "string", "description": "string", "validFrom"(): "2024-09-24T07:51:22.783Z", "validTo": "2024-09-24T07:51:22.783Z", "applyScopes"(): [ "string" ], "applyCondition": "string", "discountType"(): "string", "formula"(): "string", "orderCode": "string", "image": "string", "termsAndConditions": "string", "customerLimit"(): 0, "numberOfVoucher"(): 0, "maxValue": 0, "items"(): [ { "fee": "string", "maxValue": 0, "discountLimit": 0 } ], "config"(): { "hidden": true, "single": true, "showLimit": true, "showRemaining": true, "showCustomerLimit": true }, "orderDiscount"(): { "maxValue": 0, "discountLimit": 0, "orderDiscountType": "string" } } """
  • Quyền tạo voucher-book: voucher:create_book
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 403 khi tài khoản không có quyền tạo voucher-book: voucher:create_book

    • Given Tôi có token của tài khoản có thông tin
      accountpermissionGrouppermissionGroupNamepermission
      suppliersupplier_groupsupplier_grouptrừ quyền voucher:create_book
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Chủ phường "ownerclan" thấy phường "001" chưa có mã voucher "NATRA"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
          {
            "fee": "standard_shipping"
          }
        ],
        "config": {},
        "orderDiscount": {}
      }
    • Then Trả về status code 403
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 500 khi tạo voucher-book trên hệ thống ops khi không gửi header X-Tenant

    • Given Có token full quyền
    • When Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "001",
        "code": "NATRA",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
          {
            "fee": "standard_shipping"
          }
        ],
        "config": {},
        "orderDiscount": {}
      }
    • Then Trả về status code 500
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 400 khi tạo voucher-book trên hệ thống ops khi gửi header X-Tenant không hợp lệ

    • Given Có token full quyền
    • When Request có header là
      X-Tenant<tenant>
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "001",
        "code": "NATRA",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
          {
            "fee": "standard_shipping"
          }
        ],
        "config": {},
        "orderDiscount": {}
      }
    • Then Trả về status code 400
    • And Response có body thỏa mãn giá trị như sau
      {
        "title": "clan_not_found"
      }

    Examples:

    tenant
    null
    linhtinh
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 401 khi request tạo voucher-book khi gửi lên token hết hạn

    • Given Token đã hết hạn
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "001",
        "code": "NATRA",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
          {
            "fee": "standard_shipping"
          }
        ],
        "config": {},
        "orderDiscount": {}
      }
    • Then Trả về status code 401
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 401 khi request tạo voucher-book khi không gửi lên token

    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "001",
        "code": "NATRA",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
          {
            "fee": "standard_shipping"
          }
        ],
        "config": {},
        "orderDiscount": {}
      }
    • Then Trả về status code 401
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 400 khi gửi lên mã phường clanCode không tồn tại

    • Given Có token full quyền
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "001",
        "code": "NATRA",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
          {
            "fee": "standard_shipping"
          }
        ],
        "config": {},
        "orderDiscount": {}
      }
    • Then Trả về status code 400
    • And Response có body thỏa mãn giá trị như sau
      {
        "title": "clan_not_found"
      }
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 400 khi gửi request tạo voucher-book không có các trường bắt buộc,

    bao gồm: clanCode, code, title, validFrom, applyScopes, discountType, formula, customerLimit, numberOfVoucher, config, items, orderDiscount

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Chủ phường "ownerclan" thấy phường "001" chưa có mã voucher "NATRA"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        <jsonBody>
      }
    • Then Trả về status code 400
    • And Response có body thỏa mãn giá trị như sau
      {
        "violations": [
          {
              "field": "<field>",
              "message": "<message>"
          }
        ],
        "title": "Constraint Violation"
      }

    Examples:

    field message jsonBody
    clanCode must not be blank "code":"${NATRA}","title":"Test Voucher","validFrom":"2024-09-24T08:07:37.001Z","applyScopes":["ORDER"],"discountType":"AMOUNT","formula":"5000","customerLimit":2,"numberOfVoucher":10,"config":{},"items":[{"fee":"standard_shipping"}],"orderDiscount":{}
    code must not be blank "clanCode":"${001}","title":"Test Voucher","validFrom":"2024-09-24T08:07:37.001Z","applyScopes":["ORDER"],"discountType":"AMOUNT","formula":"5000","customerLimit":2,"numberOfVoucher":10,"config":{},"items":[{"fee":"standard_shipping"}],"orderDiscount":{}
    title must not be blank "code":"${NATRA}","clanCode":"${001}","validFrom":"2024-09-24T08:07:37.001Z","applyScopes":["ORDER"],"discountType":"AMOUNT","formula":"5000","customerLimit":2,"numberOfVoucher":10,"config":{},"items":[{"fee":"standard_shipping"}],"orderDiscount":{}
    validFrom must not be null "code":"${NATRA}","clanCode":"${001}","title":"Test Voucher","applyScopes":["ORDER"],"discountType":"AMOUNT","formula":"5000","customerLimit":2,"numberOfVoucher":10,"config":{},"items":[{"fee":"standard_shipping"}],"orderDiscount":{}
    applyScopes must not be null "code":"${NATRA}","clanCode":"${001}","title":"Test Voucher","validFrom":"2024-09-24T08:07:37.001Z","discountType":"AMOUNT","formula":"5000","customerLimit":2,"numberOfVoucher":10,"config":{},"items":[{"fee":"standard_shipping"}],"orderDiscount":{}
    discountType must not be blank "code":"${NATRA}","clanCode":"${001}","title":"Test Voucher","validFrom":"2024-09-24T08:07:37.001Z","applyScopes":["ORDER"],"formula":"5000","customerLimit":2,"numberOfVoucher":10,"config":{},"items":[{"fee":"standard_shipping"}],"orderDiscount":{}
    formula must not be blank "code":"${NATRA}","clanCode":"${001}","title":"Test Voucher","validFrom":"2024-09-24T08:07:37.001Z","applyScopes":["ORDER"],"discountType":"AMOUNT","customerLimit":2,"numberOfVoucher":10,"config":{},"items":[{"fee":"standard_shipping"}],"orderDiscount":{}
    customerLimit must not be null "code":"${NATRA}","clanCode":"${001}","title":"Test Voucher","validFrom":"2024-09-24T08:07:37.001Z","applyScopes":["ORDER"],"discountType":"AMOUNT","formula":"5000","numberOfVoucher":10,"config":{},"items":[{"fee":"standard_shipping"}],"orderDiscount":{}
    numberOfVoucher must not be null "code":"${NATRA}","clanCode":"${001}","title":"Test Voucher","validFrom":"2024-09-24T08:07:37.001Z","applyScopes":["ORDER"],"discountType":"AMOUNT","formula":"5000","customerLimit":2,"config":{},"items":[{"fee":"standard_shipping"}],"orderDiscount":{}
    config must not be null "code":"${NATRA}","clanCode":"${001}","title":"Test Voucher","validFrom":"2024-09-24T08:07:37.001Z","applyScopes":["ORDER"],"discountType":"AMOUNT","formula":"5000","customerLimit":2,"numberOfVoucher":10,"items":[{"fee":"standard_shipping"}],"orderDiscount":{}
    items must not be null "code":"${NATRA}","clanCode":"${001}","title":"Test Voucher","validFrom":"2024-09-24T08:07:37.001Z","applyScopes":["ORDER"],"discountType":"AMOUNT","formula":"5000","customerLimit":2,"numberOfVoucher":10,"config":{},"orderDiscount":{}
    orderDiscount must not be null "code":"${NATRA}","clanCode":"${001}","title":"Test Voucher","validFrom":"2024-09-24T08:07:37.001Z","applyScopes":["ORDER"],"discountType":"AMOUNT","formula":"5000","customerLimit":2,"numberOfVoucher":10,"config":{},"items":[{"fee":"standard_shipping"}]
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 400 khi gửi request tạo voucher-book với các trường bắt buộc có giá trị null hoặc rỗng,

    bao gồm: clanCode, code, title, validFrom, applyScopes, discountType, formula, customerLimit, numberOfVoucher, config, items, orderDiscount

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Chủ phường "ownerclan" thấy phường "001" chưa có mã voucher "NATRA"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": <clanCode>,
        "code": <code>,
        "title": <title>,
        "validFrom": <validFrom>,
        "applyScopes": <applyScopes>,
        "discountType": <discountType>,
        "formula": <formula>,
        "customerLimit": <customerLimit>,
        "numberOfVoucher": <numberOfVoucher>,
        "config": <config>,
        "items": <items>,
        "orderDiscount": <orderDiscount>
      }
    • Then Trả về status code 400
    • And Response có body thỏa mãn giá trị như sau
      {
        "violations": [
          {
              "field": "<field>",
              "message": "<message>"
          }
        ],
        "title": "Constraint Violation"
      }

    Examples:

    clanCode code title validFrom applyScopes discountType formula config customerLimit numberOfVoucher items orderDiscount field message
    null "${NATRA}" "test" "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" "5000" {} 2 10 [{"fee":"standard_shipping"}] {} clanCode must not be blank
    "" "${NATRA}" "test" "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" "5000" {} 2 10 [{"fee":"standard_shipping"}] {} clanCode must not be blank
    "${001}" null "test" "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" "5000" {} 2 10 [{"fee":"standard_shipping"}] {} code must not be blank
    "${001}" "" "test" "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" "5000" {} 2 10 [{"fee":"standard_shipping"}] {} code must not be blank
    "${001}" "${NATRA}" null "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" "5000" {} 2 10 [{"fee":"standard_shipping"}] {} title must not be blank
    "${001}" "${NATRA}" "test" null ["ORDER"] "PERCENT" "5000" {} 2 10 [{"fee":"standard_shipping"}] {} validFrom must not be null
    "${001}" "${NATRA}" "test" "2024-09-12T00:00:00Z" null "PERCENT" "5000" {} 2 10 [{"fee":"standard_shipping"}] {} applyScopes must not be null
    "${001}" "${NATRA}" "test" "2024-09-12T00:00:00Z" ["ORDER"] null "5000" {} 2 10 [{"fee":"standard_shipping"}] {} discountType must not be blank
    "${001}" "${NATRA}" "test" "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" null {} 2 10 [{"fee":"standard_shipping"}] {} formula must not be blank
    "${001}" "${NATRA}" "test" "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" "5000" null 2 10 [{"fee":"standard_shipping"}] {} config must not be null
    "${001}" "${NATRA}" "test" "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" "5000" {} null 10 [{"fee":"standard_shipping"}] {} customerLimit must not be null
    "${001}" "${NATRA}" "test" "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" "5000" {} 2 null [{"fee":"standard_shipping"}] {} numberOfVoucher must not be null
    "${001}" "${NATRA}" "test" "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" "5000" {} 2 10 null {} items must not be null
    "${001}" "${NATRA}" "test" "2024-09-12T00:00:00Z" ["ORDER"] "PERCENT" "5000" {} 2 10 [{"fee":"standard_shipping"}] null orderDiscount must not be null
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 400 khi gửi lên dữ liệu sai định dạng

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Chủ phường "ownerclan" thấy phường "001" chưa có mã voucher "NATRA"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "title": "Test Voucher",
        "validFrom": "<validFrom>",
        "validTo": "<validTo>",
        "applyScopes": <applyScopes>,
        "discountType": "AMOUNT",
        "formula": "5000",
        "config": <config>,
        "customerLimit": <customerLimit>,
        "numberOfVoucher": <numberOfVoucher>,
        "items": <items>,
        "orderDiscount": <orderDiscount>
      }
    • Then Trả về status code 400
    • And Response có body thỏa mãn giá trị như sau
      {
        "title": "Bad Request"
      }

    Examples:

    validFrom validTo customerLimit numberOfVoucher items applyScopes config orderDiscount
    2024-09-04 05:35:23 2024-09-24T08:07:37.001Z 2 10 [{"fee":"standard_shipping"}] ["ORDER"] {} {}
    text 2024-09-24T08:07:37.001Z 2 10 [{"fee":"standard_shipping"}] ["ORDER"] {} {}
    2024-09-24T08:07:37.001Z 2024-09-04 05:35:23 2 10 [{"fee":"standard_shipping"}] ["ORDER"] {} {}
    2024-09-24T08:07:37.001Z text 2 10 [{"fee":"standard_shipping"}] ["ORDER"] {} {}
    2024-09-24T08:07:37.001Z 2025-09-24T08:07:37.001Z "string" 10 [{"fee":"standard_shipping"}] ["ORDER"] {} {}
    2024-09-24T08:07:37.001Z 2025-09-24T08:07:37.001Z 2 "string" [{"fee":"standard_shipping"}] ["ORDER"] {} {}
    2024-09-24T08:07:37.001Z 2025-09-24T08:07:37.001Z 2 10 "normal_shipping" ["ORDER"] {} {}
    2024-09-24T08:07:37.001Z 2025-09-24T08:07:37.001Z 2 10 [{"fee":"standard_shipping"}] {} {} {}
    2024-09-24T08:07:37.001Z 2025-09-24T08:07:37.001Z 2 10 [{"fee":"standard_shipping"}] ["ORDER"] ["hidden": null] {}
    2024-09-24T08:07:37.001Z 2025-09-24T08:07:37.001Z 2 10 [{"fee":"standard_shipping"}] ["ORDER"] {} ["maxValue": 5000]
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 400 khi gửi lên customerLimit và numberOfVoucher là số âm

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Chủ phường "ownerclan" thấy phường "001" chưa có mã voucher "NATRA"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "config": {},
        "customerLimit": <customerLimit>,
        "numberOfVoucher": <numberOfVoucher>,
        "items": [
          {
            "fee": "standard_shipping"
          }
        ],
        "orderDiscount": {}
      }
    • Then Trả về status code 400
    • And Response có body thỏa mãn giá trị như sau
      {
        "title": "Constraint Violation",
        "violations": [
          {
              "field": "<field>",
              "message": "must be greater than or equal to 1"
          }
      ]
      }

    Examples:

    customerLimit numberOfVoucher field
    -2 10 customerLimit
    -2.4 10 customerLimit
    2 -10 numberOfVoucher
    2 -10.3 numberOfVoucher
  • Tags: @AUTOMATED, @TNK-12741

    Nếu body gửi lên customerLimit và numberOfVoucher (có định dạng integer) giá trị là số thập phân, thì hệ thống tự động lấy giá trị phần nguyên

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Chủ phường "ownerclan" thấy phường "001" chưa có mã voucher "NATRA"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "config": {},
        "customerLimit": 2.3,
        "numberOfVoucher": 10.4,
        "items": [
            {
            "fee": "standard_shipping"
            }
        ],
        "orderDiscount": {}
      }
    • Then Trả về status code 200
    • And Response có body thỏa mãn giá trị như sau
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "active": true,
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
            "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
            {
                "fee": "standard_shipping"
            }
        ]
      }
  • Tags: @AUTOMATED, @TNK-12741

    Trả status 400 khi gửi lên validTo nhỏ hơn validFrom, hoặc validFrom nhỏ hơn thời điểm hiện tại

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Chủ phường "ownerclan" thấy phường "001" chưa có mã voucher "NATRA"
    • And Thời gian hiện tại là "A"
    • And Thời gian áp dụng voucher là "<validFrom>"
    • And Thời gian hết hạn voucher là "<validTo>"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "title": "Test Voucher",
        "validFrom": "<validFromApply>",
        "validTo": "<validToApply>",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
          {
            "fee": "standard_shipping"
          }
        ],
        "config": {},
        "orderDiscount": {}
      }
    • Then Trả về status code 400
    • And Response có body thỏa mãn giá trị như sau
      {
        "title": "<message>"
      }

    Examples:

    validFrom validTo validFromApply validToApply message
    A+2 A+1 ${A+2} ${A+1} valid_from_not_greater_than_valid_to
    A-3 A-1 ${A-3} ${A-1} valid_to_not_greater_than_today
  • Tags: @AUTOMATED, @TNK-12741

    Tạo voucher cho cùng 1 phường, thì không được phép tạo trùng mã voucher (code)

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Tồn tại voucher có thông tin
      codeclannumberOfVoucherconditiondiscountTypeformulaitemsorderDiscount
      NATRA0012totalWeight >= 1PERCENT10[{"fee": "shipping_fee"}]{"maxValue": 5000,"discountLimit": 1000,"orderDiscountType": "totalValue"}
    • And Thời gian hiện tại là "A"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "title": "Test Voucher",
        "validFrom": "${A}",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
          {
            "fee": "standard_shipping"
          }
        ],
        "config": {},
        "orderDiscount": {}
      }
    • Then Trả về status code 400
    • And Response có body thỏa mãn giá trị như sau
      {
        "title": "voucher_code_exists"
      }
  • Tags: @AUTOMATED, @TNK-12741

    Tạo voucher cho các phường khác nhau thì có thể tạo trùng mã voucher (code)

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Tồn tại voucher có thông tin
      codeclannumberOfVoucherconditiondiscountTypeformulaitemsorderDiscount
      NATRA0012totalWeight >= 1PERCENT10[{"fee": "shipping_fee"}]{"maxValue": 5000,"discountLimit": 1000,"orderDiscountType": "totalValue"}
    • And Tài khoản "ownerclan01" đã tạo phường với thông tin
      codenamedescription
      002AutoTestCall API
    • And Thời gian hiện tại là "A"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "${002}",
        "code": "${NATRA}",
        "title": "Test Voucher",
        "validFrom": "${A}",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
          {
            "fee": "standard_shipping"
          }
        ],
        "config": {},
        "orderDiscount": {}
      }
    • Then Trả về status code 200
    • And Response có body thỏa mãn giá trị như sau
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "active": true,
        "title": "Test Voucher",
        "validFrom": "${A}",
        "applyScopes": [
            "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
            {
                "fee": "standard_shipping"
            }
        ]
      }
  • Tags: @AUTOMATED, @TNK-12741

    Tạo voucher-book thành công khi body chỉ gửi lên các thông tin bắt buộc

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Chủ phường "ownerclan" thấy phường "001" chưa có mã voucher "NATRA"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "config": {},
        "items": [
            {
            "fee": "standard_shipping"
            }
        ],
        "orderDiscount": {}
      }
    • Then Trả về status code 200
    • And Response có body thỏa mãn giá trị như sau
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "active": true,
        "title": "Test Voucher",
        "description": null,
        "validFrom": "2024-09-24T08:07:37.001Z",
        "validTo": null,
        "applyScopes": [
            "ORDER"
        ],
        "applyCondition": null,
        "discountType": "AMOUNT",
        "formula": "5000",
        "orderCode": null,
        "image": null,
        "termsAndConditions": null,
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "maxValue": null,
        "items": [
            {
                "fee": "standard_shipping",
                "maxValue": null,
                "discountLimit": null
            }
        ],
        "config": {
            "hidden": null,
            "single": null,
            "showLimit": null,
            "showRemaining": null,
            "showCustomerLimit": null
        },
        "orderDiscount": {
            "maxValue": null,
            "discountLimit": null,
            "orderDiscountType": null
        }
      }
  • Tags: @AUTOMATED, @TNK-12741

    Tạo voucher-book thành công khi body gửi lên đầy đủ thông tin

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Chủ phường "ownerclan" thấy phường "001" chưa có mã voucher "NATRA"
    • And Thời gian hiện tại là "A"
    • And Thời gian áp dụng voucher là "A-1"
    • And Thời gian hết hạn voucher là "A+10"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "title": "Test thui",
        "description": "test api Na",
        "validFrom": "${A-1}",
        "validTo": "${A+10}",
        "applyScopes": [
          "ORDER"
        ],
        "applyCondition": "totalWeight >= 1",
        "discountType": "PERCENT",
        "formula": "10",
        "orderCode": "",
        "image": "data:image/jpeg;base64…...",
        "termsAndConditions": "<div style=\"text-align: start;color: rgba(0, 0, 0, 0.8);background-color: rgb(255, 255, 255);font-size: 14px;\"><strong>….",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "maxValue": 5000,
        "items": [
          {
            "fee": "standard_shipping",
            "maxValue": 5000,
            "discountLimit": 1000
          }
        ],
        "config": {
          "hidden": true,
          "single": true,
          "showLimit": true,
          "showRemaining": true,
          "showCustomerLimit": true
        },
        "orderDiscount": {
          "maxValue": 5000,
          "discountLimit": 1000,
          "orderDiscountType": "totalValue"
        }
      }
    • Then Trả về status code 200
    • And Response có body thỏa mãn giá trị như sau
      {
        "clanCode": "${001}",
        "code": "${NATRA}",
        "active": true,
        "title": "Test thui",
        "description": "test api Na",
        "validFrom": "${A-1}",
        "validTo": "${A+10}",
        "applyScopes": [
            "ORDER"
        ],
        "applyCondition": "totalWeight >= 1",
        "discountType": "PERCENT",
        "formula": "10",
        "orderCode": "",
        "image": "data:image/jpeg;base64…...",
        "termsAndConditions": "<div style=\"text-align: start;color: rgba(0, 0, 0, 0.8);background-color: rgb(255, 255, 255);font-size: 14px;\"><strong>….",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "maxValue": 5000,
        "items": [
            {
                "fee": "standard_shipping",
                "maxValue": 5000,
                "discountLimit": 1000
            }
        ],
        "config": {
            "hidden": true,
            "single": true,
            "showLimit": true,
            "showRemaining": true,
            "showCustomerLimit": true
        },
        "orderDiscount": {
            "maxValue": 5000,
            "discountLimit": 1000,
            "orderDiscountType": "totalValue"
        }
      }
  • Tags: @AUTOMATED, @TNK-12741

    Một phường có thể tạo được nhiều voucher

    • Given Có token full quyền
    • And Tài khoản "ownerclan" đã tạo phường với thông tin
      codenamedescription
      001AutoTestCall API
    • And Tồn tại voucher có thông tin
      codeclannumberOfVoucherconditiondiscountTypeformulaitemsorderDiscount
      NATRA0012totalWeight >= 1PERCENT10[{"fee": "shipping_fee"}]{"maxValue": 5000,"discountLimit": 1000,"orderDiscountType": "totalValue"}
    • And Chủ phường "ownerclan" thấy phường "001" chưa có mã voucher "DATKY"
    • When Request có header là
      X-Tenantm26
    • And Gửi request "POST" đến "/admin/vouchers" với body
      {
        "clanCode": "${001}",
        "code": "${DATKY}",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
          "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "config": {},
        "items": [
            {
            "fee": "standard_shipping"
            }
        ],
        "orderDiscount": {}
      }
    • Then Trả về status code 200
    • And Response có body thỏa mãn giá trị như sau
      {
        "clanCode": "${001}",
        "code": "${DATKY}",
        "title": "Test Voucher",
        "validFrom": "2024-09-24T08:07:37.001Z",
        "applyScopes": [
            "ORDER"
        ],
        "discountType": "AMOUNT",
        "formula": "5000",
        "customerLimit": 2,
        "numberOfVoucher": 10,
        "items": [
            {
                "fee": "standard_shipping"
            }
        ]
      }