public decimal CalculateTax(string country) { decimal taxAmount = -1; // Get the subtotal ISubtotal subtotal = _accessorFactory.CreateAccessor <ISubtotal>(); // Get the right tax rate accessor ITaxRate tax = _accessorFactory.CreateAccessor <ITaxRate>(country); // Check to see if a tax rate accessor was created if (tax != null) { // Have the tax rate accessor calculate the tax amount tax.RequestTaxCalculation(subtotal.GetSubtotal()); // Check to see if accessor was able to calculate the tax bool taxResult = tax.CheckTaxResult(); // Get the tax amount if accessor was able to calculate taxes if (taxResult == true) { taxAmount = tax.GetTaxAmount(); } } return(taxAmount); }
/// <inheritdoc /> public string PresentSubtotal(ISubtotalResult raw, ISubtotal par, IEntitiesSerializer serializer) { m_Par = par; Ga = par.GatherType; Cu = par.EquivalentCurrency; Serializer = serializer; Sb = new StringBuilder(); Depth = 0; Pre(); raw?.Accept(this); Post(); return(Sb.ToString()); }
public static SubtotalLevel PreprocessDetail(this ISubtotal query) { var level = query.Levels.Aggregate(SubtotalLevel.None, static (total, l) => total | l); if (query.AggrType != AggregationType.None) { level |= query.AggrInterval; } if (query.EquivalentDate.HasValue) { level |= SubtotalLevel.Currency; } return(level); }
public static SubtotalLevel PreprocessVoucher(this ISubtotal query) { if (query.GatherType != GatheringType.VoucherCount) { throw new InvalidOperationException("记账凭证分类汇总只能计数"); } if (query.EquivalentDate.HasValue) { throw new InvalidOperationException("记账凭证分类汇总不能等值"); } var level = query.Levels.Aggregate(SubtotalLevel.None, static (total, l) => total | l); if (query.AggrType != AggregationType.None) { level |= query.AggrInterval; } if (level.HasFlag(SubtotalLevel.User)) { throw new InvalidOperationException("记账凭证不能按用户分类汇总"); } if (level.HasFlag(SubtotalLevel.Currency)) { throw new InvalidOperationException("记账凭证不能按币种分类汇总"); } if (level.HasFlag(SubtotalLevel.Title)) { throw new InvalidOperationException("记账凭证不能按一级科目分类汇总"); } if (level.HasFlag(SubtotalLevel.SubTitle)) { throw new InvalidOperationException("记账凭证不能按二级科目分类汇总"); } if (level.HasFlag(SubtotalLevel.Content)) { throw new InvalidOperationException("记账凭证不能按内容分类汇总"); } if (level.HasFlag(SubtotalLevel.Remark)) { throw new InvalidOperationException("记账凭证不能按备注分类汇总"); } return(level); }
/// <inheritdoc /> public async IAsyncEnumerable <string> PresentSubtotal(ISubtotalResult raw, ISubtotal par, IEntitiesSerializer serializer) { m_Par = par; Ga = par.GatherType; Cu = par.EquivalentCurrency; Serializer = serializer; Depth = 0; await foreach (var s in Pre()) { yield return(s); } if (raw != null) { await foreach (var s in raw.Accept(this)) { yield return(s); } } await foreach (var s in Post()) { yield return(s); } }
public SubtotalBuilder(ISubtotal par, IExchange ex) { m_Par = par; m_Exchange = ex; }
/// <inheritdoc /> public string PresentSubtotal(ISubtotalResult raw, ISubtotal par, IEntitiesSerializer serializer) { m_Par = par; m_Depth = 0; return((raw?.Accept(this)?.Value as JObject)?.ToString()); }
/// <inheritdoc /> public IAsyncEnumerable <string> PresentSubtotal(ISubtotalResult raw, ISubtotal par, IEntitiesSerializer serializer) { m_Par = par; m_Depth = 0; return(AsyncEnumerable.Repeat((raw?.Accept(this)?.Value as JObject)?.ToString(), 1)); }
public static bool ShouldAvoidZero(this ISubtotal query) => query.AggrType != AggregationType.ChangedDay && query.Levels.LastOrDefault().HasFlag(SubtotalLevel.NonZero);
public SubtotalBuilder(ISubtotal par) => m_Par = par;