@ -492,767 +492,7 @@ namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlInvoiceHeXiaoDAL
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
@ -1453,6 +693,22 @@ namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlInvoiceHeXiaoDAL
& & ( ( dsAP . ACCID = = dsAPFC . ACCID & & dsAP . ISFCY ) | | dsAP . ACCID ! = dsAPFC . ACCID ) )
{
var isfind = false ;
decimal EXRATE = 0 ;
if ( bodyList ! = null )
{
if ( bodyList . Count > 0 )
{
for ( int Z = 0 ; Z < bodyList . Count ; Z + + )
{
if ( bodyList [ Z ] . CURR . ToString ( ) . Trim ( ) = = dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ "CURRENCY" ] . ToString ( ) . Trim ( ) ) {
EXRATE = Convert . ToDecimal ( bodyList [ Z ] . FCYEXRATE . ToString ( ) . Trim ( ) ) ;
}
}
}
}
if ( dsCwDesign . Tables [ 0 ] . Rows [ 0 ] [ "PiaoHao" ] . ToString ( ) . Trim ( ) ! = "INVOICENO" )
{
@ -1472,9 +728,9 @@ namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlInvoiceHeXiaoDAL
isfind = true ;
items . FCYCR = items . FCYCR + Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ "AMOUNT" ] . ToString ( ) . Trim ( ) ) ; //外币借方金额
items . AMTCR = items . AMTCR + Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " INV AMOUNT"] . ToString ( ) . Trim ( ) ) ;
iAMTCR = iAMTCR + Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " INV AMOUNT"] . ToString ( ) . Trim ( ) ) ;
dRMBS + = Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " INV AMOUNT"] . ToString ( ) . Trim ( ) ) ; //本位币借方金额(互斥)
items . AMTCR = items . AMTCR + ( Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " AMOUNT"] . ToString ( ) . Trim ( ) ) * EXRATE ) ;
iAMTCR = iAMTCR + ( Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " AMOUNT"] . ToString ( ) . Trim ( ) ) * EXRATE ) ;
dRMBS + = ( Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " AMOUNT"] . ToString ( ) . Trim ( ) ) * EXRATE ) ; //本位币借方金额(互斥)
break ;
@ -1498,10 +754,10 @@ namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlInvoiceHeXiaoDAL
MsCwVouitemsGl . GRADE = 0 ; //科目级别
#region 应收账款
iAMTCR = iAMTCR + Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " INV AMOUNT"] . ToString ( ) . Trim ( ) ) ;
MsCwVouitemsGl . AMTCR = Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " INV AMOUNT"] . ToString ( ) . Trim ( ) ) ; //本位币借方金额(互斥)
iAMTCR = iAMTCR + ( Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " AMOUNT"] . ToString ( ) . Trim ( ) ) * EXRATE ) ;
MsCwVouitemsGl . AMTCR = ( Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " AMOUNT"] . ToString ( ) . Trim ( ) ) * EXRATE ) ; //本位币借方金额(互斥)
MsCwVouitemsGl . FCYCR = Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ "AMOUNT" ] . ToString ( ) . Trim ( ) ) ; //外币借方金额
dRMBS + = Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " INV AMOUNT"] . ToString ( ) . Trim ( ) ) ; //本位币借方金额(互斥)
dRMBS + = ( Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ " AMOUNT"] . ToString ( ) . Trim ( ) ) * EXRATE ) ; //本位币借方金额(互斥)
@ -1513,7 +769,6 @@ namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlInvoiceHeXiaoDAL
MsCwVouitemsGl . FCYNO = dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ "CURRENCY" ] . ToString ( ) . Trim ( ) ; //外币
strFCY = MsCwVouitemsGl . FCYNO ;
MsCwVouitemsGl . FCYCR = 0 ; //外币贷方金额
/ /
MsCwVouitemsGl . ACCNAME = dsAPFC . ACCLNAME ; //科目名称
@ -1575,7 +830,7 @@ namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlInvoiceHeXiaoDAL
MsCwVouitemsGl . ACCALL = dsAPFC . ACCNAME + strACCALL ;
MsCwVouitemsGl . EXPLAN = strEXPLAN ; //摘要
if ( Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ "AMOUNT" ] . ToString ( ) . Trim ( ) ) ! = 0 )
MsCwVouitemsGl . FCYEXRATE = Decimal. Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ "INVAMOUNT" ] . ToString ( ) . Trim ( ) ) / Decimal . Parse ( dsVWChFeeAR . Tables [ 0 ] . Rows [ i ] [ "AMOUNT" ] . ToString ( ) . Trim ( ) ) ; //汇率
MsCwVouitemsGl . FCYEXRATE = EXRATE ; //汇率
dEXCHANGERATE = MsCwVouitemsGl . FCYEXRATE ; //汇率
MsCwVouitemsGl . BLNO = "" ;
string strBLNONAME = dsCwDesign . Tables [ 0 ] . Rows [ 0 ] [ "PiaoHao" ] . ToString ( ) . Trim ( ) ;