InVoice PDF Generator Service
This project contains a micro service that is intended to generate invoices and offers for YSLG.
The project is written in node.js. It uses the pdfkit library to generate the PDF files and express to handle REST calls.
Add .env file as of such
DB_HOST = localhost
DB_PORT = 5432
DB_USER = postgres
DB_PASSWORD = changeme
DB_NAME = postgres
DB_LOGGING = false
NODE_ENV = "development"
IS_EXPOSE_SWAGGER = true
LOG_LEVEL = debug
HTTP_PORT = 4000
AWS_CLOUDFRONT_URL = localhost:4000
AWS_S3_BUCKET_NAME = production-time-expense-invoicing-file-storage
AZURE_IDENTITY_ISSUER_URI = "https://sts.windows.net/49419910-b998-4795-8014-760d87d4222a/"
AUTHORIZE = false
TZ = UTC
From the root directory enter the following commands:
npm install
docker compose up
npm run start:migrate
To build the docker container run
docker build -t younivoice-pdf-app . --build-arg APP_VERSION=local
To run the docker container locally type
docker run -p 3000:3000 younivoice-pdf-app
The service does not offer any authentication.
The service offers the following rest routes that can be used to
- /api/v1/pdf/offer - generate a offer for a customer
- /api/v1/pdf/invoice - generate an invoice
- /api/v1/pdf/query - find a document
Search all documents created in 2022 or later "http://localhost:3000/api/v1/pdf/query?year=>=2022"
All numeric values can be used with operator the syntax is paramName=OperatorValue, OperatorValue is an operator choosen from <, >, =, <=, >=. Value is a numeric value.
searchtext = Text is searched in all request json data and document name, case is ignored.
cash = Total amount of cash value of the offer or invoice, is a numeric value
hours = total number of hours billed, numeric value
year = created at year, numeric value
month = created at month, numeric value
day = created at day, numeric value
This is used when to company makes an offer to a customer.
To understand the data structure have a look at the demo data.
In ./demodata/offer_dsp.json is a json request file that can be passed to the service to generate an output. To use it with curl type:
curl -X POST -H "Content-Type: application/json" -d "$(cat ./demodata/offer_dsp.json)" http://localhost:3000/api/v1/pdf/offer
The following parameters are optional in "offer_details"
- "suppressSumRow" : default false
- "suppressTaxesRow" : default false
- "suppressTotalRow" : default false