
Payroll
SOCIALDOCUMENTSESCROWFINANCIAL
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 name | type | details |
---|---|---|
_addr | ethereum address | the account address of the employee to be added |
_jobStartDate | integer | the 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 name | type | details |
---|---|---|
_employeeID | integer | unique identifier of the employee to be paid |
_amount | integer | amount 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 name | type | details |
---|---|---|
_employeeID | integer | unique identifier of the employee that left |
_jobEndDate | integer | the date when the employee stopped working for the company (unix time) |
getEmployeeDetails returns the details of a particular employee
parameter name | type | details |
---|---|---|
_employeeID | integer | unique identifier of the employee to be queried |
getPaymentDetails returns the details of a particular payment made to a specific employee
parameter name | type | details |
---|---|---|
_employeeID | integer | unique identifier of the employee to be queried |
_paymentID | integer | unique 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 name | type | details |
---|---|---|
EmployeeID | integer | the ID of the added employee |
PaymentMade
parameter name | type | details |
---|---|---|
EmployeeID | integer | the ID of the employee to be paid |
PaymentID | integer | the ID of the the payment |
NewBalance
parameter name | type | details |
---|---|---|
Balance | integer | the current balance of the contract |