cyntaria / ConstructionERP-Backend

A REST API backend system for the construction ERP software made with NodeJS
Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

As a product owner, I should be able to create payment types, so that I can contractor can choose them as a reason while making payments #56

Open arafaysaleem opened 3 years ago

arafaysaleem commented 3 years ago

Summary

As a product owner, I should be able to create payment types, so that the contractor can choose them as a reason while making payments.

Acceptance Criteria

GIVEN an product owner is creating a payment type in the desktop app WHEN the app hits the /payment-types endpoint with a valid POST request, containing:

THEN the app should receive a status 201 AND in the response, the following information should be returned:

Sample Request/Sample Response

headers: {
    error: 0,
    message: "..."
}
body: {
    "pay_type_id": "0",
    "affected_rows": 1
}

Resources

Dev Notes

{Some complementary notes if necessary}

Testing Notes

Scenario 1: POST request is successful

  1. Create a new payment type with a POST request to /payment-types endpoint and ensure a 201 status code is returned.
  2. Use the id returned by the response in a subsequent GET request to /payment-types/:id endpoint and ensure a 200 status code is returned.
  3. Ensure the response contains a payment type with the correct information i.e. matching the initially sent body.

Scenario 2: POST request is incorrect

  1. Send a POST request to /payment-types endpoint with an incorrect key name in the body
  2. Ensure a 422 status code is returned
  3. And the response headers' code parameter should contain an error pointing out failed validation.

Scenario 3: POST request is forbidden

  1. Send a POST request to /payment-types endpoint with a contractor account token.
  2. Ensure a 403 forbidden status code is returned.
  3. And the response headers' code parameter should contain an error pointing out failed access.