2017 © Pedro Peláez
 

library ringgit

Malaysia Ringgit implementation on top of Money PHP

image

jomweb/ringgit

Malaysia Ringgit implementation on top of Money PHP

  • Friday, July 13, 2018
  • by crynobone
  • Repository
  • 5 Watchers
  • 14 Stars
  • 1,780 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 14 Versions
  • 107 % Grown

The README.md

Malaysia Ringgit implementation on top of Money PHP

tests Latest Stable Version Total Downloads Latest Unstable Version License Coverage Status, (*1)

PHP 8.0+ library to make working with money safer, easier, and fun for Malaysia Ringgit!, (*2)

"If I had a dime for every time I've seen someone use FLOAT to store currency, I'd have $999.997634" -- Bill Karwin, (*3)

In short: You shouldn't represent monetary values by a float. Wherever you need to represent money, use this Money value object., (*4)

``` php <?php, (*5)

use Duit\MYR;, (*6)

$fiveMyr = MYR::given(500); $tenMyr = $fiveMyr->add($fiveMyr);, (*7)

list($part1, $part2, $part3) = $tenMyr->allocate(array(1, 1, 1)); assert($part1->equals(MYR::given(334))); assert($part2->equals(MYR::given(333))); assert($part3->equals(MYR::given(333)));, (*8)


* [Installation](#installation) * [Usages](#usages) - [Taxes](#taxes) ## Installation To install through composer, simply put the following in your `composer.json` file: ```json { "require": { "jomweb/ringgit": "^2.0" } }

And then run composer install from the terminal., (*9)

Quick Installation

Above installation can also be simplify by using the following command:, (*10)

composer require "jomweb/ringgit"

Usages

Taxes

GST Declaration

Without GST

Declaring Money (MYR) without GST (Zero)., (*11)

use Duit\MYR;

$money = new MYR(540);
$money = MYR::given(540);
$money = MYR::withoutGst(540);
$money = MYR::withoutTax(540);
Before GST

Declaring Money (MYR) before GST is applied., (*12)

use Duit\MYR;
use Duit\Taxable\Gst\ZeroRate;
use Duit\Taxable\Gst\StandardRate;

$money = MYR::beforeGst(540);

$money = MYR::beforeTax(540, new StandardRate());
$money = MYR::beforeTax(540, new ZeroRate());

$money = MYR::given(540)->useGstStandardRate(); // 6%
$money = MYR::given(540)->useGstZeroRate(); // 0%

$money = MYR::given(540)->enableTax(new StandardRate());
$money = MYR::given(540)->enableTax(new ZeroRate());
After GST

Declaring Money (MYR) with GST amount., (*13)

use Duit\MYR;
use Duit\Taxable\Gst\ZeroRate;
use Duit\Taxable\Gst\StandardRate;

$money = MYR::afterGst(530); // always going to use 6%

$money = MYR::afterTax(540, new StandardRate());
$money = MYR::afterTax(540, new ZeroRate());

SST Declaration

Without SST

Declaring Money (MYR) without GST (Zero)., (*14)

use Duit\MYR;

$money = new MYR(540);
$money = MYR::given(540);
$money = MYR::withoutTax(540);
Before SST

Declaring Money (MYR) before SST is applied., (*15)

use Duit\MYR;
use Duit\Taxable\Sst;

$money = MYR::beforeTax(530, new Sst());

$money = MYR::given(530)->enableTax(new Sst());
After SST

Declaring Money (MYR) with SST tax., (*16)

use Duit\MYR;
use Duit\Taxable\Sst;

$money = MYR::afterTax(530, new Sst());

The Versions

13/07 2018

dev-master

9999999-dev

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

31/05 2018

v2.0.0

2.0.0.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

29/05 2018

v1.0.6

1.0.6.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

29/05 2018

1.0.x-dev

1.0.9999999.9999999-dev

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

21/05 2018

v1.0.5

1.0.5.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

30/04 2018

v1.0.4

1.0.4.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

03/04 2018

v1.0.3

1.0.3.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

30/12 2017

v1.0.2

1.0.2.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

26/10 2017

v1.0.1

1.0.1.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

09/10 2017

v1.0.0

1.0.0.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

06/10 2017

v0.3.0

0.3.0.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

04/10 2017

v0.2.1

0.2.1.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

04/10 2017

v0.2.0

0.2.0.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

03/10 2017

v0.1.0

0.1.0.0

Malaysia Ringgit implementation on top of Money PHP

  Sources   Download

MIT

The Requires

 

The Development Requires