{"id":13579094,"url":"https://github.com/spatie/tax-calculator","last_synced_at":"2025-04-07T17:10:59.874Z","repository":{"id":45919955,"uuid":"62890657","full_name":"spatie/tax-calculator","owner":"spatie","description":"A set of interfaces and methods to clean up your application's tax calculations","archived":false,"fork":false,"pushed_at":"2024-07-03T10:05:17.000Z","size":53,"stargazers_count":73,"open_issues_count":0,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-24T12:14:24.433Z","etag":null,"topics":["calculations","php","tax"],"latest_commit_sha":null,"homepage":"https://spatie.be/open-source","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"spatie","custom":"https://spatie.be/open-source/support-us"}},"created_at":"2016-07-08T13:28:12.000Z","updated_at":"2025-03-21T12:15:11.000Z","dependencies_parsed_at":"2024-08-01T15:30:12.763Z","dependency_job_id":"694e1891-8cce-463e-bd7f-3c8f199a1131","html_url":"https://github.com/spatie/tax-calculator","commit_stats":{"total_commits":33,"total_committers":8,"mean_commits":4.125,"dds":0.6060606060606061,"last_synced_commit":"327c13071b909baad1270d1c03c2a733bb1594ce"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Ftax-calculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Ftax-calculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Ftax-calculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Ftax-calculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/tax-calculator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246497937,"owners_count":20787230,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calculations","php","tax"],"created_at":"2024-08-01T15:01:36.495Z","updated_at":"2025-03-31T16:18:55.485Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie","https://spatie.be/open-source/support-us"],"categories":["PHP"],"sub_categories":[],"readme":"# A set of interfaces and methods to clean up your application's tax calculations\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/tax-calculator.svg?style=flat-square)](https://packagist.org/packages/spatie/tax-calculator)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Tests](https://github.com/spatie/tax-calculator/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/tax-calculator/actions/workflows/run-tests.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/tax-calculator.svg?style=flat-square)](https://packagist.org/packages/spatie/tax-calculator)\n\nA 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.\n\n```php\nuse Spatie\\TaxCalculator\\TaxCalculation;\n\n$items = $myCart-\u003egetItems(); // Should return an array of items that implement `HasTax`\n\nTaxCalculation::fromCollection($items)-\u003ebasePrice(); // 10.00\nTaxCalculation::fromCollection($items)-\u003etaxPrice(); // 2.10\nTaxCalculation::fromCollection($items)-\u003etaxedPrice(); // 12.10\n\n$delivery = TaxCalculation::fromTaxedPrice(7.50, 0.21);\n\nTaxCalculation::fromCollection($items)-\u003eadd($delivery)-\u003etaxedPrice(); // 19.60\n```\n\nSpatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/tax-calculator.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/tax-calculator)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe 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](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Postcardware\n\nYou're free to use this package (it's [MIT-licensed](LICENSE.md)), 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.\n\nOur address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.\n\nThe best postcards will get published on the open source page on our website.\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require spatie/tax-calculator\n```\n\n## Usage\n\n### Interfaces\n\nThe 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.\n\n#### `Spatie\\TaxCalculator\\HasTax`\n\n```php\npublic function basePrice(): float;\npublic function taxedPrice(): float;\npublic function taxPrice(): float;\n```\n\n- `basePrice`: The item's price excluding taxes\n- `taxedPrice`: The item's price including taxes\n- `taxPrice`: The item's tax amount (`= taxedPrice() - basePrice()`)\n\n#### `Spatie\\TaxCalculator\\HasTaxWithRate`\n\n```php\npublic function taxRate(): float;\n```\n\n`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.\n\n### Traits\n\n### `Spatie\\TaxCalculator\\Traits\\HasTaxWithRate`\n\nThe `HasTaxWithRate` trait provides default implementations of `taxPrice` and `taxedPrice`, since they can be deducted by a simple multiplication of `basePrice` and `taxRate`.\n\n### Calculations\n\n...\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Credits\n\n- [Sebastian De Deyne](https://github.com/sebastiandedeyne)\n- [All Contributors](../../contributors)\n\n## About Spatie\nSpatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Ftax-calculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Ftax-calculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Ftax-calculator/lists"}