2017 © Pedro Peláez
 

library tax-calculator

A set of interfaces and methods to clean up your application's tax calculations

image

spatie/tax-calculator

A set of interfaces and methods to clean up your application's tax calculations

  • Saturday, May 5, 2018
  • by Spatie
  • Repository
  • 4 Watchers
  • 23 Stars
  • 79 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 7 Versions
  • 3 % Grown

The README.md

A set of interfaces and methods to clean up your application's tax calculations

Latest Version on Packagist Software License Tests Total Downloads, (*1)

A set of interfaces and methods to clean up your application's tax calculations. The TaxCalculation class allows you to do calculations with plain numbers and objects that implement the HasTax interface on the fly., (*2)

use Spatie\TaxCalculator\TaxCalculation;

$items = $myCart->getItems(); // Should return an array of items that implement `HasTax`

TaxCalculation::fromCollection($items)->basePrice(); // 10.00
TaxCalculation::fromCollection($items)->taxPrice(); // 2.10
TaxCalculation::fromCollection($items)->taxedPrice(); // 12.10

$delivery = TaxCalculation::fromTaxedPrice(7.50, 0.21);

TaxCalculation::fromCollection($items)->add($delivery)->taxedPrice(); // 19.60

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website., (*3)

Support us

, (*4)

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products., (*5)

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall., (*6)

Postcardware

You're free to use this package (it's MIT-licensed), but if it makes it to your production environment you are required to send us a postcard from your hometown, mentioning which of our package(s) you are using., (*7)

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium., (*8)

The best postcards will get published on the open source page on our website., (*9)

Installation

You can install the package via composer:, (*10)

``` bash composer require spatie/tax-calculator, (*11)


## Usage ### Interfaces The interfaces are provided so you can keep working with your domain objects instead of having to pass around floats everywhere. However, they're not strictly necessary to do calculations. #### `Spatie\TaxCalculator\HasTax` ```php public function basePrice(): float; public function taxedPrice(): float; public function taxPrice(): float;
  • basePrice: The item's price excluding taxes
  • taxedPrice: The item's price including taxes
  • taxPrice: The item's tax amount (= taxedPrice() - basePrice())

Spatie\TaxCalculator\HasTaxWithRate

public function taxRate(): float;

HasTaxWithRate extends HasTax, and also has a taxRate method. This is useful for items that have a fixed tax rate, but can't be used on collections that contain items with various rates., (*12)

Traits

Spatie\TaxCalculator\Traits\HasTaxWithRate

The HasTaxWithRate trait provides default implementations of taxPrice and taxedPrice, since they can be deducted by a simple multiplication of basePrice and taxRate., (*13)

Calculations

..., (*14)

Changelog

Please see CHANGELOG for more information what has changed recently., (*15)

Testing

bash $ composer test, (*16)

Contributing

Please see CONTRIBUTING for details., (*17)

Security

If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker., (*18)

Credits

About Spatie

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website., (*19)

License

The MIT License (MIT). Please see License File for more information., (*20)

The Versions

05/05 2018

dev-master

9999999-dev https://github.com/spatie/tax-calculator

A set of interfaces and methods to clean up your application's tax calculations

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

spatie tax-calculator

19/08 2016

0.1.1

0.1.1.0 https://github.com/spatie/tax-calculator

A set of interfaces and methods to clean up your application's tax calculations

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

spatie tax-calculator

19/08 2016

0.1.0

0.1.0.0 https://github.com/spatie/tax-calculator

A set of interfaces and methods to clean up your application's tax calculations

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

spatie tax-calculator

19/08 2016

0.0.4

0.0.4.0 https://github.com/spatie/tax-calculator

A set of interfaces and methods to clean up your application's tax calculations

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

spatie tax-calculator

12/08 2016

0.0.3

0.0.3.0 https://github.com/spatie/tax-calculator

A set of interfaces and methods to clean up your application's tax calculations

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

spatie tax-calculator

09/08 2016

0.0.2

0.0.2.0 https://github.com/spatie/tax-calculator

A set of interfaces and methods to clean up your application's tax calculations

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

spatie tax-calculator

26/07 2016

0.0.1

0.0.1.0 https://github.com/spatie/tax-calculator

A set of interfaces and methods to clean up your application's tax calculations

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

spatie tax-calculator