定制 mibo/prices 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mibo/prices

Composer 安装命令:

composer require mibo/prices

包简介

PHP lib for prices

README 文档

README

codecov

The library serves a Price class that can be used to represent a price in an object that can be sold or has its value.

Goals:

  • Calculating multiple prices;
  • Calculating multiple prices with different currencies;
  • Calculating multiple prices with different tax rates;
  • Combination of any or all above.

User of this library should mainly use \MiBo\Prices\Price class, that comes with an implementation of \MiBo\Prices\Contracts\PriceInterface, or \MiBo\Properties\Contracts\NumericalProperty, meaning, the class follows native add, subtract methods. The PriceInterface extends the NumericalProperty Interface by adding getValueOfVAT and getValueWithVAT methods that can be used to get value of either VAT or both, VAT and the base value. The Interface then extends the PropertyInterface by forCountry method that can be used when one wants to change the VAT of the Price for a specific country.

Installation

composer require mibo/prices

Usage

$price = new \MiBo\Prices\Price(
    10,
    \MiBo\Prices\Units\Price\Currency::get("EUR"),
    \MiBo\Prices\Calculators\PriceCalc::getVATManager()->retrieveVAT($classification, 'SVK')
);
$price->getValue(); // 10
$price->getValueOfVAT(); // 2 (20% of 10 for the day of writing this)
$price->getValueWithVAT(); // 12 (10 + 2)

$price->forCountry("CZE");
$price->getValueWithVAT(); // 11.5 (10 + 1.5 for the day of writing this)

NOTE:

  • Before using conversion of currencies, one must require a library that provides conversion rates. The conversion is not part of this library!
  • Before using conversion of VAT rates, one must require a library that provides VAT rates. The conversion is not part of this library!

Logic of the library

This library one extends MiBo\Properties library by a Price, using MiBo\VAT to get VAT for the Prices, and MiBo\Currencies for currencies - units of the Prices.

Calculators

PriceCalc class is there to calculate multiple prices, either adding them together, or subtracting them. The point is to have this process on the single place. The Calculator checks the currencies and VAT rates.

Price

The \MiBo\Prices\Price class, the (main) property, is a class-to-be-used by a user. One should not have a need to use another class.

Changes, updates, etc.

The library does not cover a conversion between currencies, nor VAT rates. If one wants to have that solved, check composer suggestions. If empty, the libraries that are focused on that are not yet published, however, they are under development and will be available soon.

Notes

Please, be aware that comparing prices is complex and should be done with care. Currently, the library does provide a way to compare prices, however, that is being marked as deprecated and experimental, even tho, it should work fine. One should make sure that the behavior is as expected, because comparing a price with VAT and currency is way too hard.

mibo/prices 适用场景与选型建议

mibo/prices 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.6k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「package」 「php」 「library」 「money」 「currency」 「price」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mibo/prices 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mibo/prices 我们能提供哪些服务?
定制开发 / 二次开发

基于 mibo/prices 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.6k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 31
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-11