|
|
using System;
|
|
|
using System.Data;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using DSWeb.MvcShipping.Models.MsCwVouchersGlInvoiceHeXiaoEntity;
|
|
|
using DSWeb.MvcShipping.Models.MsCwAccitemsGl;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using HcUtility.Comm;
|
|
|
using System.Data.SqlClient;
|
|
|
using DSWeb.DataAccess;
|
|
|
using HcUtility.Core;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
|
using DSWeb.Areas.Account.Models.MsCwVouchersGl3;
|
|
|
using DSWeb.MvcShipping.Models.MsCwVouchersGl;
|
|
|
using DSWeb.MvcShipping.Models.MsCwVouitemsGl;
|
|
|
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlInvoiceHeXiaoDAL
|
|
|
{
|
|
|
public class MsCwVouchersGlInvoiceHeXiaoDAL
|
|
|
{
|
|
|
#region 按业务_查询、导出、打印
|
|
|
static public List<MsCwVouchersGlInvoiceHeXiaoEntity> GetDataList(string strCondition, string companyid, string strUSERID, string sort = null)
|
|
|
{
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUSERID);
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT BILLNO,BILLSTATUS,CUSTOMERNAME,INVNO,INVOICECUSTNAME,CURR,AMOUNT,REMARKS,INVDATE,TAXCODE,ADDRTEL,BANK,OP,OPDATE,INVAMOUNT,TAXRATE,TAX,BALBILLNO,ISAPP,VOUNO=(select top 1 VOUALLNO from cw_vouno_bs_gl WITH(NOLOCK) where BSGID=ch_fee_invoicehexiao.BILLNO and BSTABLENAME='ch_fee_invoicehexiao' and STARTGID='" + strCwSTARTGID + "') FROM ch_fee_invoicehexiao where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by OPDATE DESC");
|
|
|
}
|
|
|
return SetData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsCwVouchersGlInvoiceHeXiaoEntity> SetData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsCwVouchersGlInvoiceHeXiaoEntity>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsCwVouchersGlInvoiceHeXiaoEntity data = new MsCwVouchersGlInvoiceHeXiaoEntity();
|
|
|
#region Set DB data to Object
|
|
|
data.BILLNO = Convert.ToString(reader["BILLNO"]);
|
|
|
data.BILLSTATUS = Convert.ToString(reader["BILLSTATUS"]);
|
|
|
data.INVOICECUSTNAME = Convert.ToString(reader["INVOICECUSTNAME"]);
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
data.INVNO = Convert.ToString(reader["INVNO"]);
|
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
|
data.CURR = Convert.ToString(reader["CURR"]);
|
|
|
if (reader["AMOUNT"] != DBNull.Value)
|
|
|
data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]);
|
|
|
if (reader["INVAMOUNT"] != DBNull.Value)
|
|
|
data.INVAMOUNT = Convert.ToDecimal(reader["INVAMOUNT"]);
|
|
|
if (reader["TAXRATE"] != DBNull.Value)
|
|
|
data.TAXRATE = Convert.ToDecimal(reader["TAXRATE"]);
|
|
|
if (reader["TAX"] != DBNull.Value)
|
|
|
data.TAX = Convert.ToDecimal(reader["TAX"]);
|
|
|
data.OPDATE = Convert.ToString(reader["OPDATE"]);
|
|
|
data.INVDATE = Convert.ToString(reader["INVDATE"]);
|
|
|
data.TAXCODE = Convert.ToString(reader["TAXCODE"]);
|
|
|
data.ADDRTEL = Convert.ToString(reader["ADDRTEL"]);
|
|
|
data.BANK = Convert.ToString(reader["BANK"]);
|
|
|
data.REMARKS = Convert.ToString(reader["REMARKS"]);
|
|
|
data.BALBILLNO = Convert.ToString(reader["BALBILLNO"]);
|
|
|
if (reader["ISAPP"] != DBNull.Value)
|
|
|
data.ISAPP = Convert.ToBoolean(reader["ISAPP"]);
|
|
|
data.VOUNO = (reader["VOUNO"] == null ? "" : Convert.ToString(reader["VOUNO"]));
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
//查询、导出
|
|
|
static public string GetDataListSQL(string strCondition, string companyid, string strUSERID)
|
|
|
{
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUSERID);
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT BILLNO,BILLSTATUS,CUSTOMERNAME,INVNO,INVOICECUSTNAME,CURR,AMOUNT,REMARKS,INVDATE,TAXCODE,ADDRTEL,BANK,OP,OPDATE,INVAMOUNT,TAXRATE,TAX,BALBILLNO,ISAPP,VOUNO=(select top 1 VOUALLNO from cw_vouno_bs_gl WITH(NOLOCK) where BSGID=ch_fee_invoicehexiao.BILLNO and BSTABLENAME='ch_fee_invoicehexiao' and STARTGID='" + strCwSTARTGID + "') FROM ch_fee_invoicehexiao where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
return strSql.ToString();
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 生成结转凭证
|
|
|
#region 币别列表
|
|
|
static public List<MsCwVouchersGl4> GetCodeCurrencyList(string strBILLNOs, string companyid, string strUserID)
|
|
|
{
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(strUserID);
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select CURRENCY,(select top 1 BEGRATE from cw_currency_rate where ACCDATE='" + strCwACCDATE + "' and STARTGID='" + strCwSTARTGID + "' and LINKGID in (select GID from code_currency where CODENAME=VW_ch_fee_invoicehexiao.CURRENCY)) as FCYEXRATE from VW_ch_fee_invoicehexiao where CURRENCY<>'RMB'");
|
|
|
if (!string.IsNullOrEmpty(strBILLNOs))
|
|
|
{
|
|
|
strSql.Append(strBILLNOs);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" and 1<0");
|
|
|
}
|
|
|
strSql.Append(" group by CURRENCY order by CURRENCY");
|
|
|
return SetCodeCurrencyData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsCwVouchersGl4> SetCodeCurrencyData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsCwVouchersGl4>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsCwVouchersGl4 data = new MsCwVouchersGl4();
|
|
|
#region Set DB data to Object
|
|
|
data.CURR = (reader["CURRENCY"] == null ? "" : Convert.ToString(reader["CURRENCY"]));
|
|
|
data.FCYEXRATE = (reader["FCYEXRATE"] == null ? "" : Convert.ToString(reader["FCYEXRATE"]));
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 按费用_判断是否生成
|
|
|
public static DBResult onIsCwVouchers(string strBILLNOs, string strUserID)
|
|
|
{
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
var result = new DBResult();
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
|
strBILLNOs = "'" + strBILLNOs.Trim().Replace(",", "','") + "'";
|
|
|
string sSQL = "SELECT count(*) as iNum From VW_ch_fee_invoicehexiao WHERE 1=1 and BILLNO in (select [BSGID] from [cw_vouno_bs_gl] WITH(NOLOCK) where BSTABLENAME='ch_fee_invoicehexiao' and STARTGID='" + strCwSTARTGID + "') and BILLNO in (" + strBILLNOs.Trim() + ")";
|
|
|
int iNum = int.Parse(T_ALL_DA.GetStrSQL("iNum", sSQL));
|
|
|
result.Success = true;
|
|
|
result.Message = "";
|
|
|
if (iNum > 0)
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "有已经生成凭证的数据,不允许重复生成,请重新选择!";
|
|
|
return result;
|
|
|
}
|
|
|
result.Success = true;
|
|
|
result.Message = "";
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
public static DBResult onAddCwVouchers(string strBILLNOs, MsCwVouchersGl3 headData, List<MsCwVouchersGl4> bodyList, string strUserID, string strSHOWNAME, string companyid)
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
var result = new DBResult();
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
string sSQL = "";
|
|
|
int iResult = 0;
|
|
|
string zt = "";
|
|
|
string sError = "操作完成!";
|
|
|
string sAndGids = " and BILLNO in ('" + strBILLNOs.Trim().Replace(",", "','") + "')";
|
|
|
|
|
|
#region 生成前的判断
|
|
|
//帐套设置
|
|
|
sSQL = "SELECT top 1 * from cw_design_gl where [STARTGID]='" + strCwSTARTGID + "' and AP<>'' and APFC<>'' and MBSPENDING<>'' and TMSFC<>'' and INPUTTAX<>''";// where CORPID='"+companyid+"'
|
|
|
DataSet dsCwDesign = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (dsCwDesign == null)
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "请先设置帐套信息!" + result.Message;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//帐套设置_核算科目
|
|
|
sSQL = "SELECT [GID],[LINKGID],[ITEMGID],[OPTYPE],[MODIFIEDUSER],[MODIFIEDTIME],[MODIFIEDUSERNAME]=(select top 1 SHOWNAME from [user] where gid=[cw_design_gl_item].MODIFIEDUSER),[ITEMCODE]=(SELECT top 1 ITEMCODE from cw_item where GID=[cw_design_gl_item].[ITEMGID]),[ITEMNAME]=(SELECT top 1 ITEMNAME from cw_item where GID=[cw_design_gl_item].[ITEMGID]) FROM [cw_design_gl_item] WITH(NOLOCK) where LINKGID in (SELECT top 1 GID from cw_design_gl WITH(NOLOCK) where [STARTGID]='" + strCwSTARTGID + "') ORDER BY [ITEMCODE]";
|
|
|
DataSet dsCwDesignItem = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
|
|
|
//判断总账科目是否完全配置好
|
|
|
//科目设置 应付USD
|
|
|
sSQL = "SELECT count(CURRENCY) as inum From VW_ch_fee_invoicehexiao WHERE 1=1 and BILLNO not in (select [BSGID] from [cw_vouno_bs_gl] WITH(NOLOCK) where BSTABLENAME='ch_fee_invoicehexiao' and STARTGID='" + strCwSTARTGID + "')" + sAndGids + " and CURRENCY<>'RMB' and CURRENCY not in (SELECT CURRENCY from cw_accitems_currency where LINKGID in (SELECT GID from cw_accitems_gl where [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim() + "')) GROUP BY CURRENCY ORDER BY CURRENCY";
|
|
|
string sNum = T_ALL_DA.GetStrSQL("inum", sSQL);
|
|
|
if (sNum != "" && sNum != "0")
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "请先设置应付账款外币科目(" + dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim() + ")的币别信息!" + result.Message;
|
|
|
return result;
|
|
|
}
|
|
|
//判断是否有核算项目的科目
|
|
|
if (dsCwDesignItem == null)
|
|
|
{
|
|
|
sSQL = "SELECT COUNT(*) as inum from cw_accitems_gl where [STARTGID]='" + strCwSTARTGID + "' and ISITEMACC=1 and ACCID in ('" + dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() + "','" + dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim() + "','" + dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() + "','" + dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim() + "','" + dsCwDesign.Tables[0].Rows[0]["INPUTTAX"].ToString().Trim() + "')";
|
|
|
sNum = T_ALL_DA.GetStrSQL("inum", sSQL);
|
|
|
if (sNum != "" && sNum != "0")
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "请先设置帐套信息中的核算项目匹配设置!" + result.Message;
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//合并生成发票开出凭证凭证
|
|
|
string[] itemsBILLNO = strBILLNOs.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCTGCIC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
#region 合并生成发票开出凭证凭证
|
|
|
#region 提前生成凭证号
|
|
|
string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(strUserID);
|
|
|
string sACCDATE = headData.VOUDATE.Substring(0, 7);
|
|
|
if (DateTime.Parse(sACCDATE + "-01") < DateTime.Parse(strCwACCDATE + "-01"))
|
|
|
{
|
|
|
sACCDATE = strCwACCDATE;
|
|
|
}
|
|
|
string strBPVW = dsCwDesign.Tables[0].Rows[0]["TVW"].ToString().Trim();
|
|
|
string strVOUNOhj = DSWeb.MvcShipping.DAL.MsBaseInfoDAL.MsBaseInfoDAL.GetCwVOUNO(strBPVW, sACCDATE, strUserID);
|
|
|
string[] items = strVOUNOhj.Trim().Split(new string[] { "~" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
string strVOUNO = items[3].ToString().Trim();
|
|
|
string sACCMONTH = DateTime.Parse(headData.VOUDATE.ToString()).Month.ToString();//月
|
|
|
if (sACCMONTH.ToString().Length == 1)
|
|
|
{
|
|
|
sACCMONTH = "0" + sACCMONTH.ToString();//月
|
|
|
}
|
|
|
string cfVOUALLNO = strBPVW + DateTime.Parse(headData.VOUDATE.ToString()).Year.ToString() + sACCMONTH + strVOUNO;//年+月+自动生成编号=凭证号
|
|
|
#endregion
|
|
|
|
|
|
DBResult result2 = onIsCwVouchers(strBILLNOs, strUserID);//判断是否有已经生成凭证的数据
|
|
|
if (!result2.Success)
|
|
|
{
|
|
|
sError = result.Message;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//把凭证号更新到ch_fee_invoicehexiao
|
|
|
//string blSQL = "update ch_fee_invoicehexiao set VOUNO='" + cfVOUALLNO + "' where 1=1 and BILLNO not in (select [BSGID] from [cw_vouno_bs_gl] WITH(NOLOCK) where BSTABLENAME='ch_fee_invoicehexiao' and STARTGID='" + strCwSTARTGID + "')" + sAndGids + " and '" + cfVOUALLNO + "' NOT in (select VOUNO from ch_fee_invoicehexiao where VOUNO<>'' and VOUNO is not NULL)";
|
|
|
//把凭证号和业务GID插入到凭证生成的关系表
|
|
|
string blSQL = "INSERT INTO [cw_vouno_bs_gl]([GID],[BSTABLENAME],[BSGID],[VOUALLNO],[ORDNO],[STARTGID],[CREATEUSER],[CREATETIME])"
|
|
|
+ "select newid() as [GID],'ch_fee_invoicehexiao' as [BSTABLENAME],BILLNO as [BSGID],'" + cfVOUALLNO + "' as [VOUALLNO],'' as [ORDNO],'" + strCwSTARTGID + "' as [STARTGID],'" + strUserID + "' as [CREATEUSER],getdate() as [CREATETIME]"
|
|
|
+ " from ch_fee_invoicehexiao where 1=1" + sAndGids + " and BILLNO not in (select BSGID from cw_vouno_bs_gl WITH(NOLOCK) where BSTABLENAME='ch_fee_invoicehexiao' and [STARTGID]='" + strCwSTARTGID + "')";
|
|
|
int iCount = db.ExecuteNonQuery(CommandType.Text, blSQL);
|
|
|
//
|
|
|
if (iCount != 0)
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISINVRATESELF"].ToString().Trim() == "True")
|
|
|
iResult = getSCInv(dsCwDesign, dsCwDesignItem, sAndGids.Trim(), headData, bodyList, strUserID, companyid, cfVOUALLNO);
|
|
|
else
|
|
|
iResult = getSC(dsCwDesign, dsCwDesignItem, sAndGids.Trim(), headData, bodyList, strUserID, companyid, cfVOUALLNO);
|
|
|
zt += "," + iResult;
|
|
|
if (zt.IndexOf("-") > 0)
|
|
|
{
|
|
|
sError = "共" + itemsBILLNO.Length + "票发票单,生成0条凭证,失败1条凭证!";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sError = "共" + itemsBILLNO.Length + "票发票单,生成1条凭证,失败0条凭证!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sError = "共" + itemsBILLNO.Length + "票发票单,生成1条凭证,失败0条凭证!";
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 不 合并生成发票开出凭证凭证
|
|
|
int n = 0;
|
|
|
if (itemsBILLNO.Length > 0)
|
|
|
{
|
|
|
for (int k = 0; k < itemsBILLNO.Length; k++)
|
|
|
{
|
|
|
//按业务
|
|
|
sAndGids = " and BILLNO in ('" + itemsBILLNO[k].ToString().Trim() + "')";
|
|
|
|
|
|
#region 提前生成凭证号
|
|
|
string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(strUserID);
|
|
|
string sACCDATE = headData.VOUDATE.Substring(0, 7);
|
|
|
if (DateTime.Parse(sACCDATE + "-01") < DateTime.Parse(strCwACCDATE + "-01"))
|
|
|
{
|
|
|
sACCDATE = strCwACCDATE;
|
|
|
}
|
|
|
string strBPVW = dsCwDesign.Tables[0].Rows[0]["TVW"].ToString().Trim();
|
|
|
string strVOUNOhj = DSWeb.MvcShipping.DAL.MsBaseInfoDAL.MsBaseInfoDAL.GetCwVOUNO(strBPVW, sACCDATE, strUserID);
|
|
|
string[] items2 = strVOUNOhj.Trim().Split(new string[] { "~" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
string strVOUNO = items2[3].ToString().Trim();
|
|
|
string sACCMONTH = DateTime.Parse(headData.VOUDATE.ToString()).Month.ToString();//月
|
|
|
if (sACCMONTH.ToString().Length == 1)
|
|
|
{
|
|
|
sACCMONTH = "0" + sACCMONTH.ToString();//月
|
|
|
}
|
|
|
string cfVOUALLNO = strBPVW + DateTime.Parse(headData.VOUDATE.ToString()).Year.ToString() + sACCMONTH + strVOUNO;//年+月+自动生成编号=凭证号
|
|
|
#endregion
|
|
|
|
|
|
//把凭证号更新到ch_fee_invoicehexiao
|
|
|
//string blSQL = "update ch_fee_invoicehexiao set VOUNO='" + cfVOUALLNO + "' where 1=1 and BILLNO not in (select [BSGID] from [cw_vouno_bs_gl] WITH(NOLOCK) where BSTABLENAME='ch_fee_invoicehexiao' and STARTGID='" + strCwSTARTGID + "')" + sAndGids + " and '" + cfVOUALLNO + "' NOT in (select VOUNO from ch_fee_invoicehexiao where VOUNO<>'' and VOUNO is not NULL)";
|
|
|
//把凭证号和业务GID插入到凭证生成的关系表
|
|
|
string blSQL = "INSERT INTO [cw_vouno_bs_gl]([GID],[BSTABLENAME],[BSGID],[VOUALLNO],[ORDNO],[STARTGID],[CREATEUSER],[CREATETIME])"
|
|
|
+ "select newid() as [GID],'ch_fee_invoicehexiao' as [BSTABLENAME],BILLNO as [BSGID],'" + cfVOUALLNO + "' as [VOUALLNO],'' as [ORDNO],'" + strCwSTARTGID + "' as [STARTGID],'" + strUserID + "' as [CREATEUSER],getdate() as [CREATETIME]"
|
|
|
+ " from ch_fee_invoicehexiao where 1=1" + sAndGids + " and BILLNO not in (select BSGID from cw_vouno_bs_gl WITH(NOLOCK) where BSTABLENAME='ch_fee_invoicehexiao' and [STARTGID]='" + strCwSTARTGID + "')";
|
|
|
int iCount = db.ExecuteNonQuery(CommandType.Text, blSQL);
|
|
|
//
|
|
|
if (iCount != 0)
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISINVRATESELF"].ToString().Trim() == "True")
|
|
|
iResult = getSCInv(dsCwDesign, dsCwDesignItem, sAndGids.Trim(), headData, bodyList, strUserID, companyid, cfVOUALLNO);
|
|
|
else
|
|
|
iResult = getSC(dsCwDesign, dsCwDesignItem, sAndGids, headData, bodyList, strUserID, companyid, cfVOUALLNO);
|
|
|
zt += "," + iResult;
|
|
|
if (zt.IndexOf("-") < 0)
|
|
|
{
|
|
|
n++;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sError = "有已经生成凭证的数据,不允许重复生成,请重新选择!";
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
sError = "共" + itemsBILLNO.Length + "票发票单,生成" + n + "条凭证,失败" + (itemsBILLNO.Length - n) + "条凭证!";
|
|
|
#endregion
|
|
|
}
|
|
|
//
|
|
|
//if (zt.IndexOf("-") > 0)
|
|
|
//{
|
|
|
// result.Success = false;
|
|
|
// result.Message = "操作出错" + result.Message;//部分凭证生成
|
|
|
// return result;
|
|
|
//}
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = sError;//"操作完成!";
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 生成凭证
|
|
|
/// </summary>
|
|
|
/// <param name="ds">帐套设置数据集</param>
|
|
|
/// <param name="sGids">gid业务编号</param>
|
|
|
/// <returns></returns>
|
|
|
protected static int getSC(DataSet dsCwDesign, DataSet dsCwDesignItem, string sAndGids, MsCwVouchersGl3 headData, List<MsCwVouchersGl4> bodyList, string strUserID, string strCompanyID, string cfVOUALLNO)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
#region 基本变量
|
|
|
//全部
|
|
|
string sSQL = "";
|
|
|
string strEXPLAN = "";
|
|
|
string strFCY = "RMB";
|
|
|
Decimal dEXCHANGERATE = 0;
|
|
|
//应付应付账款
|
|
|
Decimal iAMTDR = 0;
|
|
|
Decimal iAMTCR = 0;
|
|
|
//差额主营业务成本
|
|
|
Decimal dRMBS = 0;
|
|
|
Decimal dRMBF = 0;
|
|
|
Decimal dUSDS = 0;
|
|
|
Decimal dUSDF = 0;
|
|
|
//总合计
|
|
|
//Decimal strJie = 0;
|
|
|
//Decimal strDai = 0;
|
|
|
string strBPVW = dsCwDesign.Tables[0].Rows[0]["TVW"].ToString().Trim();
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(strUserID);
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置
|
|
|
//科目设置 应付RMB
|
|
|
sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() + "'";
|
|
|
DataSet dsAP = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
//科目设置 应付USD
|
|
|
sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim() + "'";
|
|
|
DataSet dsAPFC = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
|
|
|
//主营业务成本 成本RMB
|
|
|
sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() + "'";
|
|
|
DataSet dsMBSPENDING = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
//主营成本外币 成本USD
|
|
|
sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim() + "'";
|
|
|
DataSet dsTMSFC = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
|
|
|
//进项税
|
|
|
sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["INPUTTAX"].ToString().Trim() + "'";
|
|
|
DataSet dsINPUTTAX = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
#endregion
|
|
|
|
|
|
#region 摘要
|
|
|
string strISEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLAN += ",CUSTOMERNAME";//是否收付客户名称CUSTOMERNAME
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLAN += ",INVOICENO";//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLAN += ",MBLNO";//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLAN += ",VESSEL";//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLAN += ",VOYNO";//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLAN += ",BSSOURCE";//是否业务来源
|
|
|
//}
|
|
|
|
|
|
string strISEXPLANnull = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLANnull += ",CUSTOMERNAME";//是否收付客户名称CUSTOMERNAME
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLANnull += ",INVOICENO";//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLANnull += ",MBLNO";//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLANnull += ",VESSEL";//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLANnull += ",VOYNO";//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLANnull += ",BSSOURCE";//是否业务来源
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBILLNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLANnull += ",BILLNO_ACAD";//是否申请单号
|
|
|
//}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 票号
|
|
|
if (strISEXPLAN.IndexOf(dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim()) < 0)
|
|
|
{
|
|
|
strISEXPLAN += "," + dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf(dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim()) < 0)
|
|
|
{
|
|
|
strISEXPLANnull += "," + dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 核算科目_分录
|
|
|
//string sqlItemAP = "";
|
|
|
//string sqlItemAPFC = "";
|
|
|
//string sqlItemMBSPENDING = "";
|
|
|
//string sqlItemTMSFC = "";
|
|
|
#endregion
|
|
|
|
|
|
#region 基本数据集
|
|
|
string strORDNO = getGid();
|
|
|
string sqlAP = "";
|
|
|
string sqlAPFC = "";
|
|
|
string sqlMBSPENDING = "";
|
|
|
string sqlTMSFC = "";
|
|
|
string sqlINPUTTAX = "";
|
|
|
string sqlINPUTTAXUSD = "";
|
|
|
IList<MsCwVouitemsGl> CwVouitemsEntities = new List<MsCwVouitemsGl>();
|
|
|
string strCondition = sAndGids + " and BILLNO in (select [BSGID] from [cw_vouno_bs_gl] WITH(NOLOCK) where BSTABLENAME='ch_fee_invoicehexiao' and VOUALLNO='" + cfVOUALLNO + "' and STARTGID='" + strCwSTARTGID + "')";
|
|
|
|
|
|
//是否按照系统录入汇率
|
|
|
if (headData.ISRATE == true)
|
|
|
{
|
|
|
#region 科目设置:应付RMB dsAP、应付USD dsAPFC
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim())
|
|
|
{
|
|
|
#region 应付RMB==应付USD
|
|
|
#region 摘要内容
|
|
|
string sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsAP.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlAP = "SELECT EXCHANGERATE,CURRENCY,AMOUNT AS je,Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlAP += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
//
|
|
|
sqlAPFC = "SELECT EXCHANGERATE,CURRENCY,AMOUNT AS je,Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAPFC += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlAPFC += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlAP = "SELECT AMOUNT AS je,Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + "";
|
|
|
sqlAP += " ORDER BY VOUNO" + strISEXPLAN + sISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 应付RMB!=应付USD
|
|
|
//应付RMB
|
|
|
#region 摘要内容
|
|
|
string sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlAP = "SELECT AMOUNT AS je,Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlAP += " ORDER BY VOUNO" + strISEXPLAN + sISEXPLAN;
|
|
|
|
|
|
//应付USD
|
|
|
#region 摘要内容
|
|
|
sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlAPFC = "SELECT EXCHANGERATE,CURRENCY,AMOUNT AS je,Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAPFC += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlAPFC += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
#endregion
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置:主营业务成本RMB dsMBSPENDING、主营成本外币USD dsTMSFC
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim())
|
|
|
{
|
|
|
#region 主营业务成本RMB==主营成本外币USD
|
|
|
string sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlMBSPENDING = "SELECT EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(AMOUNT)-SUM(TAX)) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlMBSPENDING += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
//
|
|
|
sqlTMSFC = "SELECT EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)))-SUM(Convert(decimal(18,2),(TAX*EXCHANGERATE)))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlTMSFC += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlMBSPENDING = "SELECT (SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)))-SUM(Convert(decimal(18,2),(TAX*EXCHANGERATE)))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + "";
|
|
|
sqlMBSPENDING += " group BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 主营业务成本RMB!=主营成本外币USD
|
|
|
//主营业务成本RMB
|
|
|
string sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlMBSPENDING = "SELECT (SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(AMOUNT)-SUM(TAX)) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlMBSPENDING += " group BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
|
|
|
//主营成本外币USD
|
|
|
sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlTMSFC = "SELECT EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)))-SUM(Convert(decimal(18,2),(TAX*EXCHANGERATE)))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlTMSFC += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
#endregion
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置:进项税 dsINPUTTAX
|
|
|
#region 核算项目
|
|
|
string ssISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
ssISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
ssISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlINPUTTAX = "SELECT EXCHANGERATE,CURRENCY,SUM(TAX) AS je,SUM(TAX*EXCHANGERATE) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " From VW_ch_fee_invoicehexiao WHERE 1=1 and TAX<>0" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlINPUTTAX += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " ORDER BY CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
//
|
|
|
sqlINPUTTAXUSD = "SELECT EXCHANGERATE,CURRENCY,SUM(TAX) AS je,SUM(Convert(decimal(18,2),(TAX*EXCHANGERATE))) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAXUSD += " From VW_ch_fee_invoicehexiao WHERE 1=1 and TAX<>0" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlINPUTTAXUSD += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAXUSD += " ORDER BY CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlINPUTTAX = "SELECT SUM(TAX) AS je,SUM(Convert(decimal(18,2),(TAX*EXCHANGERATE))) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " From VW_ch_fee_invoicehexiao WHERE 1=1 and TAX<>0" + strCondition;
|
|
|
sqlINPUTTAX += " group BY VOUNO" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " ORDER BY VOUNO" + strISEXPLANnull + ssISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 提取费率
|
|
|
string tbRATE = "";
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
if (bodyList.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < bodyList.Count; i++)
|
|
|
{
|
|
|
tbRATE += " WHEN CURRENCY='" + bodyList[i].CURR.ToString().Trim() + "' THEN " + bodyList[i].FCYEXRATE.ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置:应付RMB dsAP、应付USD dsAPFC
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim())
|
|
|
{
|
|
|
#region 应付RMB==应付USD
|
|
|
#region 摘要
|
|
|
string sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsAP.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlAP = "SELECT EXCHANGERATE,CURRENCY,AMOUNT AS je,Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlAP += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
//
|
|
|
sqlAPFC = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,AMOUNT AS je,Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAPFC += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlAPFC += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlAP = "SELECT AMOUNT AS je,Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + "";
|
|
|
sqlAP += " ORDER BY VOUNO" + strISEXPLAN + sISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 应付RMB!=应付USD
|
|
|
//应付RMB
|
|
|
#region 摘要
|
|
|
string sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlAP = "SELECT AMOUNT AS je,Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlAP += " ORDER BY VOUNO" + strISEXPLAN + sISEXPLAN;
|
|
|
|
|
|
//应付USD
|
|
|
#region 摘要
|
|
|
sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlAPFC = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,AMOUNT AS je,Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAPFC += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlAPFC += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
#endregion
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置:主营业务成本RMB dsMBSPENDING、主营成本外币USD dsTMSFC
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim())
|
|
|
{
|
|
|
#region 主营业务成本RMB==主营成本外币USD
|
|
|
string sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlMBSPENDING = "SELECT EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(AMOUNT)-SUM(TAX)) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlMBSPENDING += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
//
|
|
|
sqlTMSFC = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))-SUM(Convert(decimal(18,2),(TAX*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlTMSFC += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlMBSPENDING = "SELECT (SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))-SUM(Convert(decimal(18,2),(TAX*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + "";
|
|
|
sqlMBSPENDING += " group BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 主营业务成本RMB!=主营成本外币USD
|
|
|
//主营业务成本RMB
|
|
|
string sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlMBSPENDING = "SELECT (SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(AMOUNT)-SUM(TAX)) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlMBSPENDING += " group BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
|
|
|
//主营成本外币USD
|
|
|
sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlTMSFC = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))-SUM(Convert(decimal(18,2),(TAX*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " From VW_ch_fee_invoicehexiao WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlTMSFC += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
#endregion
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置:进项税 dsINPUTTAX
|
|
|
#region 核算项目
|
|
|
string ssISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
ssISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
ssISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlINPUTTAX = "SELECT EXCHANGERATE,CURRENCY,SUM(TAX) AS je,SUM(TAX) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " From VW_ch_fee_invoicehexiao WHERE 1=1 and TAX<>0" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlINPUTTAX += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " ORDER BY CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
//
|
|
|
sqlINPUTTAXUSD = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(TAX) AS je,SUM(Convert(decimal(18,2),(TAX*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAXUSD += " From VW_ch_fee_invoicehexiao WHERE 1=1 and TAX<>0" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlINPUTTAXUSD += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAXUSD += " ORDER BY CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlINPUTTAX = "SELECT SUM(TAX) AS je,SUM(Convert(decimal(18,2),(TAX*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " From VW_ch_fee_invoicehexiao WHERE 1=1 and TAX<>0" + strCondition + "";
|
|
|
sqlINPUTTAX += " group BY VOUNO" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " ORDER BY VOUNO" + strISEXPLANnull + ssISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
DataSet dsVWChFeeInvoiceAP = T_ALL_DA.GetAllSQL(sqlAP);
|
|
|
DataSet dsVWChFeeInvoiceAPFC = null;
|
|
|
if (sqlAPFC.Trim() != "")
|
|
|
{
|
|
|
dsVWChFeeInvoiceAPFC = T_ALL_DA.GetAllSQL(sqlAPFC);
|
|
|
}
|
|
|
DataSet dsVWChFeeInvoiceMBSPENDING = T_ALL_DA.GetAllSQL(sqlMBSPENDING);
|
|
|
DataSet dsVWChFeeInvoiceTMSFC = null;
|
|
|
if (sqlTMSFC.Trim() != "")
|
|
|
{
|
|
|
dsVWChFeeInvoiceTMSFC = T_ALL_DA.GetAllSQL(sqlTMSFC);
|
|
|
}
|
|
|
DataSet dsVWChFeeInvoiceINPUTTAX = T_ALL_DA.GetAllSQL(sqlINPUTTAX);
|
|
|
DataSet dsVWChFeeInvoiceINPUTTAXUSD = null;
|
|
|
if (sqlINPUTTAXUSD.Trim() != "")
|
|
|
{
|
|
|
dsVWChFeeInvoiceINPUTTAXUSD = T_ALL_DA.GetAllSQL(sqlINPUTTAXUSD);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
if (dsVWChFeeInvoiceAP != null || dsVWChFeeInvoiceAPFC != null)
|
|
|
{
|
|
|
#region 明细表_实体类
|
|
|
#region 插入明细表:应付RMB dsAP
|
|
|
if (dsVWChFeeInvoiceAP != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceAP.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否收付船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
#endregion
|
|
|
|
|
|
#region 插入明细表 应付账款
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;// 行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
#region 应付账款
|
|
|
iAMTCR = iAMTCR + Decimal.Parse(dsVWChFeeInvoiceAP.Tables[0].Rows[i]["hj"].ToString().Trim());
|
|
|
//
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim();//应付账款科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVWChFeeInvoiceAP.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥)
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd
|
|
|
MsCwVouitemsGl.FCYDR = 0;//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
dRMBF += Decimal.Parse(dsVWChFeeInvoiceAP.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
//
|
|
|
MsCwVouitemsGl.ACCNAME = dsAP.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsAP.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
//是否核算客户
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统)
|
|
|
if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceAP.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceAP.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceAP.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAP.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要
|
|
|
MsCwVouitemsGl.FCYEXRATE = 1;//汇率
|
|
|
dEXCHANGERATE = 1;//汇率
|
|
|
MsCwVouitemsGl.BLNO = "";
|
|
|
string strBLNONAME = dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim();
|
|
|
if (strBLNONAME.Trim() != "")
|
|
|
{
|
|
|
MsCwVouitemsGl.BLNO = dsVWChFeeInvoiceAP.Tables[0].Rows[i][strBLNONAME].ToString().Trim();
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// MsCwVouitemsGl.BLNO = dsVWChFeeInvoiceAP.Tables[0].Rows[i]["MBLNO"].ToString().Trim();
|
|
|
//}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
#endregion
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 插入明细表:应付外币 dsAPFC
|
|
|
if (dsVWChFeeInvoiceAPFC != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceAPFC.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否收付船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否收付航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
#endregion
|
|
|
|
|
|
#region 插入明细表 应付账款
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;// 行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
#region 应付账款
|
|
|
iAMTCR = iAMTCR + Decimal.Parse(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());
|
|
|
//
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim();//应付账款科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥)
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币
|
|
|
strFCY = MsCwVouitemsGl.FCYNO;
|
|
|
MsCwVouitemsGl.FCYDR = 0;//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = Decimal.Parse(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额
|
|
|
dRMBF += Decimal.Parse(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
//
|
|
|
MsCwVouitemsGl.ACCNAME = dsAPFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsAPFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
//是否核算客户
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统)
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceAPFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAPFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要
|
|
|
MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
|
|
|
dEXCHANGERATE = MsCwVouitemsGl.FCYEXRATE;//汇率
|
|
|
MsCwVouitemsGl.BLNO = "";
|
|
|
string strBLNONAME = dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim();
|
|
|
if (strBLNONAME.Trim() != "")
|
|
|
{
|
|
|
MsCwVouitemsGl.BLNO = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i][strBLNONAME].ToString().Trim();
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// MsCwVouitemsGl.BLNO = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();
|
|
|
//}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
#endregion
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 插入明细表:主营业务成本
|
|
|
Decimal dRMB = dRMBS - dRMBF;
|
|
|
Decimal dUSD = dUSDS - dUSDF;
|
|
|
//成本\成本 生成 全额\差额
|
|
|
Decimal strJie = dRMBS + dUSDS * dEXCHANGERATE;
|
|
|
Decimal strDai = dRMBF + dUSDF * dEXCHANGERATE;
|
|
|
//
|
|
|
#region 全额
|
|
|
if (dsVWChFeeInvoiceMBSPENDING != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 成本
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;//行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim();//主营业务成本科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥)
|
|
|
strJie = strJie + MsCwVouitemsGl.AMTDR;
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = "RMB";//外币
|
|
|
MsCwVouitemsGl.FCYDR = 0;//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
MsCwVouitemsGl.ACCNAME = dsMBSPENDING.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsMBSPENDING.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.FCYEXRATE = 1;//汇率
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
|
|
|
MsCwVouitemsGl.BLNO = "";//
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (dsVWChFeeInvoiceTMSFC != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceTMSFC.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 成本_外币
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;//行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim();//主营业务成本科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥)
|
|
|
strJie = strJie + MsCwVouitemsGl.AMTDR;
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISFCY = true;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币
|
|
|
strFCY = MsCwVouitemsGl.FCYNO;
|
|
|
MsCwVouitemsGl.FCYDR = Decimal.Parse(dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = "RMB";//外币
|
|
|
MsCwVouitemsGl.FCYDR = 0;//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
MsCwVouitemsGl.FCYEXRATE = 1;//汇率
|
|
|
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCNAME = dsTMSFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceTMSFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsTMSFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
|
|
|
MsCwVouitemsGl.BLNO = "";//
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
#region 插入明细表:进项税
|
|
|
if (dsVWChFeeInvoiceINPUTTAX != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 成本
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;//行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["INPUTTAX"].ToString().Trim();//主营业务成本科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥)
|
|
|
strJie = strJie + MsCwVouitemsGl.AMTDR;
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = "RMB";//外币
|
|
|
MsCwVouitemsGl.FCYDR = 0;//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
MsCwVouitemsGl.ACCNAME = dsINPUTTAX.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsINPUTTAX.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.FCYEXRATE = 1;//汇率
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
|
|
|
MsCwVouitemsGl.BLNO = "";//
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (dsVWChFeeInvoiceINPUTTAXUSD != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 成本_外币
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;//行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["INPUTTAX"].ToString().Trim();//主营业务成本科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥)
|
|
|
strJie = strJie + MsCwVouitemsGl.AMTDR;
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币
|
|
|
strFCY = MsCwVouitemsGl.FCYNO;
|
|
|
MsCwVouitemsGl.FCYDR = Decimal.Parse(dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
MsCwVouitemsGl.ACCNAME = dsINPUTTAX.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsINPUTTAX.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
|
|
|
MsCwVouitemsGl.BLNO = "";//
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
#region 插入主表
|
|
|
MsCwVouchersGl MsCwVouchersGl = new MsCwVouchersGl();
|
|
|
MsCwVouchersGl.ORDNO = strORDNO.Trim();//唯一编码 newid() varchar (36)
|
|
|
MsCwVouchersGl.VOUDATE = headData.VOUDATE;//凭证日期
|
|
|
|
|
|
//strY + "~" + strM + "~" + sVOUNO + "~" + strVOUNO + "~" + strVOUDATE + "~" + strACCDATE;
|
|
|
//string sACCDATE = headData.VOUDATE.Substring(0, 7);
|
|
|
//if (DateTime.Parse(sACCDATE + "-01") < DateTime.Parse(strACCDATE + "-01"))
|
|
|
//{
|
|
|
// sACCDATE = strACCDATE;
|
|
|
//}
|
|
|
//string strVOUNOhj = DSWeb.MvcShipping.DAL.MsBaseInfoDAL.MsBaseInfoDAL.GetCwVOUNO(strBPVW.Trim(), sACCDATE);
|
|
|
//string[] items = strVOUNOhj.Trim().Split(new string[] { "~" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
//string sVOUNO = items[2].ToString().Trim();
|
|
|
//string strVOUNO = items[3].ToString().Trim();
|
|
|
MsCwVouchersGl.VOUNO = int.Parse(cfVOUALLNO.Substring(cfVOUALLNO.Length-4)).ToString();//sVOUNO;//月初清零 varchar (16)
|
|
|
|
|
|
MsCwVouchersGl.ACCYEAR = DateTime.Parse(headData.VOUDATE.ToString()).Year.ToString();//年
|
|
|
MsCwVouchersGl.ACCMONTH = DateTime.Parse(headData.VOUDATE.ToString()).Month.ToString();//月
|
|
|
if (MsCwVouchersGl.ACCMONTH.ToString().Length == 1)
|
|
|
{
|
|
|
MsCwVouchersGl.ACCMONTH = "0" + MsCwVouchersGl.ACCMONTH.ToString();//月
|
|
|
}
|
|
|
MsCwVouchersGl.VKNO = strBPVW.Trim();//凭证字
|
|
|
//MsCwVouchersGl.VOUALLNO = MsCwVouchersGl.VKNO + MsCwVouchersGl.ACCYEAR + MsCwVouchersGl.ACCMONTH + strVOUNO;//年+月+自动生成编号=凭证号
|
|
|
MsCwVouchersGl.VOUALLNO = cfVOUALLNO.Replace("记", strBPVW.Trim());//年+月+自动生成编号=凭证号
|
|
|
MsCwVouchersGl.ATTACHS = 1;// int.Parse(dsCwDesign.Tables[0].Rows[0]["AFFIXNO"].ToString().Trim());//附件(单据)数
|
|
|
MsCwVouchersGl.AMTDR = strJie;// iAMTDR;//本位币借方
|
|
|
MsCwVouchersGl.AMTCR = strDai;//iAMTDR;// iAMTCR;//本位币贷方
|
|
|
MsCwVouchersGl.FCY = strFCY;//是否含有外币科目
|
|
|
MsCwVouchersGl.QTY = "";//是否含有数量科目
|
|
|
MsCwVouchersGl.VOUPROP = "";//凭证属性
|
|
|
MsCwVouchersGl.PREPARED = headData.PREPARED.ToString().Trim();//制单人
|
|
|
MsCwVouchersGl.CHECKED = "";//审核人
|
|
|
MsCwVouchersGl.ENTERED = "";//记账人
|
|
|
MsCwVouchersGl.ERRMSG = "";//错误信息
|
|
|
MsCwVouchersGl.ISDELETE = false;//是否废除
|
|
|
MsCwVouchersGl.DELETEUSER = "";//废除操作人
|
|
|
MsCwVouchersGl.STARTGID = strCwSTARTGID;
|
|
|
MsCwVouchersGl.DbOperationType = DbOperationType.DbotIns;
|
|
|
MsCwVouchersGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouchersGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouchersGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouchersGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
MsCwVouchersGl.ISAUTO = true;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 生成入库
|
|
|
var modb = new ModelObjectDB();
|
|
|
result = modb.Save(MsCwVouchersGl);
|
|
|
if (result.Success == true)
|
|
|
{
|
|
|
int n = 1;
|
|
|
foreach (var enumValue in CwVouitemsEntities)
|
|
|
{
|
|
|
enumValue.GID = Guid.NewGuid().ToString();
|
|
|
enumValue.ITEMNO = n;
|
|
|
enumValue.DbOperationType = DbOperationType.DbotIns;
|
|
|
var modb2 = new ModelObjectDB();
|
|
|
DBResult result2 = modb2.Save(enumValue);
|
|
|
n++;
|
|
|
}
|
|
|
|
|
|
//更新凭证生成关系表中的ORDNO数据
|
|
|
string strLS = sAndGids.Replace("BILLNO", "BSGID");
|
|
|
string blSQL = "update [cw_vouno_bs_gl] set ORDNO='" + MsCwVouchersGl.ORDNO + "' where VOUALLNO='" + cfVOUALLNO + "' and BSTABLENAME='ch_fee_invoicehexiao' and [STARTGID]='" + strCwSTARTGID + "'" + strLS;
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blSQL);
|
|
|
|
|
|
blSQL = "update code_fill_serialno set ISDELETE=1,DELETEUSER='" + strUserID + "',DELETETIME=GETDATE() where TABLENAME='cw_vouchers_gl' and SERIALNO='" + cfVOUALLNO + "' and STARTGID='" + strCwSTARTGID + "'";
|
|
|
bl = T_ALL_DA.GetExecuteSqlCommand(blSQL);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//result.Success = false;
|
|
|
//result.Message = result.Message;
|
|
|
//return result;
|
|
|
|
|
|
//删除ch_fee_invoicehexiao中未生成的凭证号
|
|
|
//string blSQL = "update ch_fee_invoicehexiao set VOUNO='' where VOUNO='" + cfVOUALLNO + "'" + sAndGids.Trim();
|
|
|
//删除凭证生成关系表中的ch_fee_invoicehexiao的GID数据
|
|
|
string strLS = sAndGids.Replace("BILLNO", "BSGID");
|
|
|
string blSQL = "delete from [cw_vouno_bs_gl] where VOUALLNO='" + cfVOUALLNO + "' and BSTABLENAME='ch_fee_invoicehexiao' and [STARTGID]='" + strCwSTARTGID + "'" + strLS;
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blSQL);
|
|
|
return -2;//重复数据
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//删除ch_fee_invoicehexiao中未生成的凭证号
|
|
|
//string blSQL = "update ch_fee_invoicehexiao set VOUNO='' where VOUNO='" + cfVOUALLNO + "'" + sAndGids.Trim();
|
|
|
//删除凭证生成关系表中的ch_fee_invoicehexiao的GID数据
|
|
|
string strLS = sAndGids.Replace("BILLNO", "BSGID");
|
|
|
string blSQL = "delete from [cw_vouno_bs_gl] where VOUALLNO='" + cfVOUALLNO + "' and BSTABLENAME='ch_fee_invoicehexiao' and [STARTGID]='" + strCwSTARTGID + "'" + strLS;
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blSQL);
|
|
|
return -3;//结算无明细数据
|
|
|
}
|
|
|
//result.Success = true;
|
|
|
//result.Message = result.Message;
|
|
|
//return result;
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
protected static int getSCInv(DataSet dsCwDesign, DataSet dsCwDesignItem, string sAndGids, MsCwVouchersGl3 headData, List<MsCwVouchersGl4> bodyList, string strUserID, string strCompanyID, string cfVOUALLNO)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
#region 基本变量
|
|
|
//全部
|
|
|
string sSQL = "";
|
|
|
string strEXPLAN = "";
|
|
|
string strFCY = "RMB";
|
|
|
Decimal dEXCHANGERATE = 0;
|
|
|
//应付应付账款
|
|
|
Decimal iAMTDR = 0;
|
|
|
Decimal iAMTCR = 0;
|
|
|
//差额主营业务成本
|
|
|
Decimal dRMBS = 0;
|
|
|
Decimal dRMBF = 0;
|
|
|
Decimal dUSDS = 0;
|
|
|
Decimal dUSDF = 0;
|
|
|
//总合计
|
|
|
//Decimal strJie = 0;
|
|
|
//Decimal strDai = 0;
|
|
|
string strBPVW = dsCwDesign.Tables[0].Rows[0]["TVW"].ToString().Trim();
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(strUserID);
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置
|
|
|
//科目设置 应付RMB
|
|
|
sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() + "'";
|
|
|
DataSet dsAP = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
//科目设置 应付USD
|
|
|
sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim() + "'";
|
|
|
DataSet dsAPFC = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
|
|
|
//主营业务成本 成本RMB
|
|
|
sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() + "'";
|
|
|
DataSet dsMBSPENDING = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
//主营成本外币 成本USD
|
|
|
sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim() + "'";
|
|
|
DataSet dsTMSFC = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
|
|
|
//进项税
|
|
|
sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' and ACCID='" + dsCwDesign.Tables[0].Rows[0]["INPUTTAX"].ToString().Trim() + "'";
|
|
|
DataSet dsINPUTTAX = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
#endregion
|
|
|
|
|
|
#region 摘要
|
|
|
string strISEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLAN += ",CUSTOMERNAME";//是否收付客户名称CUSTOMERNAME
|
|
|
}
|
|
|
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLAN += ",MBLNO";//是否主提单号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISINVEXPLANONRATE"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLAN += ",INVRATE,INVOICENO";//是否主提单号
|
|
|
}
|
|
|
else {
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLAN += ",INVOICENO";//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLAN += ",VESSEL";//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLAN += ",VOYNO";//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLAN += ",BSSOURCE";//是否业务来源
|
|
|
//}
|
|
|
|
|
|
string strISEXPLANnull = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLANnull += ",CUSTOMERNAME";//是否收付客户名称CUSTOMERNAME
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLANnull += ",INVOICENO";//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strISEXPLANnull += ",MBLNO";//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLANnull += ",VESSEL";//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLANnull += ",VOYNO";//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLANnull += ",BSSOURCE";//是否业务来源
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBILLNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strISEXPLANnull += ",BILLNO_ACAD";//是否申请单号
|
|
|
//}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 票号
|
|
|
if (strISEXPLAN.IndexOf(dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim()) < 0)
|
|
|
{
|
|
|
strISEXPLAN += "," + dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf(dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim()) < 0)
|
|
|
{
|
|
|
strISEXPLANnull += "," + dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 核算科目_分录
|
|
|
//string sqlItemAP = "";
|
|
|
//string sqlItemAPFC = "";
|
|
|
//string sqlItemMBSPENDING = "";
|
|
|
//string sqlItemTMSFC = "";
|
|
|
#endregion
|
|
|
|
|
|
#region 基本数据集
|
|
|
string strORDNO = getGid();
|
|
|
string sqlAP = "";
|
|
|
string sqlAPFC = "";
|
|
|
string sqlMBSPENDING = "";
|
|
|
string sqlTMSFC = "";
|
|
|
string sqlINPUTTAX = "";
|
|
|
string sqlINPUTTAXUSD = "";
|
|
|
IList<MsCwVouitemsGl> CwVouitemsEntities = new List<MsCwVouitemsGl>();
|
|
|
string strCondition = sAndGids + " and BILLNO in (select [BSGID] from [cw_vouno_bs_gl] WITH(NOLOCK) where BSTABLENAME='ch_fee_invoicehexiao' and VOUALLNO='" + cfVOUALLNO + "' and STARTGID='" + strCwSTARTGID + "')";
|
|
|
|
|
|
//是否按照系统录入汇率
|
|
|
if (headData.ISRATE == true)
|
|
|
{
|
|
|
#region 科目设置:应付RMB dsAP、应付USD dsAPFC
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim())
|
|
|
{
|
|
|
#region 应付RMB==应付USD
|
|
|
#region 摘要内容
|
|
|
string sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsAP.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlAP = "SELECT EXCHANGERATE,CURRENCY,sum(AMOUNT) AS je,sum(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlAP += " GROUP BY EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN;//
|
|
|
|
|
|
sqlAP += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
//
|
|
|
sqlAPFC = "SELECT EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAPFC += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlAPFC += " GROUP BY EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN;//
|
|
|
sqlAPFC += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlAP = "SELECT INVOICECUSTNAME,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + "";
|
|
|
sqlAP += " GROUP BY VOUNO " + strISEXPLAN + sISEXPLAN;//
|
|
|
sqlAP += " ORDER BY VOUNO" + strISEXPLAN + sISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 应付RMB!=应付USD
|
|
|
//应付RMB
|
|
|
#region 摘要内容
|
|
|
string sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlAP = "SELECT SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlAP += " GROUP BY VOUNO " + strISEXPLAN + sISEXPLAN;//
|
|
|
sqlAP += " ORDER BY VOUNO" + strISEXPLAN + sISEXPLAN;
|
|
|
|
|
|
//应付USD
|
|
|
#region 摘要内容
|
|
|
sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlAPFC = "SELECT EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAPFC += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlAPFC += " GROUP BY EXCHANGERATE,CURRENCY " + strISEXPLAN + sISEXPLAN;//
|
|
|
sqlAPFC += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
#endregion
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置:主营业务成本RMB dsMBSPENDING、主营成本外币USD dsTMSFC
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim())
|
|
|
{
|
|
|
#region 主营业务成本RMB==主营成本外币USD
|
|
|
string sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlMBSPENDING = "SELECT EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(AMOUNT)-SUM(TAX)) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlMBSPENDING += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
//
|
|
|
sqlTMSFC = "SELECT EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)))-SUM(Convert(decimal(18,2),(TAX*EXCHANGERATE)))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlTMSFC += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlMBSPENDING = "SELECT (SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)))-SUM(Convert(decimal(18,2),(TAX*EXCHANGERATE)))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + "";
|
|
|
sqlMBSPENDING += " group BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 主营业务成本RMB!=主营成本外币USD
|
|
|
//主营业务成本RMB
|
|
|
string sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlMBSPENDING = "SELECT (SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(AMOUNT)-SUM(TAX)) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlMBSPENDING += " group BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
|
|
|
//主营成本外币USD
|
|
|
sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlTMSFC = "SELECT EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE)))-SUM(Convert(decimal(18,2),(TAX*EXCHANGERATE)))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlTMSFC += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
#endregion
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置:进项税 dsINPUTTAX
|
|
|
#region 核算项目
|
|
|
string ssISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
ssISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
ssISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlINPUTTAX = "SELECT EXCHANGERATE,CURRENCY,SUM(TAX) AS je,SUM(TAX*EXCHANGERATE) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1 and TAX<>0" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlINPUTTAX += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " ORDER BY CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
//
|
|
|
sqlINPUTTAXUSD = "SELECT EXCHANGERATE,CURRENCY,SUM(TAX) AS je,SUM(Convert(decimal(18,2),(TAX*EXCHANGERATE))) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAXUSD += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1 and TAX<>0" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlINPUTTAXUSD += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAXUSD += " ORDER BY CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlINPUTTAX = "SELECT SUM(TAX) AS je,SUM(Convert(decimal(18,2),(TAX*EXCHANGERATE))) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1 and TAX<>0" + strCondition;
|
|
|
sqlINPUTTAX += " group BY VOUNO" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " ORDER BY VOUNO" + strISEXPLANnull + ssISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 提取费率
|
|
|
string tbRATE = "";
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
if (bodyList.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < bodyList.Count; i++)
|
|
|
{
|
|
|
tbRATE += " WHEN CURRENCY='" + bodyList[i].CURR.ToString().Trim() + "' THEN " + bodyList[i].FCYEXRATE.ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置:应付RMB dsAP、应付USD dsAPFC
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim())
|
|
|
{
|
|
|
#region 应付RMB==应付USD
|
|
|
#region 摘要
|
|
|
string sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsAP.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlAP = "SELECT EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlAP += " GROUP BY EXCHANGERATE,CURRENCY " + strISEXPLAN + sISEXPLAN;//
|
|
|
sqlAP += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
//
|
|
|
sqlAPFC = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAPFC += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlAPFC += " GROUP BY (CASE" + tbRATE + " ELSE EXCHANGERATE END),CURRENCY " + strISEXPLAN + sISEXPLAN;//
|
|
|
sqlAPFC += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlAP = "SELECT SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + "";
|
|
|
sqlAP += " GROUP BY VOUNO " + strISEXPLAN + sISEXPLAN;//
|
|
|
sqlAP += " ORDER BY VOUNO" + strISEXPLAN + sISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 应付RMB!=应付USD
|
|
|
//应付RMB
|
|
|
#region 摘要
|
|
|
string sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlAP = "SELECT SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAP += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlAP += " GROUP BY VOUNO " + strISEXPLAN + sISEXPLAN;//
|
|
|
sqlAP += " ORDER BY VOUNO" + strISEXPLAN + sISEXPLAN;
|
|
|
|
|
|
//应付USD
|
|
|
#region 摘要
|
|
|
sISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLAN.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlAPFC = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLAN + sISEXPLAN;
|
|
|
sqlAPFC += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlAPFC += " GROUP BY (CASE" + tbRATE + " ELSE EXCHANGERATE END),CURRENCY " + strISEXPLAN + sISEXPLAN;//
|
|
|
sqlAPFC += " ORDER BY CURRENCY" + strISEXPLAN + sISEXPLAN;
|
|
|
#endregion
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置:主营业务成本RMB dsMBSPENDING、主营成本外币USD dsTMSFC
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim())
|
|
|
{
|
|
|
#region 主营业务成本RMB==主营成本外币USD
|
|
|
string sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlMBSPENDING = "SELECT EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(AMOUNT)-SUM(TAX)) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlMBSPENDING += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
//
|
|
|
sqlTMSFC = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))-SUM(Convert(decimal(18,2),(TAX*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlTMSFC += " group BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlMBSPENDING = "SELECT (SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))-SUM(Convert(decimal(18,2),(TAX*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + "";
|
|
|
sqlMBSPENDING += " group BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 主营业务成本RMB!=主营成本外币USD
|
|
|
//主营业务成本RMB
|
|
|
string sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlMBSPENDING = "SELECT (SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(AMOUNT)-SUM(TAX)) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlMBSPENDING += " group BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlMBSPENDING += " ORDER BY VOUNO" + strISEXPLANnull + sISEXPLAN;
|
|
|
|
|
|
//主营成本外币USD
|
|
|
sISEXPLAN = "";
|
|
|
#region 核算项目
|
|
|
//是否核算客户
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
sISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
sISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币
|
|
|
sqlTMSFC = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,(SUM(AMOUNT)-SUM(TAX)) AS je,(SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))-SUM(Convert(decimal(18,2),(TAX*(CASE" + tbRATE + " ELSE EXCHANGERATE END))))) AS hj " + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlTMSFC += " group BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
sqlTMSFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN;
|
|
|
#endregion
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目设置:进项税 dsINPUTTAX
|
|
|
#region 核算项目
|
|
|
string ssISEXPLAN = "";
|
|
|
//是否核算客户
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",CUSTOMERNAME";//是否发票单位
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (strISEXPLANnull.IndexOf("CUSTOMERNAME") < 0)
|
|
|
{
|
|
|
ssISEXPLAN += ",CUSTOMERNAME";//是否委托单位
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否核算人员
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",SALE";//是否揽货人
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
ssISEXPLAN += ",DEPTGID";//是否揽货人的部门
|
|
|
}
|
|
|
//是否核算项目
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
ssISEXPLAN += ",OPLBNAME";//是否核算项目
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//ISFCY 是否核算外币
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
|
|
|
{
|
|
|
sqlINPUTTAX = "SELECT EXCHANGERATE,CURRENCY,SUM(TAX) AS je,SUM(TAX) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1 and TAX<>0" + strCondition + " and CURRENCY='RMB'";
|
|
|
sqlINPUTTAX += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " ORDER BY CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
//
|
|
|
sqlINPUTTAXUSD = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(TAX) AS je,SUM(Convert(decimal(18,2),(TAX*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAXUSD += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1 and TAX<>0" + strCondition + " and CURRENCY<>'RMB'";
|
|
|
sqlINPUTTAXUSD += " group BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAXUSD += " ORDER BY CURRENCY" + strISEXPLANnull + ssISEXPLAN;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sqlINPUTTAX = "SELECT SUM(TAX) AS je,SUM(Convert(decimal(18,2),(TAX*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " From v_ch_fee_invoice_hexiao_pz WHERE 1=1 and TAX<>0" + strCondition + "";
|
|
|
sqlINPUTTAX += " group BY VOUNO" + strISEXPLANnull + ssISEXPLAN;
|
|
|
sqlINPUTTAX += " ORDER BY VOUNO" + strISEXPLANnull + ssISEXPLAN;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
DataSet dsVWChFeeInvoiceAP = T_ALL_DA.GetAllSQL(sqlAP);
|
|
|
DataSet dsVWChFeeInvoiceAPFC = null;
|
|
|
if (sqlAPFC.Trim() != "")
|
|
|
{
|
|
|
dsVWChFeeInvoiceAPFC = T_ALL_DA.GetAllSQL(sqlAPFC);
|
|
|
}
|
|
|
DataSet dsVWChFeeInvoiceMBSPENDING = T_ALL_DA.GetAllSQL(sqlMBSPENDING);
|
|
|
DataSet dsVWChFeeInvoiceTMSFC = null;
|
|
|
if (sqlTMSFC.Trim() != "")
|
|
|
{
|
|
|
dsVWChFeeInvoiceTMSFC = T_ALL_DA.GetAllSQL(sqlTMSFC);
|
|
|
}
|
|
|
DataSet dsVWChFeeInvoiceINPUTTAX = T_ALL_DA.GetAllSQL(sqlINPUTTAX);
|
|
|
DataSet dsVWChFeeInvoiceINPUTTAXUSD = null;
|
|
|
if (sqlINPUTTAXUSD.Trim() != "")
|
|
|
{
|
|
|
dsVWChFeeInvoiceINPUTTAXUSD = T_ALL_DA.GetAllSQL(sqlINPUTTAXUSD);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
if (dsVWChFeeInvoiceAP != null || dsVWChFeeInvoiceAPFC != null)
|
|
|
{
|
|
|
#region 明细表_实体类
|
|
|
#region 插入明细表:应付RMB dsAP
|
|
|
if (dsVWChFeeInvoiceAP != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceAP.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISINVEXPLANONRATE"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceAP.Tables[0].Rows[i]["GOODSNAME"].ToString().Trim() == "仓储费")
|
|
|
{
|
|
|
strEXPLAN += " 应付仓储费(" + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["INVOICENO"].ToString().Trim() + ")";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (Convert.ToDecimal(dsVWChFeeInvoiceAP.Tables[0].Rows[i]["INVRATE"].ToString().Trim()) == 0)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceAP.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB")
|
|
|
{
|
|
|
strEXPLAN += " 应付代理运杂费(" + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["INVOICENO"].ToString().Trim() + ")";
|
|
|
}
|
|
|
else if (dsVWChFeeInvoiceAP.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "USD")
|
|
|
{
|
|
|
strEXPLAN += " 应付代理海运费(" + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["INVOICENO"].ToString().Trim() + ")";
|
|
|
}
|
|
|
}
|
|
|
else if (Convert.ToDecimal(dsVWChFeeInvoiceAP.Tables[0].Rows[i]["INVRATE"].ToString().Trim()) == 6)
|
|
|
{
|
|
|
strEXPLAN += " 应付代理杂费(" + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["INVOICENO"].ToString().Trim() + ")";
|
|
|
}
|
|
|
else if (Convert.ToDecimal(dsVWChFeeInvoiceAP.Tables[0].Rows[i]["INVRATE"].ToString().Trim()) ==10)
|
|
|
{
|
|
|
strEXPLAN += " 应付陆运费(" + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["INVOICENO"].ToString().Trim() + ")";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否收付船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
#endregion
|
|
|
|
|
|
#region 插入明细表 应付账款
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;// 行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
#region 应付账款
|
|
|
iAMTCR = iAMTCR + Decimal.Parse(dsVWChFeeInvoiceAP.Tables[0].Rows[i]["hj"].ToString().Trim());
|
|
|
//
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim();//应付账款科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVWChFeeInvoiceAP.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥)
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd
|
|
|
MsCwVouitemsGl.FCYDR = 0;//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
dRMBF += Decimal.Parse(dsVWChFeeInvoiceAP.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
//
|
|
|
MsCwVouitemsGl.ACCNAME = dsAP.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsAP.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
//是否核算客户
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统)
|
|
|
if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceAP.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceAP.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceAP.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceAP.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAP.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要
|
|
|
MsCwVouitemsGl.FCYEXRATE = 1;//汇率
|
|
|
dEXCHANGERATE = 1;//汇率
|
|
|
MsCwVouitemsGl.BLNO = "";
|
|
|
string strBLNONAME = dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim();
|
|
|
if (strBLNONAME.Trim() != "")
|
|
|
{
|
|
|
MsCwVouitemsGl.BLNO = dsVWChFeeInvoiceAP.Tables[0].Rows[i][strBLNONAME].ToString().Trim();
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// MsCwVouitemsGl.BLNO = dsVWChFeeInvoiceAP.Tables[0].Rows[i]["MBLNO"].ToString().Trim();
|
|
|
//}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
#endregion
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 插入明细表:应付外币 dsAPFC
|
|
|
if (dsVWChFeeInvoiceAPFC != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceAPFC.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISINVEXPLANONRATE"].ToString().Trim() == "True")
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["GOODSNAME"].ToString().Trim() == "仓储费")
|
|
|
{
|
|
|
strEXPLAN += " 应付仓储费(" + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["INVOICENO"].ToString().Trim() + ")";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (Convert.ToDecimal(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["INVRATE"].ToString().Trim()) == 0)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB")
|
|
|
{
|
|
|
strEXPLAN += " 应付代理运杂费(" + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["INVOICENO"].ToString().Trim() + ")";
|
|
|
}
|
|
|
else if (dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "USD")
|
|
|
{
|
|
|
strEXPLAN += " 应付代理海运费(" + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["INVOICENO"].ToString().Trim() + ")";
|
|
|
}
|
|
|
}
|
|
|
else if (Convert.ToDecimal(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["INVRATE"].ToString().Trim()) == 6)
|
|
|
{
|
|
|
strEXPLAN += " 应付代理杂费(" + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["INVOICENO"].ToString().Trim() + ")";
|
|
|
}
|
|
|
else if (Convert.ToDecimal(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["INVRATE"].ToString().Trim()) ==10)
|
|
|
{
|
|
|
strEXPLAN += " 应付陆运费(" + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["INVOICENO"].ToString().Trim() + ")";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否收付船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否收付航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
#endregion
|
|
|
|
|
|
#region 插入明细表 应付账款
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;// 行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
#region 应付账款
|
|
|
iAMTCR = iAMTCR + Decimal.Parse(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());
|
|
|
//
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim();//应付账款科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥)
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币
|
|
|
strFCY = MsCwVouitemsGl.FCYNO;
|
|
|
MsCwVouitemsGl.FCYDR = 0;//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = Decimal.Parse(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额
|
|
|
dRMBF += Decimal.Parse(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
//
|
|
|
MsCwVouitemsGl.ACCNAME = dsAPFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsAPFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
//是否核算客户
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统)
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceAPFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAPFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要
|
|
|
MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
|
|
|
dEXCHANGERATE = MsCwVouitemsGl.FCYEXRATE;//汇率
|
|
|
MsCwVouitemsGl.BLNO = "";
|
|
|
string strBLNONAME = dsCwDesign.Tables[0].Rows[0]["PiaoHao"].ToString().Trim();
|
|
|
if (strBLNONAME.Trim() != "")
|
|
|
{
|
|
|
MsCwVouitemsGl.BLNO = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i][strBLNONAME].ToString().Trim();
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// MsCwVouitemsGl.BLNO = dsVWChFeeInvoiceAPFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();
|
|
|
//}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
#endregion
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 插入明细表:主营业务成本
|
|
|
Decimal dRMB = dRMBS - dRMBF;
|
|
|
Decimal dUSD = dUSDS - dUSDF;
|
|
|
//成本\成本 生成 全额\差额
|
|
|
Decimal strJie = dRMBS + dUSDS * dEXCHANGERATE;
|
|
|
Decimal strDai = dRMBF + dUSDF * dEXCHANGERATE;
|
|
|
//
|
|
|
#region 全额
|
|
|
if (dsVWChFeeInvoiceMBSPENDING != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 成本
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;//行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim();//主营业务成本科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥)
|
|
|
strJie = strJie + MsCwVouitemsGl.AMTDR;
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = "RMB";//外币
|
|
|
MsCwVouitemsGl.FCYDR = 0;//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
MsCwVouitemsGl.ACCNAME = dsMBSPENDING.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceMBSPENDING.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsMBSPENDING.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.FCYEXRATE = 1;//汇率
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
|
|
|
MsCwVouitemsGl.BLNO = "";//
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (dsVWChFeeInvoiceTMSFC != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceTMSFC.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 成本_外币
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;//行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim();//主营业务成本科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥)
|
|
|
strJie = strJie + MsCwVouitemsGl.AMTDR;
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币
|
|
|
strFCY = MsCwVouitemsGl.FCYNO;
|
|
|
MsCwVouitemsGl.FCYDR = Decimal.Parse(dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
MsCwVouitemsGl.ACCNAME = dsTMSFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceTMSFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsTMSFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeInvoiceTMSFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
|
|
|
MsCwVouitemsGl.BLNO = "";//
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
#region 插入明细表:进项税
|
|
|
if (dsVWChFeeInvoiceINPUTTAX != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 成本
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;//行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["INPUTTAX"].ToString().Trim();//主营业务成本科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥)
|
|
|
strJie = strJie + MsCwVouitemsGl.AMTDR;
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = "RMB";//外币
|
|
|
MsCwVouitemsGl.FCYDR = 0;//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
MsCwVouitemsGl.ACCNAME = dsINPUTTAX.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceINPUTTAX.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsINPUTTAX.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.FCYEXRATE = 1;//汇率
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
|
|
|
MsCwVouitemsGl.BLNO = "";//
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (dsVWChFeeInvoiceINPUTTAXUSD != null)
|
|
|
{
|
|
|
for (int i = 0; i < dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 摘要内容
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成发票开出凭证中的主营业务科目
|
|
|
{
|
|
|
strEXPLAN = "";
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["INVOICENO"].ToString().Trim();//是否委托编号CUSTNO//发票号
|
|
|
}
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
|
|
|
{
|
|
|
strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号
|
|
|
}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次
|
|
|
//}
|
|
|
//if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True")
|
|
|
//{
|
|
|
// strEXPLAN += " " + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源
|
|
|
//}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 成本_外币
|
|
|
MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl();
|
|
|
//MsCwVouitemsGl.GID 唯一编码 newid()
|
|
|
MsCwVouitemsGl.ORDNO = strORDNO.Trim();
|
|
|
MsCwVouitemsGl.ITEMNO = 0;//行号
|
|
|
MsCwVouitemsGl.PACCID = "";//父级科目贷码
|
|
|
MsCwVouitemsGl.PROPERTY = 0;//科目属性
|
|
|
MsCwVouitemsGl.GRADE = 0;//科目级别
|
|
|
MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["INPUTTAX"].ToString().Trim();//主营业务成本科目贷码
|
|
|
MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
|
|
|
MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥)
|
|
|
strJie = strJie + MsCwVouitemsGl.AMTDR;
|
|
|
MsCwVouitemsGl.ISFCY = false;//是否外币
|
|
|
MsCwVouitemsGl.FCYNO = dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币
|
|
|
strFCY = MsCwVouitemsGl.FCYNO;
|
|
|
MsCwVouitemsGl.FCYDR = Decimal.Parse(dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额
|
|
|
MsCwVouitemsGl.FCYCR = 0;//外币贷方金额
|
|
|
MsCwVouitemsGl.ACCNAME = dsINPUTTAX.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
|
|
|
MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
|
|
|
MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
|
|
|
MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
|
|
|
MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "D";//借方向
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.DC = "C";//贷方向
|
|
|
}
|
|
|
//
|
|
|
string strACCALL = "";
|
|
|
MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.CORPID = "";//客户(系统)
|
|
|
MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME;
|
|
|
}
|
|
|
//是否核算部门
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.DEPTGID = dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门
|
|
|
strACCALL += "▁" + dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim();
|
|
|
}
|
|
|
//是否核算人员_揽货人
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.SALE = dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称
|
|
|
strACCALL += "▁" + MsCwVouitemsGl.SALE;
|
|
|
}
|
|
|
|
|
|
//是否核算项目
|
|
|
if (dsINPUTTAX.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = "";
|
|
|
if (dsCwDesignItem != null)
|
|
|
{
|
|
|
for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++)
|
|
|
{
|
|
|
if (dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim())
|
|
|
{
|
|
|
MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目
|
|
|
strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsINPUTTAX.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL;
|
|
|
MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeInvoiceINPUTTAXUSD.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
|
|
|
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = false;//是否手动录入
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MsCwVouitemsGl.ISSYS = true;//是否手动录入
|
|
|
}
|
|
|
MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
|
|
|
MsCwVouitemsGl.BLNO = "";//
|
|
|
MsCwVouitemsGl.QTYUNIT = "";//数量包装单位
|
|
|
MsCwVouitemsGl.QTYDR = 0;//借方数量
|
|
|
MsCwVouitemsGl.QTYCR = 0;//贷方数量
|
|
|
MsCwVouitemsGl.DEPTID = "";//部门(系统)
|
|
|
MsCwVouitemsGl.EMPLID = "";//人员(系统)
|
|
|
MsCwVouitemsGl.PITEMID = 0;//父级项目编号
|
|
|
MsCwVouitemsGl.ITEMID = "";//项目编号
|
|
|
MsCwVouitemsGl.FIELD1 = "";//预留字段1
|
|
|
MsCwVouitemsGl.FIELD2 = "";//预留字段2
|
|
|
MsCwVouitemsGl.FIELD3 = "";//预留字段3
|
|
|
MsCwVouitemsGl.FIELD4 = "";//预留字段4
|
|
|
MsCwVouitemsGl.FIELD5 = "";//预留字段5
|
|
|
MsCwVouitemsGl.FIELD6 = "";//预留字段6
|
|
|
MsCwVouitemsGl.FIELD7 = "";//预留字段7
|
|
|
MsCwVouitemsGl.FIELD8 = "";//预留字段8
|
|
|
MsCwVouitemsGl.FIELD9 = "";//预留字段9
|
|
|
MsCwVouitemsGl.FIELD10 = "";//预留字段10
|
|
|
MsCwVouitemsGl.FSETTLCODE = "";//结算方式
|
|
|
MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号
|
|
|
MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
|
|
|
MsCwVouitemsGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouitemsGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouitemsGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
#endregion
|
|
|
CwVouitemsEntities.Add(MsCwVouitemsGl);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
#region 插入主表
|
|
|
MsCwVouchersGl MsCwVouchersGl = new MsCwVouchersGl();
|
|
|
MsCwVouchersGl.ORDNO = strORDNO.Trim();//唯一编码 newid() varchar (36)
|
|
|
MsCwVouchersGl.VOUDATE = headData.VOUDATE;//凭证日期
|
|
|
|
|
|
//strY + "~" + strM + "~" + sVOUNO + "~" + strVOUNO + "~" + strVOUDATE + "~" + strACCDATE;
|
|
|
//string sACCDATE = headData.VOUDATE.Substring(0, 7);
|
|
|
//if (DateTime.Parse(sACCDATE + "-01") < DateTime.Parse(strACCDATE + "-01"))
|
|
|
//{
|
|
|
// sACCDATE = strACCDATE;
|
|
|
//}
|
|
|
//string strVOUNOhj = DSWeb.MvcShipping.DAL.MsBaseInfoDAL.MsBaseInfoDAL.GetCwVOUNO(strBPVW.Trim(), sACCDATE);
|
|
|
//string[] items = strVOUNOhj.Trim().Split(new string[] { "~" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
//string sVOUNO = items[2].ToString().Trim();
|
|
|
//string strVOUNO = items[3].ToString().Trim();
|
|
|
MsCwVouchersGl.VOUNO = int.Parse(cfVOUALLNO.Substring(cfVOUALLNO.Length - 4)).ToString();//sVOUNO;//月初清零 varchar (16)
|
|
|
|
|
|
MsCwVouchersGl.ACCYEAR = DateTime.Parse(headData.VOUDATE.ToString()).Year.ToString();//年
|
|
|
MsCwVouchersGl.ACCMONTH = DateTime.Parse(headData.VOUDATE.ToString()).Month.ToString();//月
|
|
|
if (MsCwVouchersGl.ACCMONTH.ToString().Length == 1)
|
|
|
{
|
|
|
MsCwVouchersGl.ACCMONTH = "0" + MsCwVouchersGl.ACCMONTH.ToString();//月
|
|
|
}
|
|
|
MsCwVouchersGl.VKNO = strBPVW.Trim();//凭证字
|
|
|
//MsCwVouchersGl.VOUALLNO = MsCwVouchersGl.VKNO + MsCwVouchersGl.ACCYEAR + MsCwVouchersGl.ACCMONTH + strVOUNO;//年+月+自动生成编号=凭证号
|
|
|
MsCwVouchersGl.VOUALLNO = cfVOUALLNO.Replace("记", strBPVW.Trim());//年+月+自动生成编号=凭证号
|
|
|
MsCwVouchersGl.ATTACHS = 1;// int.Parse(dsCwDesign.Tables[0].Rows[0]["AFFIXNO"].ToString().Trim());//附件(单据)数
|
|
|
MsCwVouchersGl.AMTDR = strJie;// iAMTDR;//本位币借方
|
|
|
MsCwVouchersGl.AMTCR = strDai;//iAMTDR;// iAMTCR;//本位币贷方
|
|
|
MsCwVouchersGl.FCY = strFCY;//是否含有外币科目
|
|
|
MsCwVouchersGl.QTY = "";//是否含有数量科目
|
|
|
MsCwVouchersGl.VOUPROP = "";//凭证属性
|
|
|
MsCwVouchersGl.PREPARED = headData.PREPARED.ToString().Trim();//制单人
|
|
|
MsCwVouchersGl.CHECKED = "";//审核人
|
|
|
MsCwVouchersGl.ENTERED = "";//记账人
|
|
|
MsCwVouchersGl.ERRMSG = "";//错误信息
|
|
|
MsCwVouchersGl.ISDELETE = false;//是否废除
|
|
|
MsCwVouchersGl.DELETEUSER = "";//废除操作人
|
|
|
MsCwVouchersGl.STARTGID = strCwSTARTGID;
|
|
|
MsCwVouchersGl.DbOperationType = DbOperationType.DbotIns;
|
|
|
MsCwVouchersGl.CREATEUSER = strUserID;//创建人
|
|
|
MsCwVouchersGl.CREATETIME = DateTime.Now;//创建时间
|
|
|
MsCwVouchersGl.MODIFIEDUSER = strUserID;//最后一次更新操作人
|
|
|
MsCwVouchersGl.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
|
|
|
MsCwVouchersGl.ISAUTO = true;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 生成入库
|
|
|
var modb = new ModelObjectDB();
|
|
|
result = modb.Save(MsCwVouchersGl);
|
|
|
if (result.Success == true)
|
|
|
{
|
|
|
int n = 1;
|
|
|
foreach (var enumValue in CwVouitemsEntities)
|
|
|
{
|
|
|
enumValue.GID = Guid.NewGuid().ToString();
|
|
|
enumValue.ITEMNO = n;
|
|
|
enumValue.DbOperationType = DbOperationType.DbotIns;
|
|
|
var modb2 = new ModelObjectDB();
|
|
|
DBResult result2 = modb2.Save(enumValue);
|
|
|
n++;
|
|
|
}
|
|
|
|
|
|
//更新凭证生成关系表中的ORDNO数据
|
|
|
string strLS = sAndGids.Replace("BILLNO", "BSGID");
|
|
|
string blSQL = "update [cw_vouno_bs_gl] set ORDNO='" + MsCwVouchersGl.ORDNO + "' where VOUALLNO='" + cfVOUALLNO + "' and BSTABLENAME='ch_fee_invoicehexiao' and [STARTGID]='" + strCwSTARTGID + "'" + strLS;
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blSQL);
|
|
|
|
|
|
blSQL = "update code_fill_serialno set ISDELETE=1,DELETEUSER='" + strUserID + "',DELETETIME=GETDATE() where TABLENAME='cw_vouchers_gl' and SERIALNO='" + cfVOUALLNO + "' and STARTGID='" + strCwSTARTGID + "'";
|
|
|
bl = T_ALL_DA.GetExecuteSqlCommand(blSQL);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//result.Success = false;
|
|
|
//result.Message = result.Message;
|
|
|
//return result;
|
|
|
|
|
|
//删除ch_fee_invoicehexiao中未生成的凭证号
|
|
|
//string blSQL = "update ch_fee_invoicehexiao set VOUNO='' where VOUNO='" + cfVOUALLNO + "'" + sAndGids.Trim();
|
|
|
//删除凭证生成关系表中的ch_fee_invoicehexiao的GID数据
|
|
|
string strLS = sAndGids.Replace("BILLNO", "BSGID");
|
|
|
string blSQL = "delete from [cw_vouno_bs_gl] where VOUALLNO='" + cfVOUALLNO + "' and BSTABLENAME='ch_fee_invoicehexiao' and [STARTGID]='" + strCwSTARTGID + "'" + strLS;
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blSQL);
|
|
|
return -2;//重复数据
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//删除ch_fee_invoicehexiao中未生成的凭证号
|
|
|
//string blSQL = "update ch_fee_invoicehexiao set VOUNO='' where VOUNO='" + cfVOUALLNO + "'" + sAndGids.Trim();
|
|
|
//删除凭证生成关系表中的ch_fee_invoicehexiao的GID数据
|
|
|
string strLS = sAndGids.Replace("BILLNO", "BSGID");
|
|
|
string blSQL = "delete from [cw_vouno_bs_gl] where VOUALLNO='" + cfVOUALLNO + "' and BSTABLENAME='ch_fee_invoicehexiao' and [STARTGID]='" + strCwSTARTGID + "'" + strLS;
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blSQL);
|
|
|
return -3;//结算无明细数据
|
|
|
}
|
|
|
//result.Success = true;
|
|
|
//result.Message = result.Message;
|
|
|
//return result;
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static String getGid()
|
|
|
{
|
|
|
string strgid = Guid.NewGuid().ToString();
|
|
|
strgid = strgid.Replace("-", "");
|
|
|
strgid = "VOU" + strgid;
|
|
|
return strgid;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|