# Manual Integration Test: Create Sales Order

## DESCRIPTION

Test entity creation with the Sales Orders application.

## PREPARATION

To check console errors open the developer tools before starting the application and check with each step, that there are no errors and warnings.

### Testing with mock data

Start the Sales Orders application with following URL (adjust host and port if necessary):

- local: http://localhost:8080/test-resources/sap/ui/core/demokit/sample/common/index.html?component=odata.v4.SalesOrders

### Testing with back end

Configure your IDE to be able to execute the Sales Orders application against an ABAP back end system.
Start the Sales Orders application with the URL (adjust host and port if necessary):

- local: http://localhost:8080/test-resources/sap/ui/core/demokit/sample/common/index.html?component=odata.v4.SalesOrders&realOData=true

## REALIZE and CHECK

### Modify Company Name in the Business Partner Details and check that Buyer Name in the Sales Order List is updated accordingly after saving.

1. Check: That you got the first `5` of `n` sales orders in the `Sales Orders` table with title "`n` New Sales Orders", whereas `n` is exactly `10` without back end.
2. Press the `More` button in the `Sales Orders` table.
3. Check: That you got the next `5` sales orders in the `Sales Orders` table. Without back end the `More` button now is gone.
4. Select the first sales order and check that the `Sales Order Details` becomes visible.
5. In the `Business Partner` details change the `Company Name` to `SAP - modified by OPA` (without back end) or any other value (with back end).
6. Press the `Save Sales Order` button.
7. Check That in the `Sales Orders` table the `Buyer Name` is updated accordingly for all sales orders having the same business partner.

### Create, modify and delete of an unsaved sales order

1. Select the first sales order.
2. Click on the `Value Help` button for `Category`in the `Sales Order Line Items` table.
3. Check: The title of the `Value Help` is "Value Help: Category (Modified Mapping)".
4. Close the `Value Help` dialog.
5. Click on the `Create` button in the `Sales Orders` table.
6. Check: The table below the `Create New Sales Order` dialog gets a new row with an empty `Sales Order ID` and the `Note` as displayed in the `Create New Sales Order` dialog.
7. Check: That for input field `Currency Code` a value help button is displayed.
8. Press the value help button and check that a value help dialog is opened.
9. Close the `Value Help` dialog.
10. Modify the content of the `Note` input field of the `Create New Sales Order` dialog.
11. Check: The `Note` of the first sales order (table below the dialog) is updated automatically after leaving the input field of the dialog.
12. Click on `OK` in the `Create New Sales Order` dialog.
13. Check: (without back end only) The sales orders count is 11 new and 23 overall.
14. Select the newly created sales order.
15. Modify the content of the `Note` in the newly created sales order.
16. Click on the `Delete` button in the `Sales Orders` table.
17. Check: The newly created sales order is gone.
18. Check: (without back end only) The sales orders count is 10.
19. Click on the `Save` button in the `Sales Orders` table.

### Create a sales order, save, modify again, save and delete

1. Click on the `Create` button in the `Sales Orders` table.
2. Modify the content of the `Note` input field of the `Create New Sales Order` dialog.
3. Click on `OK` in the `Create New Sales Order` dialog.
4. Check:The `Confirm selected sales order` button in the `Sales Orders` table is disabled.
5. Click on the `Save` button in the `Sales Orders` table.
6. Check: You get a success message for creating the sales order.
7. Click on `OK` in the `Success` dialog.
8. With back end only:
   1. Check:The `Confirm selected sales order` button in the `Sales Orders` table is enabled.
   2. Check: The `Sales Order ID` has been updated by the server.
   3. Check: The overall sales orders count has increased by one.
   4. For the newly created sales order enter a text in the `Note` field .
   5. Click on `Save` button in the `Sales Orders` table.
9. Select the saved sales order.
10. Click on `Delete` button in the `Sales Orders` table.
11. Check: The newly created sales order is gone.
12. Check: (with back end only) The overall sales orders count has decreased by one.

### Create a sales order, save and refresh the sales orders

1. Click on the `Create` button in the `Sales Orders` table.
2. Modify the content of the `Note` input field of the `Create New Sales Order` dialog.
3. Click on `OK` in the `Create New Sales Order` dialog.
4. Click on the `Save` button in the `Sales Orders` table.
5. Check: You get a success message for creating the sales order.
6. Click on `OK` in the `Success` dialog.
7. Check: (without back end only) The sales orders count is 11.
8. Click on `Refresh` button in the `Sales Orders` table.
9. Check: The first sales order is the same as the one from the initial application start.
10. Check (with back end only): The new sales order is inserted at the right position (considering sort and filter criterion); maybe you have to click on the `More` button of the `Sales Orders` table to see the new sales order.

### Create a sales order, refresh/filter w/o saving

1. Click on the `Create` button in the `Sales Orders` table.
2. Click on `OK` in the `Create New Sales Order` dialog.

#### Cancel refresh

3. Click on `Refresh all` button.
4. Check: You get a warning about pending changes.
5. Click on the `Cancel` button.
6. With back end only:
   1. Enter a numerical value in the `Filter by gross amount...` search field above the `Sales Orders` table and press `Enter`.
   2. Check: The list is properly filtered and the newly created sales order still exists.
   3. Click on `Refresh` button in the `Sales Orders` table.
   4. Check: The newly created sales order still exists.

#### Confirm refresh

10. Click on `Refresh all` button.
11. Check: You get a warning about pending changes.
12. Click on the `Ok` button.
13. Check: The newly created sales order is gone.

### Create a sales order, press "cancel sales order changes" w/o saving

1. Click on the `Create` button in the `Sales Orders` table.
2. Click on `OK` in the `Create New Sales Order` dialog.
3. Click on `Cancel sales orders changes` button in the `Sales Orders` table.
4. Check: The newly created sales order is gone.
5. Check: (without back end only) The sales orders count is 10.

### Cancel or resume a failed creation of a sales order

With back end only:

1. Click on the `Create` button in the `Sales Orders` table.
2. Click on `OK` in the `Create New Sales Order` dialog.
3. Type in `RAISE_ERROR` into the `Note` input field of the new row.
4. Click on the `Save` button in the `Sales Orders` table.
5. Check:You get an error regarding invalid value for the `Note`.
6. Click on `Refresh` button in the `Sales Orders` table.
7. Check: The newly created sales order is not yet gone.
8. Click on `Cancel sales orders changes` button in the `Sales Orders` table.
9. Check: The newly created sales order is gone.
10. Click on the `Create` button in the `Sales Orders` table.
11. Type in `RAISE_ERROR` into the `Note` input field of the `Create New Sales Order` dialog.
12. Click on `OK` in the `Create New Sales Order` dialog.
13. Click on the `Save` button in the `Sales Orders` table.
14. Check: A POST request for the created entity is sent to the server and you got the above error.
15. Click again on the `Save` button in the `Sales Orders` table.
16. Check: A POST request for the created entity is sent to the server and you got the above error again.
17. Modify the content of the `Note` in the newly created sales order.
18. Click on the `Save` button in the `Sales Orders` table.
19. Check: You get a success message for creating the sales order.
20. Click on `OK` in the `Success` dialog.
21. Check: The `Sales Order ID` has been updated by the server