Giter VIP home page Giter VIP logo

automated-payroll's Introduction

The New Boston - Core Team Automated Payroll Script

To run:

  • clone repo and install dependencies
    • git clone [email protected]:nax3t/automated-payroll.git
    • cd automated-payroll
    • npm install
  • Rename example.env to .env and populate with required values
  • Change testing variable to false in app.js (if not already false)
  • Run the program with node app.js

Error key:

  • green: payment succeeded
  • red: payment failed (see error)
  • yellow: payment held for manual review due to amount over 10,000 TNBC

Script Notes:

  • The script will automatically pull up all the issues from thenewboston-github repositories, where payments need to do, with the Ready to pay label added to them and in the open state.
    • Check that 'Ready to pay' label added by correct user
    • Update ids being used for 'Ready to pay' label user check
    • Need to update the labels being used in the code to pull in Ready to Pay Timesheet issues from the API
  • Collect this info from issues and core members API:
    • Contributor account address
    • Hourly Rate
    • Total time spent
    • Types of payment: Core team payment / Bounty / Project
    • Issue id
  • Print any transactions where insufficient data is available to make a valid transaction, e.g., no hourly rate
  • Generate appropriate memo for each payment based on standard memo format
  • Print payment sheet. Highlight those issues with more than 10000TNBC to be sent at once.
  • Payer will run the pay command after reviewing the payment sheet.
    • Use either a mailer notification or create a new github issue for these kinds of manual verification payments
  • Payment by the script:
  • Send coins to the contributor
  • Confirm transaction is successful
  • Add Paid label to the issue
  • Remove Ready to pay label to the issue
  • Close the issue
  • Print all successful and failed payments
  • Use agenda js to create a background job that runs the script daily on a production server

automated-payroll's People

Contributors

manishram avatar nax3t avatar

Stargazers

 avatar

Watchers

 avatar

automated-payroll's Issues

Some ideas to make this more readable

I have a few ideas to help make this a little more readable, and wonder if I worked on this would you accept the pull request.

API Client

We can create an instance of axios client with the base URL, any credentials thats needed. When we call the API we would do so with our instance.

Add Service Layer

Basically a service is just a function or class that does some work. It just does 1 thing and 1 thing only. GetAccountsPayableService for example.

Personal preferences

https://github.com/nax3t/automated-payroll/blob/main/app.js#L72-L73

We can do something like this instead: action.label?.name === 'Ready to pay'

Create a Webhook instead?

At the end of the day we have an interval when we need to do work.

https://github.com/nax3t/automated-payroll/blob/main/app.js#L181-L186

Consider having some other service, like GitHub, handling the cron to send it to our webhook.

https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#scheduled-events

Track payment ledgers

What happens if a payment failed? why? where are we logging it? what would you do right now if payment failed and someone asked you to look into it? When you do track it in a database this is a secondary action so I would take a instance of eventemitter with something like this pattern

https://refactoring.guru/design-patterns/observer

Low balance case

Expected
When the sender account balance is lower than amount + fees then it should show payment failed.

Actually
Shows payment succeeded but there is no transaction.

Add Service Layer

In order to make the code more readable, and testable we should introduce a service layer to the project. Basically a service is just a function or class that does some work. It just does 1 thing and 1 thing only. GetAccountsPayableService for example.

AC:

  • Start moving logic to services. ( GetAccountsPayableService as an example )

Depends on:

Create an API Client

We can create an instance of axios client with the base URL, any credentials thats needed to make API request. When we call the API we would do so with our instance.

AC:

  • Create a Custom Axios Instance
  • In at least 1 place call the API with our custom Axios Instance

Only use the GitHub username to find the member from API

Let's only use the GitHub username to find the member from API to get hourly rates.

Problem:
This line of code is creating a problem because we have led76marx and toledit in our team with led as part of their name.

Due to this reason, toledit was receiving the payment with an hourly rate of led76marx.

Also, we should get rid of this code there are possible edge cases for this too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.