Payroll

Under Review

DOCUMENTSESCROWFINANCIAL

Contract purpose

This Smart Contract manages the monthly payments for the employees of a company. The system manager is in charge of adding all the employee's details( account address, job start date) to the contract list. The system manager is also in charge with updating the employee's job end date when an employee leaves the job. The constructor is payable, meaning that when the contract is created, some amount of ether has to be sent to the contract's balance. From this balance, the payments to the employees are made. The manager can increase this balance at any time.

Exposed methods and variables

systemManager the ethereum address of the system manager, given as parameter at contract creation

addEmployee allows the manager to add a new employee on the payroll and it emits the EmployeeAdded event which will contain the employeeID that will further identify this particular employee

parameter nametypedetails
_addrethereum addressthe account address of the employee to be added
_jobStartDateintegerthe date when the employee started working for the company (unix time)

payEmployee payable function called by the manager to create a new Payment in the system, sending to the chosen employee the amount given as parameter and it emits the PaymentMade event,logging the employeeID and the ID of this payment

parameter nametypedetails
_employeeIDintegerunique identifier of the employee to be paid
_amountintegeramount to be paid

endJobEmployee in case an employee left the job, this thing has to be updated because this employee can no longer receive payments

parameter nametypedetails
_employeeIDintegerunique identifier of the employee that left
_jobEndDateintegerthe date when the employee stopped working for the company (unix time)

getEmployeeDetails returns the details of a particular employee

parameter nametypedetails
_employeeIDintegerunique identifier of the employee to be queried

getPaymentDetails returns the details of a particular payment made to a specific employee

parameter nametypedetails
_employeeIDintegerunique identifier of the employee to be queried
_paymentIDintegerunique identifier of the payment to be queried

increaseBalance allows the manager to increase the available balance of the contract. It emits the NewBalance event, logging the current balance.

getBalance returns the balance of the contract when called by the manager

Events

EmployeeAdded

parameter nametypedetails
EmployeeIDintegerthe ID of the added employee

PaymentMade

parameter nametypedetails
EmployeeIDintegerthe ID of the employee to be paid
PaymentIDintegerthe ID of the the payment

NewBalance

parameter nametypedetails
Balanceintegerthe current balance of the contract
Reviewed by Modex
Buy
Buy Contract

Create an account or login to purchase this smart contract