| | 1 | == Placing an Order |
| | 2 | |
| | 3 | ==== Actors: **Registered Shopper** |
| | 4 | |
| | 5 | **1.** The user selects products and proceeds to checkout. |
| | 6 | |
| | 7 | **2.** The system checks if the user has a delivery address. |
| | 8 | |
| | 9 | {{{#!sql |
| | 10 | SELECT CASE |
| | 11 | WHEN EXISTS ( |
| | 12 | SELECT 1 |
| | 13 | FROM delivery_address |
| | 14 | WHERE client_ID = '1001' |
| | 15 | ) THEN 'Yes' |
| | 16 | ELSE 'No' |
| | 17 | END AS has_address; |
| | 18 | |
| | 19 | }}} |
| | 20 | |
| | 21 | **3.** If not, the user will need to provide a delivery address. |
| | 22 | |
| | 23 | {{sql#! |
| | 24 | INSERT INTO delivery_address(client_ID, address, city, postcode, country, is_default) VALUES |
| | 25 | ('1001', bul.Partizanski Odredi num.52/4' , 'Skopje', '1000', 'Macedonia', TRUE); |
| | 26 | |
| | 27 | }}} |
| | 28 | |
| | 29 | **4.** The application creates a new order in {{{order}}}. |
| | 30 | |
| | 31 | {{{#!sql |
| | 32 | INSERT INTO "order" (order_num, client_ID, last_date_mod, payment_method) VALUES |
| | 33 | ('00125100001', 1001, CURRENT_TIMESTAMP,'credit card, **** **** **** 6750'); |
| | 34 | |
| | 35 | }}} |
| | 36 | |
| | 37 | **5.** Products are added to the order using {{{includes}}}. |
| | 38 | |
| | 39 | {{{#!sql |
| | 40 | INSERT INTO includes (order_num, product_code) |
| | 41 | VALUES ('00125100001', '00100001'); |
| | 42 | |
| | 43 | }}} |
| | 44 | |
| | 45 | **6.** Store employees are nottifed that a new order has been placed and are given the information about the order. |