TaxCalculator class

税务计算器

提供税务计算的统一入口,支持含税/不含税金额的双向计算。

主要功能

  • 统一的计算入口 calculate
  • 自动选择计算策略
  • 参数校验和异常处理

计算模式

  1. 含税计算不含税:根据含税金额计算不含税金额和税额
  2. 不含税计算含税:根据不含税金额计算含税金额和税额

使用示例

final operator = TaxOperator();
final sources = {
  TaxField.quantity: 10,
  TaxField.taxRate: 0.13,
  TaxField.taxIncludedUnitPrice: 113,
};

// 含税计算不含税
TaxCalculator.calculate(operator, sources);

// 不含税计算含税
TaxCalculator.calculate(operator, sources, isByTaxExcluded: true);

异常处理

  • sources 为空时抛出 ArgumentError
  • 计算过程中的异常由具体策略类处理

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

calculate(TaxOperator operator, Map<TaxField, dynamic> sources, {bool isByTaxExcluded = false}) → void
执行税务计算