Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
omaralalwi committed Mar 2, 2024
1 parent 277b0a5 commit 78d0753
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 213 deletions.
212 changes: 2 additions & 210 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Laravel Taxify

<p align="center">
<a href="https://github.com/omaralalwi/laravel-taxify" target="_blank">
<a href="https://omaralalwi.github.io/laravel-taxify" target="_blank">
<img src="https://raw.githubusercontent.com/omaralalwi/laravel-taxify/master/public/images/taxify.jpg" alt="Laravel Taxify">
</a>
</p>

Laravel Taxify provides a set of helper functions and classes to simplify tax (VAT) calculations within Laravel applications. that allow developers to easily integrate tax calculation functionalities into their projects with multi tax profiles settings and (fixed, percentage) ways. it's offers a straightforward and efficient solution Designed to streamline the process of handling taxes.

### [Documentation](https://omaralalwi.github.io/laravel-taxify)

## [Documentation](https://omaralalwi.github.io/laravel-taxify)

## Installation

Expand All @@ -31,213 +30,6 @@ publish only config file
php artisan vendor:publish --tag=laravel-taxify-config
```

## Compatibility

The Laravel Taxify package has different versions based on the compatibility with Laravel and PHP versions.

### Laravel v7.x and Earlier

For Laravel versions `5.8`, `6.x`, `7.x`, and PHP version `7.4`, use version `1.0.4` of the Laravel Taxify package.

```bash
composer require omaralalwi/laravel-taxify:^1.0.4
```

### Laravel v8.x and Later

For Laravel versions `8.x`, `9.x`, `10.x`, and PHP versions `8.0`, `8.1`, `8.2`, `8.3`, and higher, use at least version `2.0.x` of the Laravel Taxify package, and keep up to date.


## Configuration

### Environment Variables

You can configure Laravel Taxify by adding the following default configuration keys to your `.env` file. If you do not add these, the default values will be used.

For a percentage tax type:

```markdown
DEFAULT_TAXIFY_PROFILE="default"
TAXIFY_DEFAULT_RATE="0.10"
TAXIFY_DEFAULT_TYPE="percentage"
```

For a fixed tax type:

```markdown
DEFAULT_TAXIFY_PROFILE="default"
TAXIFY_DEFAULT_RATE=50
TAXIFY_DEFAULT_TYPE="fixed"
```

**Note:** The `TAXIFY_DEFAULT_RATE` is a number representing the rate when the type is `percentage` or the amount when type is `fixed`.

You can add more than one of tax profile in config/taxify.php .

## Usage

### Available Helper Functions

laravel taxify many of helper functions to simplify usige.
- `calculateTax()` --> common usage.
- `calculateTaxForCollection()` common usage with E-commerce and Enterprise Applications.
- `getTaxAmount()` .
- `getTaxRate()` .
- `getTaxType()` .
- `getTaxRateAsPercentage()` .
### Examples:
#### Calculate tax for an amount:
- get Tax As object (default)
by default the function return result as object
```markdown
$amount = 250;
$tax = calculateTax($amount,'profileName');
```
Result (object)
```
amount_with_tax: 275
tax_amount: 25
tax_rate: 0.1
```
access it as object property
```markdown
$taxAmount = $tax->tax_amount
// 25
$AmountWithTax = $tax->amount_with_tax
// 275
$taxRate = $tax->tax_rate
// 0.1
```

Or simpilify
```markdown
$amount = 250;
$taxAmount = calculateTax($amount,'profileName')->tax_amount;
```

- get Tax As Array
you can pass $asArray param as true to get result as array
```markdown
$amount = 250;
$tax = calculateTax($amount,'profileName',true);
```
Result
```
array (
'amount_with_tax' => 220.0,
'tax_amount' => 20.0,
'tax_rate' => 0.1,
);
```
access it as object property
```markdown
$taxAmount = $tax['tax_amount']
// 25
$AmountWithTax = $tax['amount_with_tax']
// 275
$taxRate = $tax['tax_rate']
// 0.1
```

Or simpilify
```markdown
$amount = 250;
$taxAmount = calculateTax($amount,'',true)['tax_amount'];
```
**Note**: the second param refer to profile, we mad it null to take default profile, second param can take (`default`, null,''') all three values mean `default`.

#### Calculate tax for a collection of amounts:

like calculateTax but this for a many amounts .
- get a tax for a collection of amounts by passing amounts as array (first param).
```markdown
// you can pass number as float or integer
$productAmount = 250;
$featureAmount = 70.5;
$sarrantyAmount = 30.60;
$chargeAmount = 90;

$tax = calculateTaxForCollection([$productAmount,$featureAmount, $sarrantyAmount, $chargeAmount]);
```
Result (object)
```markdown
'amount_with_tax' => 485.21,
'tax_amount' => 44.11,
'tax_rate' => 0.1,
```

access it as object property
```markdown
$taxAmount = $tax->tax_amount
// 485.21
$AmountWithTax = $tax->amount_with_tax
// 44.11
$taxRate = $tax->tax_rate
// 0.1
```

#### Get Tax Amount as numeric value

- get Tax Amount as number
```markdown
$amount = 250;
getTaxAmount($amount);
```
Result
```markdown
25
```

#### Get tax rate or tax amount:

- get Tax Rate or amount (according to tax type for specified profile in config file)

```markdown
getTaxRate()
```
Result
```markdown
0.1
```

```markdown
getTaxRate('sales')
```
Result
```markdown
50
```
if profile tax type is `fixed` will return the amount (read the tax rate as amount), else will return the tax rate.

**Note**: for default profile no need to pass `profileName`.

#### Get tax type:

you can get Tax Type
```markdown
getTaxType('profileName')
```
Result:
```
fixed or percentage // according to profile settings
```

#### Get tax rate as Percentage number (10%, 15%) - for percentage type Only:

you can get Tax Rate As Percentage
- you can get a tax rate percentage (for percentage type only)
```markdown
getTaxRateAsPercentage();
```
Result
```
'10.00%'
```
**Note**: for default profile no need to pass it

## Features

- Calculate tax for individual amounts or a collection of amounts
Expand Down
3 changes: 0 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

Laravel Taxify provides a set of helper functions and classes to simplify tax (VAT) calculations within Laravel applications. that allow developers to easily integrate tax calculation functionalities into their projects with multi tax profiles settings and (fixed, percentage) ways. it's offers a straightforward and efficient solution Designed to streamline the process of handling taxes.

### [Documentation](https://omaralalwi.github.io/laravel-taxify)


## Installation

You can install latest stable version of package via Composer:
Expand Down

0 comments on commit 78d0753

Please sign in to comment.