|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using DSWeb.Areas.SysMng.DAL.DBTableConn;
|
|
|
|
|
using DSWeb.Areas.SysMng.Models.DBTableConn;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsCodeGoodInv;
|
|
|
|
|
using DSWeb.MvcShipping.Models.CodeGoodInv;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.Account.Models.Chfee_Invoiceapplication
|
|
|
|
|
{
|
|
|
|
|
[JsonObject]
|
|
|
|
|
public class ChInvoiceDetail : ModelObjectBillBody
|
|
|
|
|
{
|
|
|
|
|
#region private Fields
|
|
|
|
|
|
|
|
|
|
private string _gid = String.Empty;//主键唯一值
|
|
|
|
|
private string _pid = String.Empty;//主键唯一值
|
|
|
|
|
private decimal _serialNo = 0;
|
|
|
|
|
private string _goodsname = String.Empty;
|
|
|
|
|
private string _goodsnameref = String.Empty;
|
|
|
|
|
private string _spec = String.Empty;
|
|
|
|
|
private string _unit = String.Empty;
|
|
|
|
|
private decimal _taxprice = 0;
|
|
|
|
|
private decimal _pkgs = 0;
|
|
|
|
|
private decimal _price = 0;
|
|
|
|
|
private decimal _amount = 0;
|
|
|
|
|
private decimal _taxrate = 0;
|
|
|
|
|
private decimal _tax = 0;
|
|
|
|
|
private string _remark = String.Empty;
|
|
|
|
|
private string _goodcode = String.Empty;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Public Properties
|
|
|
|
|
|
|
|
|
|
[ModelDB(MDBType = ModelDBOprationType.All, IsPrimary = true)]
|
|
|
|
|
public string GID
|
|
|
|
|
{
|
|
|
|
|
get { return _gid; }
|
|
|
|
|
set { _gid = value; }
|
|
|
|
|
}
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public string PID
|
|
|
|
|
{
|
|
|
|
|
get { return _pid; }
|
|
|
|
|
set { _pid = value; }
|
|
|
|
|
}
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public decimal SERIALNO
|
|
|
|
|
{
|
|
|
|
|
get { return _serialNo; }
|
|
|
|
|
set { _serialNo = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public string GOODSNAME
|
|
|
|
|
{
|
|
|
|
|
get { return _goodsname; }
|
|
|
|
|
set { _goodsname = value; }
|
|
|
|
|
}
|
|
|
|
|
public string GOODSNAMEREF
|
|
|
|
|
{
|
|
|
|
|
get { return _goodsnameref; }
|
|
|
|
|
set { _goodsnameref = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public string SPEC
|
|
|
|
|
{
|
|
|
|
|
get { return _spec; }
|
|
|
|
|
set { _spec = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public string UNIT
|
|
|
|
|
{
|
|
|
|
|
get { return _unit; }
|
|
|
|
|
set { _unit = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public decimal PKGS
|
|
|
|
|
{
|
|
|
|
|
get { return _pkgs; }
|
|
|
|
|
set { _pkgs = value; }
|
|
|
|
|
}
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public decimal TAXPRICE
|
|
|
|
|
{
|
|
|
|
|
get { return _taxprice; }
|
|
|
|
|
set { _taxprice = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public decimal PRICE
|
|
|
|
|
{
|
|
|
|
|
get { return _price; }
|
|
|
|
|
set { _price = value; }
|
|
|
|
|
}
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public decimal TAXRATE
|
|
|
|
|
{
|
|
|
|
|
get { return _taxrate; }
|
|
|
|
|
set { _taxrate = value; }
|
|
|
|
|
}
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public decimal AMOUNT
|
|
|
|
|
{
|
|
|
|
|
get { return _amount; }
|
|
|
|
|
set { _amount = value; }
|
|
|
|
|
}
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public decimal TAX
|
|
|
|
|
{
|
|
|
|
|
get { return _tax; }
|
|
|
|
|
set { _tax = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public string REMARK
|
|
|
|
|
{
|
|
|
|
|
get { return _remark; }
|
|
|
|
|
set { _remark = value; }
|
|
|
|
|
}
|
|
|
|
|
[ModelDB]
|
|
|
|
|
public string GOODCODE
|
|
|
|
|
{
|
|
|
|
|
get { return _goodcode; }
|
|
|
|
|
set { _goodcode = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public tempfield 用于放置code_goods_inv当中的三个字段
|
|
|
|
|
|
|
|
|
|
public string ISUSEPREF //是否享受优惠政策 0或1
|
|
|
|
|
{ get; set; }
|
|
|
|
|
|
|
|
|
|
public string DEFREMARK //增值税特殊管理
|
|
|
|
|
{ get; set; }
|
|
|
|
|
|
|
|
|
|
public string ZTAXTYPE //零税率标识 数字或空
|
|
|
|
|
{ get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将发票金额反转成红票所需的负数
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void SetRed() {
|
|
|
|
|
if (PKGS > 0) PKGS = PKGS * -1;
|
|
|
|
|
if (TAX > 0) TAX = TAX * -1;
|
|
|
|
|
if (AMOUNT > 0) AMOUNT = AMOUNT * -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将发票金额反转成红票所需的负数
|
|
|
|
|
/// P2数据:数量为正价格为负 诺诺的要求则相反
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void SetRed_P2()
|
|
|
|
|
{
|
|
|
|
|
if (PKGS > 0) PKGS = PKGS * -1;
|
|
|
|
|
if (TAX > 0) TAX = TAX * -1;
|
|
|
|
|
if (AMOUNT > 0) AMOUNT = AMOUNT * -1;
|
|
|
|
|
if (TAXPRICE < 0) TAXPRICE = TAXPRICE * -1;
|
|
|
|
|
if (PRICE < 0) PRICE = PRICE * -1;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public ChInvoiceDetail()
|
|
|
|
|
{
|
|
|
|
|
TableName = "ch_fee_invoicedetail";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 使用其他数据类型填充该类型的方法 用于接入其他数据信息
|
|
|
|
|
|
|
|
|
|
public decimal TAXAMOUNT { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static List<ChInvoiceDetail> GetP2DetailList(BaseTableMC P2data,bool isred)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var INVOICE_ID = P2data.GetValue("BSNO");
|
|
|
|
|
|
|
|
|
|
BaseTableMC fromdbbase = new BaseTableMC("M_INVOICE", "INVOICE_ID", "", "P2DB");
|
|
|
|
|
|
|
|
|
|
var dataList = DBTableConnDAL.getToList(fromdbbase, "联力P2发票_明细", $"INVOICE_ID='{INVOICE_ID}'");
|
|
|
|
|
|
|
|
|
|
var result = new List<ChInvoiceDetail>();
|
|
|
|
|
|
|
|
|
|
var splitword = "\r\n";
|
|
|
|
|
|
|
|
|
|
if (dataList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var data in dataList)
|
|
|
|
|
{
|
|
|
|
|
var feenamearray = data.GetSplitField("FEENAME", splitword);
|
|
|
|
|
var amoutarray = data.GetSplitField("AMOUNT", splitword);
|
|
|
|
|
var PRICEarray = data.GetSplitField("PRICE", splitword);
|
|
|
|
|
var ratearray = data.GetSplitField("RATE", splitword);
|
|
|
|
|
var NUMarray = data.GetSplitField("NUM", splitword);
|
|
|
|
|
|
|
|
|
|
if (feenamearray.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
for (var _i = 0; _i < feenamearray.Length; _i++)
|
|
|
|
|
{
|
|
|
|
|
var resultdata = new ChInvoiceDetail();
|
|
|
|
|
|
|
|
|
|
//resultdata.SetValue("CURRENCY", data.GetValue("CURRENCY"));
|
|
|
|
|
//resultdata.SetValue("FEENAME", feenamearray[_i]);
|
|
|
|
|
//resultdata.SetValue("AMOUNT", amoutarray[_i]);
|
|
|
|
|
//resultdata.SetValue("PRICE", PRICEarray[_i]);
|
|
|
|
|
//resultdata.SetValue("RATE", ratearray[_i]);
|
|
|
|
|
//resultdata.SetValue("NUM", NUMarray[_i]);
|
|
|
|
|
|
|
|
|
|
resultdata.GID = "";
|
|
|
|
|
resultdata.SERIALNO = 1;
|
|
|
|
|
resultdata.SPEC = "";
|
|
|
|
|
resultdata.UNIT = "票";
|
|
|
|
|
resultdata.PKGS = NUMarray[_i] == "" ? 0 : Convert.ToDecimal(NUMarray[_i]);
|
|
|
|
|
resultdata.TAXPRICE = PRICEarray[_i] == "" ? 0 : Convert.ToDecimal(PRICEarray[_i]);
|
|
|
|
|
resultdata.TAXAMOUNT = amoutarray[_i] == "" ? 0 : Convert.ToDecimal(amoutarray[_i]);
|
|
|
|
|
resultdata.TAXRATE = ratearray[_i] == "" ? 0 : Convert.ToDecimal(ratearray[_i]);
|
|
|
|
|
resultdata.GOODSNAME = feenamearray[_i];
|
|
|
|
|
|
|
|
|
|
result.Add(resultdata);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var resultdata = new ChInvoiceDetail();
|
|
|
|
|
|
|
|
|
|
resultdata.GID = "";
|
|
|
|
|
resultdata.SERIALNO = 1;
|
|
|
|
|
resultdata.SPEC = "";
|
|
|
|
|
resultdata.UNIT = "票";
|
|
|
|
|
resultdata.PKGS = NUMarray[0] == "" ? 0 : Convert.ToDecimal(NUMarray[0]);
|
|
|
|
|
resultdata.TAXPRICE = PRICEarray[0] == "" ? 0 : Convert.ToDecimal(PRICEarray[0]);
|
|
|
|
|
resultdata.TAXAMOUNT = amoutarray[0] == "" ? 0 : Convert.ToDecimal(amoutarray[0]);
|
|
|
|
|
|
|
|
|
|
if (resultdata.TAXAMOUNT < resultdata.TAXPRICE * resultdata.PKGS) {
|
|
|
|
|
resultdata.TAXAMOUNT = resultdata.TAXPRICE * resultdata.PKGS;
|
|
|
|
|
}
|
|
|
|
|
resultdata.TAXRATE = ratearray[0]==""?0: Convert.ToDecimal(ratearray[0]);
|
|
|
|
|
|
|
|
|
|
resultdata.GOODSNAME = feenamearray[0];
|
|
|
|
|
result.Add(resultdata);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var feecodelist = MsCodeGoodInvDAL.GetDataList("");
|
|
|
|
|
|
|
|
|
|
foreach (var detail in result) {
|
|
|
|
|
detail.setP2value(feecodelist);
|
|
|
|
|
|
|
|
|
|
if (isred) {
|
|
|
|
|
detail.SetRed_P2();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setP2value(List<CodeGoodInv> feecodelist)
|
|
|
|
|
{
|
|
|
|
|
if (feecodelist.Exists(o => o.GOODNAME == GOODSNAME))
|
|
|
|
|
{
|
|
|
|
|
var feecode = feecodelist.Find(o => o.GOODNAME == GOODSNAME);
|
|
|
|
|
GOODCODE = feecode.GOODCODE;
|
|
|
|
|
GOODSNAME = feecode.GID;
|
|
|
|
|
SPEC = feecode.SPEC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (TAXRATE == 0)
|
|
|
|
|
{
|
|
|
|
|
AMOUNT = TAXAMOUNT;
|
|
|
|
|
PRICE = TAXPRICE;
|
|
|
|
|
TAX = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (TAXRATE > 0)
|
|
|
|
|
{
|
|
|
|
|
TAX = (TAXAMOUNT / (1 + TAXRATE / 100)) * (TAXRATE / 100);
|
|
|
|
|
AMOUNT = TAXAMOUNT - TAX;
|
|
|
|
|
PRICE = AMOUNT / PKGS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|