== Placing an Order ==== Actors: **Registered Shopper** **1.** The user selects products and proceeds to checkout. **2.** The system checks if the user has a delivery address. {{{#!sql SELECT CASE WHEN EXISTS ( SELECT 1 FROM delivery_address WHERE client_ID = '1001' ) THEN 'Yes' ELSE 'No' END AS has_address; }}} **3.** If not, the user will need to provide a delivery address. {{{#!sql INSERT INTO delivery_address(client_ID, address, city, postcode, country, is_default) VALUES ('1001', bul.Partizanski Odredi num.52/4' , 'Skopje', '1000', 'Macedonia', TRUE); }}} **4.** The application creates a new order in {{{order}}}. {{{#!sql INSERT INTO "order" (order_num, client_ID, last_date_mod, payment_method) VALUES ('00125100001', 1001, CURRENT_TIMESTAMP,'credit card, **** **** **** 6750'); }}} **5.** Products are added to the order using {{{includes}}}. {{{#!sql INSERT INTO includes (order_num, product_code) VALUES ('00125100001', '00100001'); }}} **6.** Store employees are nottifed that a new order has been placed and are given the information about the order.