You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.1 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using log4net;
using System.IO;
using System.Net;
using System.Text;
using DSWeb.Common.DB;
namespace DSWeb.Common.DB
{
public class ChFeeHelper
{
/// <summary>
/// 获取一个新的费用对象
/// </summary>
/// <param name="BSNO">BSNO</param>
/// <param name="CUSTOMERNAME">结算对象</param>
/// <param name="FEETYPE">收付方向</param>
/// <param name="FEENAME">费用名称</param>
/// <param name="AMOUNT">金额</param>
/// <param name="QUANTITY">数量</param>
/// <returns></returns>
public static ch_fee_md getChFee(string USERID, string BSNO, string CUSTOMERNAME, int FEETYPE, string FEENAME, decimal AMOUNT, string UNIT, decimal QUANTITY = 1, string SALE = "", string remark = "", string custtype = "")
{
var result = getNewChfee();
result.BSNO = BSNO;
result.CUSTOMERNAME = CUSTOMERNAME;
result.FEETYPE = FEETYPE;
result.AMOUNT = AMOUNT;
result.QUANTITY = QUANTITY;
result.CUSTOMERTYPE = custtype;
result.FEENAME = FEENAME;
result.ENTEROPERATOR = USERID;
result.ENTERDATE = DateTime.Now;
result.MODIFIEDUSER = USERID;
result.MODIFIEDTIME = DateTime.Now;
result.CURRENCY = "RMB";
result.LOCALCURR = "RMB";
result.EXCHANGERATE = 1M;
result.UNIT = UNIT;
result.MANAGER = SALE;
result.REMARK = remark;
CommonDataContext cdc = new CommonDataContext();
var codefeelist = cdc.code_fee.Where(x => 1 == 1).ToList();
result.setTax(codefeelist);
return result;
}
public static ch_fee_md getchfeeHelper()
{
var feeShou = new ch_fee_md();
//2021-12-31要求下列字段不能为空填写0或false
feeShou.COMMISSIONRATE = 0;
feeShou.AUDITSTATUS = 0;
feeShou.LINENUM = 0;
feeShou.ISDEBIT = false;
feeShou.ISOPEN = false;
feeShou.ACCTAXRATE = 0;
feeShou.ISVOU = false;
feeShou.TAX = 0;
feeShou.PREAMOUNT = 0;
feeShou.ISACC = false;
feeShou.CUSTDUI = false;
feeShou.SETTLEMENT = 0;
feeShou.ORDERAMOUNT = 0;
feeShou.ORDERINVOICE = 0;
feeShou.ORDERINVSETTLEMENT = 0;
feeShou.ORDERSETTLEMENT = 0;
feeShou.INVOICE = 0;
feeShou.TAXRATE = 0;
feeShou.ISADVANCEDPAY = false;
feeShou.ISINVOICE = false;
feeShou.ISCRMORDERFEE = false;
feeShou.TAXUNITPRICE = 0;//2021-12-29于菲同样赋值单价和金额
feeShou.NOTAXAMOUNT = 0;//2021-12-29于菲同样赋值单价和金额
feeShou.FEESTATUS = 1;
return feeShou;
}
public static ch_fee_md getNewChfee()
{
var result = getchfeeHelper();
result.GID = Guid.NewGuid().ToString();
result.WMSOUTBSNO = "";
return result;
}
public static void setTax(ref ch_fee_md ch_fee)
{
var taxrateb = 1 + ch_fee.TAXRATE / 100;
ch_fee.NOTAXAMOUNT = ch_fee.AMOUNT / taxrateb;
ch_fee.TAX = ch_fee.AMOUNT - ch_fee.NOTAXAMOUNT;
if (ch_fee.QUANTITY > 0)
{
//ch_fee.UNITPRICE = Math.Round((decimal)(ch_fee.NOTAXAMOUNT / ch_fee.QUANTITY),2);
//ch_fee.TAXUNITPRICE = Math.Round((decimal)(ch_fee.AMOUNT / ch_fee.QUANTITY),2);
ch_fee.UNITPRICE = ch_fee.NOTAXAMOUNT / ch_fee.QUANTITY;
ch_fee.TAXUNITPRICE = ch_fee.AMOUNT / ch_fee.QUANTITY;
}
else
{
ch_fee.UNITPRICE = ch_fee.NOTAXAMOUNT;
ch_fee.TAXUNITPRICE = ch_fee.AMOUNT;
}
if (ch_fee.ACCTAXRATE == null)
{
ch_fee.ACCTAXRATE = ch_fee.TAXRATE;
}
}
}
}