Point of Sale - Условие PDF
Point of Sale - Условие PDF
Point of Sale - Условие PDF
You are assigned to implement a Web application (SPA) using HTML5, JavaScript, AJAX, REST and JSON with cloud-
based backend (Kinvey). The app that keeps users (cashiers), product entires and receipts. Users can register, login,
logout, access the main view where a receipt can be composed (add products with their qunatity and price and
save the basket to the database), list of all receipts and a receipt details view.
You are allowed to use libraries like jQuery, Handlebars and Sammy. Frameworks and libraries like React, Angular,
Vue are not permitted!
401 Unauthorized {
"error": "InvalidCredentials",
"description": "Invalid credentials. …",
"debug": ""
}
Error response {
"error": "UserAlreadyExists",
409 Conflict
"description": "This username is already taken. …",
"debug": ""
}
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
Follow us: Page 1 of 7
Using Postman or other HTTP client tool (you can use Kinvey’s built-in API Console), test the REST service endpoints:
Request body {
"username": "testuser",
"password": "testuserpass890"
}
The request needs “Basic” authentication. Use the Kinvey App Key and Kinvey App Secret as credentials.
User Login
POST https://baas.kinvey.com/user/app_key/login
Request body {
"username": "testuser",
"password": "testuserpass890"
}
Successful login returns an “authtoken” which is later used to authenticate the CRUD operations.
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
Follow us: Page 2 of 7
User Logout
POST https://baas.kinvey.com/user/app_key/_logout
To logout, you need to provide the “authtoken” given by login / register as “Kinvey” authorization header.
This will return the receipt that’s active for the currently logged in user. Use this to populate the Editor, or if it’s not
found – create a new receipt and set it to be active.
You may use this query to get all entries of the currently active receipt, or entries for receipt details.
Create Receipt
POST https://baas.kinvey.com/appdata/app_key/receipts
Request body {
"active": true,
"productCount": 0,
"total": 0
}
Add Entry
POST https://baas.kinvey.com/appdata/app_key/entries
Request body {
"type": "Apple",
"qty": 5,
"price": 0.3,
"receiptId": "59affdae3044bb86044a79bd"
}
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
Follow us: Page 3 of 7
New entries should always be added to the active receipt.
Delete Entry
DELETE https://baas.kinvey.com/appdata/app_key/entries/entry_id
Get My Receipts
GET https://baas.kinvey.com/appdata/app_key/receipts?query={"_acl.creator":"userId","active":"false"}
Use the ID of the currently logged in user. The user should see only his or her receipts on the overview screen.
Receipt Details
GET https://baas.kinvey.com/appdata/app_key/receipts/receipt_id
Commit Receipt
PUT https://baas.kinvey.com/appdata/app_key/receipts/receipt_id
Request body {
"active": false,
"productCount": 0, // Sum of all products
"total": 0, // Total cost of all products
// Other receipt properties
}
To mark a receipt as finalized (client has checked out), simply update it to set its active property to false. You need
to send the whole receipt object, so don’t forget to fetch the receipt from the database first.
Initially all views and forms are shown by the HTML. Your application may hide by CSS (display: none) or
delete from the DOM all unneeded elements or just display the views it needs to display.
You may render the views / forms / components with jQuery or Handlebars.
Important: don’t change the elements’ class name and id. Don’t rename form fields / link names / ids. You are
allowed to add data attributes to any elements. You may modify href attributes of links and add action/method
attributes to forms, to allow the use of a routing library.
Including the <section> elements is required for the style to display correctly!
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
Follow us: Page 4 of 7
Problem 4. Client-Side Web Application
Design and implement a client-side front-end app (SPA). Implement the functionality described below.
In case of error, an error notification message (red) should be shown which disappears on user click.
During the AJAX calls a loading notification message (blue) should be shown. It should disappear
automatically as soon as the AJAX call is completed.
Clicking on the links in the menu or individual links should display the view behind the link (views are
sections in the HTML code).
The given „Navigation“ menu should be visible only for logged in users. Anonymous users can only view the
sign in/register section.
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
Follow us: Page 5 of 7
Login User Screen (5 pts)
By given username and password the app should be able to login an existing user.
After a successful login, a notification message “Login successful.” should be displayed and and the user
should be redirected to the home view.
In case of error, an appropriate error message should be displayed and the user should be able to fill the
login form again.
Form validation should be the same as register.
Keep the user session data in the browser’s session storage.
Clear all input fields after successful login.
Logout (5 pts)
Successfully logged in user should be able to logout from the app.
After a successful logout, a notification message “Logout successful.” should be displayed.
After successful logout, the Sign In screen should be shown.
The “logout” REST service at the back-end should be obligatory called at logout.
All local information in the browser (user session data) about the current user should be deleted.
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
Follow us: Page 6 of 7
Update Sub-total and Total (5 pts)
When the user enters a valid value for Quantity and Price per Unit, the displayed values for Sub-total for the new
entry and Total for the receipt should be updated.
Remove Entry (5 pts)
Clicking the delete button next to each entry must remove it from the database and delete the row from the table.
After successful deletion, update the value of Total. Display a notification “Entry removed” and remove the
corresponding elements from the list of entries.
Checkout Receipt (10 pts)
Clicking on Checkout should perform the following:
Display a notification “Receipt checked out”
Update the receipt in the database to have its active property set to false and the properties productCount
and total populated with the correct values
Prepare the editor for a new receipt by creating it in the database and clearing the screen of any old
information.
Before carrying out any actions, make sure the receipt contains at least one entry – the user should not be able to
checkout an empty receipt!
© Software University Foundation. This work is licensed under the CC-BY-NC-SA license.
Follow us: Page 7 of 7