Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone committed Dec 14, 2021
1 parent f20d4c0 commit 4974c0d
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 13 deletions.
8 changes: 7 additions & 1 deletion src/Concerns/Cash.php
Expand Up @@ -9,6 +9,8 @@ trait Cash
{
/**
* Get formatted amount.
*
* @return numeric-string
*/
public function amount(): string
{
Expand All @@ -17,6 +19,8 @@ public function amount(): string

/**
* Get formatted cash.
*
* @return numeric-string
*/
public function cashAmount(): string
{
Expand All @@ -27,6 +31,8 @@ public function cashAmount(): string

/**
* Get amount for cash.
*
* @return numeric-string
*/
public function getCashAmount(): string
{
Expand All @@ -38,7 +44,7 @@ public function getCashAmount(): string
/**
* Get closest accepted cash amount.
*
* @param int|string $amount
* @param int|numeric-string $amount
*/
protected function getClosestAcceptedCashAmount($amount): int
{
Expand Down
6 changes: 3 additions & 3 deletions src/Concerns/Gst.php
Expand Up @@ -12,7 +12,7 @@ trait Gst
/**
* Make object with GST.
*
* @param int|string $amount
* @param int|numeric-string $amount
*
* @return static
*/
Expand All @@ -24,7 +24,7 @@ public static function afterGst($amount)
/**
* Make object before applying GST.
*
* @param int|string $amount
* @param int|numeric-string $amount
*
* @return static
*/
Expand All @@ -36,7 +36,7 @@ public static function beforeGst($amount)
/**
* Make object without GST.
*
* @param int|string $amount
* @param int|numeric-string $amount
*
* @return static
*/
Expand Down
22 changes: 16 additions & 6 deletions src/Concerns/Tax.php
Expand Up @@ -20,7 +20,7 @@ trait Tax
/**
* Make object with Tax.
*
* @param int|string $amount
* @param int|numeric-string $amount
* @param \Duit\Contracts\Taxable $taxable
*
* @return static
Expand All @@ -35,7 +35,7 @@ public static function afterTax($amount, Taxable $taxable)
/**
* Make object before applying Tax.
*
* @param int|string $amount
* @param int|numeric-string $amount
* @param \Duit\Contracts\Taxable $taxable
*
* @return static
Expand All @@ -48,7 +48,7 @@ public static function beforeTax($amount, Taxable $taxable)
/**
* Make object without Tax.
*
* @param int|string $amount
* @param int|numeric-string $amount
*
* @return static
*/
Expand All @@ -59,6 +59,8 @@ public static function withoutTax($amount)

/**
* Get formatted amount with GST.
*
* @return numeric-string
*/
public function amountWithTax(): string
{
Expand All @@ -69,6 +71,8 @@ public function amountWithTax(): string

/**
* Get formatted cash with GST.
*
* @return numeric-string
*/
public function cashAmountWithTax(): string
{
Expand Down Expand Up @@ -111,6 +115,8 @@ final public function hasTax(): bool

/**
* Get GST amount.
*
* @return numeric-string
*/
public function getTaxAmount(): string
{
Expand All @@ -123,6 +129,8 @@ public function getTaxAmount(): string

/**
* Returns the value represented by this object with Tax.
*
* @return numeric-string
*/
public function getAmountWithTax(): string
{
Expand All @@ -135,6 +143,8 @@ public function getAmountWithTax(): string

/**
* Get amount for cash with Tax.
*
* @return numeric-string
*/
public function getCashAmountWithTax(): string
{
Expand All @@ -146,7 +156,7 @@ public function getCashAmountWithTax(): string
/**
* Allocate the money according to a list of ratios with Tax.
*
* @return Money[]
* @return array<int, \Money\Money>
*/
public function allocateWithTax(array $ratios): array
{
Expand All @@ -168,7 +178,7 @@ public function allocateWithTax(array $ratios): array
* @param int<1, max> $n
* @throws \InvalidArgumentException If number of targets is not an integer
*
* @return Money[]
* @return array<int, \Money\Money>
*/
public function allocateWithTaxTo(int $n): array
{
Expand Down Expand Up @@ -197,7 +207,7 @@ abstract public function getMoney(): Money;
/**
* Build money object.
*
* @param int|string $amount
* @param int|numeric-string $amount
*/
abstract protected static function asMoney($amount): Money;

Expand Down
2 changes: 2 additions & 0 deletions src/Contracts/Money.php
Expand Up @@ -6,6 +6,8 @@ interface Money
{
/**
* Returns the value represented by this object.
*
* @return numeric-string
*/
public function getAmount(): string;

Expand Down
6 changes: 6 additions & 0 deletions src/Contracts/Taxable.php
Expand Up @@ -8,16 +8,22 @@ interface Taxable
{
/**
* Get tax percentage.
*
* @return numeric-string
*/
public function getAmountWithoutTax(MoneyContract $money): string;

/**
* Get tax percentage.
*
* @return numeric-string
*/
public function getAmountWithTax(MoneyContract $money): string;

/**
* Get tax percentage.
*
* @return numeric-string
*/
public function getTaxAmount(MoneyContract $money): string;

Expand Down
8 changes: 5 additions & 3 deletions src/MYR.php
Expand Up @@ -32,7 +32,7 @@ class MYR implements Contracts\Money, \JsonSerializable
/**
* Construct a new MYR money.
*
* @param int|string $amount
* @param int|numeric-string $amount
*/
public function __construct($amount)
{
Expand All @@ -42,7 +42,7 @@ public function __construct($amount)
/**
* Construct a new MYR money.
*
* @param int|string $amount
* @param int|numeric-string $amount
*
* @return static
*/
Expand All @@ -54,7 +54,7 @@ public static function given($amount)
/**
* Parse value as ringgit.
*
* @param string|array $value
* @param numeric-string|array $value
*
* @return static
*/
Expand All @@ -78,6 +78,8 @@ public static function parse($value)

/**
* Returns the value represented by this object.
*
* @return numeric-string
*/
public function getAmount(): string
{
Expand Down
6 changes: 6 additions & 0 deletions src/Taxable.php
Expand Up @@ -23,6 +23,8 @@ abstract class Taxable implements Contracts\Taxable

/**
* Get tax percentage.
*
* @return numeric-string
*/
public function getAmountWithoutTax(Money $money): string
{
Expand All @@ -31,6 +33,8 @@ public function getAmountWithoutTax(Money $money): string

/**
* Get tax percentage.
*
* @return numeric-string
*/
public function getAmountWithTax(Money $money): string
{
Expand All @@ -39,6 +43,8 @@ public function getAmountWithTax(Money $money): string

/**
* Get tax percentage.
*
* @return numeric-string
*/
public function getTaxAmount(Money $money): string
{
Expand Down

0 comments on commit 4974c0d

Please sign in to comment.