This is the solution for the technical challenge - Document Validation Prototype
It can be run by opening index.html
from the dist
directory in a browser or by running yarn dev
(yarn
command should be run before installing required dependencies) and opening http://localhost:9000/
address.
The solution utilizes TypeScript for type safety and is built into a webpage for demo purposes. It can be converted into a server-side solution if needed.
Input data contains only necessary data for demonstration purposes: Attendance Record includes employeeId
, date
, and hours
fields, and Payroll Record includes employeeId
, date
, and hours
fields. Both models can be found in src/models
directory and can be extended with any additional data if needed.
Input data is set up in demoData.ts
. It consists of several attendance and payroll records for several different months for two employees. There can be any number, order, and combination of records.
Output is performed to the browser console. Also, the validation result is visualised as a table.
Validation is split into two steps: gathering validation data (validation/composeValidationData.ts
) (calculating monthly reported and paid hours), and then this data is converted into a validation result (validation/validate.ts
). For this solution, just the result
field with "success" or "mismatch" value is added to the gathered data, but it can be extended to a more complex validation result.
It is assumed that we validating records by month periods. If there are no records for a specific month, then we don't perform any validation. If there are records of only one type, then either the employee did not report any hours or there was no payment.
Models can be extended to include other data required for validation.
Validation can be performed by different time periods (e.g., weekly, or even with flex periods based on data provided to the engine).
This solution can be converted to a microservice that accepts some already prepared data (it can be in the form of extended models of this solution) and returns a validation result in any form convenient for the recipient. Data preparation can be performed differently for different sources, e.g., each source can have a different microservice for data retrieval and conversion, or e.g. client-uploaded files can be processed on the client side. Or all logic or any parts of it can be implemented in a monolithic server. It can even be rewritten to any other language and framework because the core of this solution is just a few files.