This NodeJS and ExpressJS application is designed to process an XLS file containing invoice data. It includes validation for the file structure and performs specific calculations and validations on the data. Follow the steps below to set up and run the application.
npm installat the root- Fill ENVs
npm run startat the root- Enjoy <3
Endpoint:
POST /uploadRequest Parameters:
invoicingMonth(Format: YYYY-MM)
Request Payload:
Form data with the file field containing the XLS file.
Sample Request:
curl -X POST -H "Content-Type: multipart/form-data" -F "file=@/path/to/Test_task.xlsx" -F "invoicingMonth=2024-03" http://localhost:3000/uploadSample Response:
{
"InvoicingMonth": "2023-09",
"currencyRates": {
"USD": 3.849,
"EUR": 4.0575,
"GBP": 4.7003
},
"invoicesData": [
{
"Customer": "Coca Col",
"Cust No'": 21314,
"Project Type": "Marketing",
"Quantity": 12,
"Price Per Item": 2,
"Item Price Currency": "USD",
"Total Price": 10000,
"Invoice Currency": "USD",
"Status": "Ready",
"Invoice #": null,
"Contract Comments": "Remind next month",
"Invoice Total": null,
"validationErrors": [
"[Total Price]: isn't correct (12 * 2 not equal 10000)"
]
}
]
}- Only relevant lines with a status of "ready" or having the "Invoice #" filled are processed.
- Mandatory fields for validation: Customer, Cust No', Project Type, Quantity, Price Per Item,* Item Price Currency, Total Price, Invoice Currency, Status.