Files
GX.O3.WMS/APP.O3/Shared/Utils/CalculateAmount.cs
T

117 lines
3.9 KiB
C#
Executable File

using System;
using System.Collections.Generic;
using System.Text;
namespace Opsoft.NetCore.O3App.Shared.Utils
{
/// <summary>
/// 金额计算公共类
/// </summary>
public class CalculateAmount
{
/// <summary>
/// 含税单价
/// </summary>
public decimal FTAXPRICE { get; set; }
private decimal Qty { get; set; }
public decimal FDISCOUNTRATE { get; set; }
public decimal FTAXRATE { get; set; }
private decimal ExchangeRate { get; set; }
/// <summary>
/// 保留几位小数
/// </summary>
private int IRound { get; set; }
/// <summary>
/// 本国币保留小数
/// </summary>
private int IRound_LC { get; set; }
/// <summary>
/// 未税单价保留小数
/// </summary>
private int IRound_Price { get; set; }
/// <summary>
///
/// </summary>
/// <param name="Price">含税单价</param>
/// <param name="Qty">数量</param>
/// <param name="DiscountRate">折扣率</param>
/// <param name="TaxRate">税率</param>
/// <param name="ExchangeRate">汇率</param>
public CalculateAmount(decimal TaxPrice, decimal Qty, decimal DiscountRate, decimal TaxRate, decimal ExchangeRate, int IRound = 2, int IRound_LC = 2, int IRound_Price = 4)
{
this.FTAXPRICE = TaxPrice;
this.Qty = Qty;
this.FDISCOUNTRATE = DiscountRate;
this.FTAXRATE = TaxRate;
this.ExchangeRate = ExchangeRate;
this.IRound = IRound;
this.IRound_LC = IRound_LC;
this.IRound_Price = IRound_Price;
this.InI();
}
/// <summary>
/// 开始计算
/// </summary>
private void InI()
{
this.FDISCOUNT = Math.Round((this.FTAXPRICE * this.Qty) * (this.FDISCOUNTRATE / 100), this.IRound); //折扣额
this.FALLAMOUNT = Math.Round((this.FTAXPRICE * this.Qty), this.IRound) - this.FDISCOUNT; //价税合计
this.FAMOUNT = Math.Round(this.FALLAMOUNT / (1 + this.FTAXRATE / 100), this.IRound); //金额
this.FTAXAMOUNT = this.FALLAMOUNT - this.FAMOUNT; //税额
this.FALLAMOUNT_LC = Math.Round(this.FALLAMOUNT * this.ExchangeRate, this.IRound_LC); //价税合计本国币
this.FAMOUNT_LC = Math.Round(this.FAMOUNT * this.ExchangeRate, this.IRound_LC); //金额本国币
this.FTAXAMOUNT_LC = this.FALLAMOUNT_LC - this.FAMOUNT_LC; //税额本国币
this.FPRICE = Math.Round(this.FTAXPRICE / (1 + this.FTAXRATE / 100), this.IRound_Price); //未税价
}
/// <summary>
/// 税额
/// </summary>
public decimal FTAXAMOUNT { get; set; }
/// <summary>
/// 税额(本位币)
/// </summary>
public decimal FTAXAMOUNT_LC { get; set; }
/// <summary>
/// 金额
/// </summary>
public decimal FAMOUNT { get; set; }
/// <summary>
/// 金额(本位币)
/// </summary>
public decimal FAMOUNT_LC { get; set; }
/// <summary>
/// 价税合计
/// </summary>
public decimal FALLAMOUNT { get; set; }
/// <summary>
/// 价税合计(本位币)
/// </summary>
public decimal FALLAMOUNT_LC { get; set; }
/// <summary>
/// 折扣额
/// </summary>
public decimal FDISCOUNT { get; set; }
/// <summary>
/// 未税单价
/// </summary>
public decimal FPRICE { get; set; }
}
}