using System;
using System.Collections.Generic;
using System.Text;
namespace Opsoft.NetCore.O3App.Shared.Utils
{
///
/// 金额计算公共类
///
public class CalculateAmount
{
///
/// 含税单价
///
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; }
///
/// 保留几位小数
///
private int IRound { get; set; }
///
/// 本国币保留小数
///
private int IRound_LC { get; set; }
///
/// 未税单价保留小数
///
private int IRound_Price { get; set; }
///
///
///
/// 含税单价
/// 数量
/// 折扣率
/// 税率
/// 汇率
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();
}
///
/// 开始计算
///
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); //未税价
}
///
/// 税额
///
public decimal FTAXAMOUNT { get; set; }
///
/// 税额(本位币)
///
public decimal FTAXAMOUNT_LC { get; set; }
///
/// 金额
///
public decimal FAMOUNT { get; set; }
///
/// 金额(本位币)
///
public decimal FAMOUNT_LC { get; set; }
///
/// 价税合计
///
public decimal FALLAMOUNT { get; set; }
///
/// 价税合计(本位币)
///
public decimal FALLAMOUNT_LC { get; set; }
///
/// 折扣额
///
public decimal FDISCOUNT { get; set; }
///
/// 未税单价
///
public decimal FPRICE { get; set; }
}
}