Bill Scheduler
Overview
This bill scheduler is a cronjob scheduler for calculating the supervision bill. It runs based on environment configuration. It triggers multiple APIs to generate the supervision bill.
Dependency
MDMS
User
Contract
Expense Calculator
Key Functionalities
It creates supervision bills based on ACTIVE contracts using expense-calculate service /v1/_calculate API.
Code
Configuration
Create a role in
ACCESSCONTROL-ROLES/roles.json
MDMS like this.Create a
SYSTEM
user with BILL_CREATOR andSYSTEM
roles. Find the curl below.The same username will be used to generate bills BILL_GEN_CRONJOB, it’s defined in the environment config.
Cron job duration will be configured using environment variables from here.
Deployment
Update Scheduler
There are two ways to update the configuration of the scheduler:
Add the config in the DevOps environment file, and restart the service. This will trigger the scheduler based on the updated environment configuration and restart the
expense-cronjob
service.
Use the commands given below: Change schedule - kubectl patch cronjobs expense-cronjob -p '{"spec" : {"schedule": "*/10 * * * *" }}'
Pause cron job - kubectl patch cronjobs expense-cronjob -p '{"spec" : {"suspend" : true }}' Resume cron job - kubectl patch cronjobs expense-cronjob -p '{"spec" : {"suspend" : false}}' Create a new cronjob scheduler - kubectl create job --from=cronjob/expense-cronjob expense-cronjob