omaralalwi/laravel-taxify
Composer 安装命令:
composer require omaralalwi/laravel-taxify
包简介
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. it's offers a straightforward and efficient solution Designed to streamline the
关键字:
README 文档
README
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.
Requirements
Laravel 8.x or up , for version 2.x .
Installation
composer require omaralalwi/laravel-taxify
publish the package's configuration file:
php artisan vendor:publish --tag=taxify
Compatibility
For applications running Laravel versions 7.x and older, use version 1.0.4.
composer require omaralalwi/laravel-taxify:^1.0.4
Usage
Available Helper Functions
laravel taxify many of helper functions to simplify usage.
calculateTax().calculateTaxForCollection().getTaxAmount().getTaxRate().getTaxType().getTaxRateAsPercentage().
calculate tax for an amount:
- use
calculateTaxto get Tax As object (default).
$amount = 250; $taxAmount = calculateTax($amount,'profileName')->tax_amount; // 37.5
Another way to get Detailed Result.
$amount = 250; $tax = calculateTax($amount,'profileName');
Result (Object)
$tax = { "amount_with_tax": 287.5, "tax_amount": 37.5, "tax_rate": 0.15, }
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 .
- use
calculateTaxForCollectionto get a tax for a collection of amounts by passing amounts as array (first param) -> Result wanted as object (default).
// you can pass number as float or integer $productAmount = 250; $featureAmount = 70.5; $warrantyAmount = 30.60; $chargeAmount = 90; $tax = calculateTaxForCollection([$productAmount,$featureAmount, $warrantyAmount, $chargeAmount]);
Result (object)
$tax = { "amount_with_tax": 507.265, "tax_amount": 66.165, "tax_rate": 0.15, }
$taxAmount = $tax->tax_amount // 66.165
Get Tax Amount as numeric value
- use
getTaxAmountto get Tax Amount as number
$amount = 250; getTaxAmount($amount); // Result 25
Get tax rate or tax amount:
- use
getTaxRateto get Tax Rate or amount (according to tax type for specified profile in config file)
getTaxRate() // Result 0.15
getTaxRate('sales') // fore specific profile // Result 50 , here the result is fixed number because the profile type is fixed amount Not percentage
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:
- use
getTaxTypeto you can get Tax Type
getTaxType('profileName') // Result: fixed or percentage // depend on profile settings
Get tax rate as Percentage number (10%, 15%) - for percentage profiles Only:
you can get Tax Rate As Percentage
- you can get a tax rate percentage (for percentage type only)
getTaxRateAsPercentage(); // Result '10.00%'
Note: for default profile no need to pass it
Configuration
Environment Variables
after you published config file .
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:
DEFAULT_TAXIFY_PROFILE="default" TAXIFY_DEFAULT_RATE="0.10" TAXIFY_DEFAULT_TYPE="percentage"
example configuration for fixed tax type:
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 .
Features
- Calculate tax for individual amounts or a collection of amounts
- Retrieve tax amount, rate, and type for any profile as individual.
- Retrieve tax
amount_with_taxandtax_amountandtax_ratefor any profile as individual for one amount or a collection of amounts - Get tax rate as a percentage (for percentage type only)
- Customizable configuration options through environment variables easy.
- helper functions easy-to-use.
- support all php and laravel versions.
- Exception Handling: Robust error handling to ensure smooth operation and easy debugging.
- Logging: Automatic logging of errors and exceptions for better error tracking and debugging.
- Unit Tests.
Testing
php artisan test --filter TaxifyTest
Contributing
Please see CONTRIBUTING for details.
TODO
this todo list , contain the tasks that we planning to working on them, you can choose one of them and develop it if you want to contribute.
Security
If you discover any security related issues, please email omaralwi2010@gmail.com.
Credits
License
The MIT License (MIT). Please see License File for more information.
📚 Helpful Open Source Packages
-
Lexi Translate simplify managing translations for multilingual Eloquent models with power of morph relationships and caching . -
Gpdf Open Source HTML to PDF converter for PHP & Laravel Applications, supports Arabic content out-of-the-box and other languages.. -
laravel Deployer Streamlined Deployment for Laravel and Node.js apps, with Zero-Downtime and various environments and branches. -
laravel Trash Cleaner clean logs and debug files for debugging packages. -
laravel Time Craft simple trait and helper functions that allow you, Effortlessly manage date and time queries in Laravel apps. -
Laravel Startkit Laravel Admin Dashboard, Admin Template with Frontend Template, for scalable Laravel projects.
omaralalwi/laravel-taxify 适用场景与选型建议
omaralalwi/laravel-taxify 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.09k 次下载、GitHub Stars 达 47, 最近一次更新时间为 2024 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel-helpers」 「laravel-helper」 「laravel-facade」 「laravel-library」 「laravel-vat」 「omaralalwi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 omaralalwi/laravel-taxify 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 omaralalwi/laravel-taxify 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 omaralalwi/laravel-taxify 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
a package for collections of custom toolkit
Biblioteca que contem helpers para projetos PHP
Various helpers and tools for Laravel
Global helpers for Laravel projects
Integration with DeviceDetector and Laravel.
Laravel package using for creating a new facade and it's structure.
统计信息
- 总下载量: 2.09k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 47
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-25