Code Monkey home page Code Monkey logo

payslip-core's Introduction

Build Status Latest Stable Version Total Downloads Scrutinizer Code Quality License

Payslip Core

This package about provide a simple processor for payslip - calculate employee salary for the given year and month. Each employee have their own earnings and deductions.

Earnings - anything that related to employee for getting more amount of money like Travel Allowance, Meal Allowance, Director Allowance.

Deductions - anything that related to employee for getting less amount of money - Zakat, Laptop Loan, Insurance.

Earning / Deduction Contribution

To add new earning / deduction, you can implement CleaniqueCoders\Payslip\Contracts\Contribution interface. Once implement, you need to add following methods in your class:

public function name(): string
{
	return 'Director Allowance'
}

public function type(): string;
{
	return \CleaniqueCoders\Payslip\Payslip::EARNING; // for earning
	// return \CleaniqueCoders\Payslip\Payslip::DEDUCTION; // for deduction
}

public function contribution()
{
	return 1000; // do your logic to get the amount of contribution
}

Usage

// implement CleaniqueCoders\Payslip\Contracts\Employee interface
$employee = new \App\Models\Employee();
$salary   = new \CleaniqueCoders\Payslip\Salary();

// Earnings
// Implement CleaniqueCoders\Payslip\Contracts\Contribution interface
$basic_salary = new \App\Processors\Payslip\Earnings\BasicSalary();
$basic_salary->setAmount(5000);
$salary->addEarnings($basic_salary);

// Implement CleaniqueCoders\Payslip\Contracts\Contribution interface
$travel_allowance = new \App\Processors\Payslip\Earnings\TravelAllowance();
$travel_allowance->setAmount(500);
$salary->addEarnings($travel_allowance);

// @todo Deductions

// Payslip accept CleaniqueCoders\Payslip\Contracts\Employee contracts and
// CleaniqueCoders\Payslip\Salary object in the constructor
$payslip = new \CleaniqueCoders\Payslip\Payslip($employee, $salary);
$payslip
    ->setYear(2018)
    ->setMonth(10)
    ->setPayday('2018-10-28')
    ->handle();

$summary = $payslip->getSummary();

payslip-core's People

Contributors

nasrulhazim avatar

Watchers

 avatar

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.