hanxuntao 2 months ago
parent 9ed0c7a0d1
commit bb4af31167

@ -632,7 +632,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_bankdata
var result2 = modb.Save(head);
if (result2.Success)
{
var addinvlist =ChsettlementDAL.GetPayDCDataList("BILLNO in (select BILLNO FROM ch_fee_bankdata_fitdetail WHERE LINKGID='" + Bankdata.GID + "')", userid, username, companyid,"","RMB");
var addinvlist =ChsettlementDAL.GetPayDCDataAllList("BILLNO in (select BILLNO FROM ch_fee_bankdata_fitdetail WHERE LINKGID='" + Bankdata.GID + "')","","RMB");
if (addinvlist != null && addinvlist.Count != 0)
{
var exrateList = ChsettlementDAL.GetAppCurrExrateData(addinvlist, head.CURR, "", true);

@ -2967,7 +2967,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
return headList;
}
static public List<ChPaySettlement> GetPayDCDataList(string strCondition, string userid = "", string usercode = "", string orgcode = "", string sort = null)
static public List<ChPaySettlement> GetPayDCDataList(string strCondition, string userid = "", string usercode = "", string orgcode = "", string sort = null, string localcurr = "RMB")
{
var rangstr = GetRangDAPayAppListStr("modPaySettleAppList", userid, usercode, orgcode);
@ -2984,21 +2984,27 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
}
}
var strSql = new StringBuilder();
strSql.Append("SELECT *,AMOUNT-DOAMOUNT AS BALAMOUNT,USDAMOUNT-USDDOAMOUNT AS USDBALAMOUNT FROM (SELECT GID,BILLNO,BILLSTATUS,CUSTOMERNAME,CURR,CHEQUEPAYABLE,SETTLETYPE ");
strSql.Append(" ,PAYABLETIME,AMOUNTRMB AMOUNT,RATE,ISNULL(AMOUNTOT,0)+ISNULL(AMOUNTUSD,0) USDAMOUNT");
strSql.Append("SELECT *,AMOUNT-DOAMOUNT AS BALAMOUNT,USDAMOUNT-USDDOAMOUNT AS USDBALAMOUNT,OTAMOUNT-OTDOAMOUNT AS OTBALAMOUNT FROM (SELECT GID,cm.BILLNO,BILLSTATUS,CUSTOMERNAME,CURR,CHEQUEPAYABLE,SETTLETYPE ");
strSql.Append(" ,PAYABLETIME,V.AMOUNT,RATE,V.USDAMOUNT,V.OTAMOUNT,V.DOAMOUNT,V.USDDOAMOUNT,V.OTDOAMOUNT");
strSql.Append(" ,APPLICANT,APPLYTIME,ENTERTIME,SETTLEUSER,SETTLETIME ");
strSql.Append(",(select STLNAME from [code_stlmode] where STLCODE=cm.SETTLETYPE) as SETTLETYPEREF");
strSql.Append(" ,REMARK,COMPANYID,SALECORPID,(select [NAME] from [company] where GID=cm.SALECORPID) as SALECORP ");
strSql.Append(",(select SUM(CASE FEETYPE WHEN 1 THEN -DOAMOUNT ELSE DOAMOUNT END) from ch_fee_do where CURRENCY='RMB' AND BILLNO=cm.BILLNO) as DOAMOUNT ");
strSql.Append(",(select SUM(CASE FEETYPE WHEN 1 THEN -DOAMOUNT ELSE DOAMOUNT END) from ch_fee_do where CURRENCY!='RMB' AND BILLNO=cm.BILLNO) as USDDOAMOUNT ");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97005 and EnumValueID=cm.BILLSTATUS) as BILLSTATUSREF");
strSql.Append(",(select ShowName from [user] where GID=cm.APPLICANT) as APPLICANTNAME");
strSql.Append(",CUSTACCOUNTGID");
strSql.Append(",(select CODENAME+'_'+bankname from info_client_bank where gid=cm.CUSTACCOUNTGID) CUSTBANKNAME");
strSql.Append(",(select ACCOUNT from info_client_bank where gid=cm.CUSTACCOUNTGID) CUSTACCOUNT,cm.STLAMOUNT,cm.STLRATE,cm.STLCURR,cm.INVNO");
strSql.Append(",AUDITTIME,(select ShowName from [user] where GID=cm.AUDITUSER) as AUDITUSERREF");
strSql.Append(" FROM ch_fee_payapplication cm where BILLSTATUS IN (0,4,5) ");
strSql.Append(",AUDITTIME,(select ShowName from [user] where GID=cm.AUDITUSER) as AUDITUSERREF,ISREVINV");
strSql.Append(" FROM ch_fee_payapplication cm ");
strSql.Append(" LEFT JOIN (SELECT BILLNO,ISNULL(SUM(CASE WHEN CURRENCY='" + localcurr + "' THEN CASE WHEN FEETYPE=1 THEN -AMOUNT ELSE AMOUNT END ELSE 0 END),0) AMOUNT" +
" ,ISNULL(SUM(CASE WHEN CURRENCY='USD' THEN CASE WHEN FEETYPE=1 THEN -AMOUNT ELSE AMOUNT END ELSE 0 END),0) USDAMOUNT," +
"ISNULL(SUM(CASE WHEN CURRENCY<>'" + localcurr + "' AND CURRENCY<>'USD' THEN CASE WHEN FEETYPE=1 THEN -AMOUNT ELSE AMOUNT END ELSE 0 END),0) OTAMOUNT" +
",ISNULL(SUM(CASE WHEN CURRENCY='" + localcurr + "' THEN CASE WHEN FEETYPE=1 THEN -DOAMOUNT ELSE DOAMOUNT END ELSE 0 END),0) DOAMOUNT" +
",ISNULL(SUM(CASE WHEN CURRENCY='USD' THEN CASE WHEN FEETYPE=1 THEN -DOAMOUNT ELSE DOAMOUNT END ELSE 0 END),0) USDDOAMOUNT" +
" ,ISNULL(SUM(CASE WHEN CURRENCY<>'" + localcurr + "' AND CURRENCY<>'USD' THEN CASE WHEN FEETYPE=1 THEN -DOAMOUNT ELSE DOAMOUNT END ELSE 0 END),0) OTDOAMOUNT" +
" from ch_fee_do where CATEGORY=4 GROUP BY BILLNO ) V ON (V.BILLNO=cm.BILLNO)");
strSql.Append(" where BILLSTATUS IN (0,4,5) ");
if (!string.IsNullOrEmpty(strCondition))
{
@ -3062,6 +3068,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
data.DOAMOUNT = Convert.ToDecimal(reader["DOAMOUNT"]);
if (reader["USDDOAMOUNT"] != DBNull.Value)
data.USDDOAMOUNT = Convert.ToDecimal(reader["USDDOAMOUNT"]);
if (reader["OTAMOUNT"] != DBNull.Value)
data.OTAMOUNT = Convert.ToDecimal(reader["OTAMOUNT"]);
if (reader["OTDOAMOUNT"] != DBNull.Value)
data.OTDOAMOUNT = Convert.ToDecimal(reader["OTDOAMOUNT"]);
if (reader["BALAMOUNT"] != DBNull.Value)
{
data.BALAMOUNT = Convert.ToDecimal(reader["BALAMOUNT"]);
@ -3072,6 +3083,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
data.USDBALAMOUNT = Convert.ToDecimal(reader["USDBALAMOUNT"]);
data.USDSTLAMOUNT = Convert.ToDecimal(reader["USDBALAMOUNT"]);
}
if (reader["OTBALAMOUNT"] != DBNull.Value)
{
data.OTBALAMOUNT = Convert.ToDecimal(reader["OTBALAMOUNT"]);
data.OTSTLAMOUNT = Convert.ToDecimal(reader["OTBALAMOUNT"]);
}
//data.BALAMOUNT = data.AMOUNT - data.DOAMOUNT;
//data.STLAMOUNT = data.AMOUNT - data.DOAMOUNT;
//data.USDBALAMOUNT = data.USDAMOUNT - data.USDDOAMOUNT;
@ -3105,6 +3121,9 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
if (reader["AUDITTIME"] != DBNull.Value)
data.AUDITTIME = Convert.ToDateTime(reader["AUDITTIME"]).ToString("yyyy-MM-dd hh:mm:ss");
data.AUDITUSERREF = Convert.ToString(reader["AUDITUSERREF"]);
data.ISREVINV = Convert.ToString(reader["ISREVINV"]);
#endregion
headList.Add(data);
}
@ -3113,7 +3132,161 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
return headList;
}
public static DBResult AddAppDCDetail(string billno, List<ChPaySettlement> bodyList, string curr, string companyid, string addcurr, List<ChFeeExrate> exratelist, bool isAuditExrate)
static public List<ChPaySettlement> GetPayDCDataAllList(string strCondition, string sort = null, string localcurr = "RMB")
{
var strSql = new StringBuilder();
strSql.Append("SELECT *,AMOUNT-DOAMOUNT AS BALAMOUNT,USDAMOUNT-USDDOAMOUNT AS USDBALAMOUNT,OTAMOUNT-OTDOAMOUNT AS OTBALAMOUNT FROM (SELECT GID,cm.BILLNO,BILLSTATUS,CUSTOMERNAME,CURR,CHEQUEPAYABLE,SETTLETYPE ");
strSql.Append(" ,PAYABLETIME,V.AMOUNT,RATE,V.USDAMOUNT,V.OTAMOUNT,V.DOAMOUNT,V.USDDOAMOUNT,V.OTDOAMOUNT");
strSql.Append(" ,APPLICANT,APPLYTIME,ENTERTIME,SETTLEUSER,SETTLETIME ");
strSql.Append(",(select STLNAME from [code_stlmode] where STLCODE=cm.SETTLETYPE) as SETTLETYPEREF");
strSql.Append(" ,REMARK,COMPANYID,SALECORPID,(select [NAME] from [company] where GID=cm.SALECORPID) as SALECORP ");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97005 and EnumValueID=cm.BILLSTATUS) as BILLSTATUSREF");
strSql.Append(",(select ShowName from [user] where GID=cm.APPLICANT) as APPLICANTNAME");
strSql.Append(",CUSTACCOUNTGID");
strSql.Append(",(select CODENAME+'_'+bankname from info_client_bank where gid=cm.CUSTACCOUNTGID) CUSTBANKNAME");
strSql.Append(",(select ACCOUNT from info_client_bank where gid=cm.CUSTACCOUNTGID) CUSTACCOUNT,cm.STLAMOUNT,cm.STLRATE,cm.STLCURR,cm.INVNO");
strSql.Append(",AUDITTIME,(select ShowName from [user] where GID=cm.AUDITUSER) as AUDITUSERREF,ISREVINV");
strSql.Append(" FROM ch_fee_payapplication cm ");
strSql.Append(" LEFT JOIN (SELECT BILLNO,ISNULL(SUM(CASE WHEN CURRENCY='" + localcurr + "' THEN CASE WHEN FEETYPE=1 THEN -AMOUNT ELSE AMOUNT END ELSE 0 END),0) AMOUNT" +
" ,ISNULL(SUM(CASE WHEN CURRENCY='USD' THEN CASE WHEN FEETYPE=1 THEN -AMOUNT ELSE AMOUNT END ELSE 0 END),0) USDAMOUNT," +
"ISNULL(SUM(CASE WHEN CURRENCY<>'" + localcurr + "' AND CURRENCY<>'USD' THEN CASE WHEN FEETYPE=1 THEN -AMOUNT ELSE AMOUNT END ELSE 0 END),0) OTAMOUNT" +
",ISNULL(SUM(CASE WHEN CURRENCY='" + localcurr + "' THEN CASE WHEN FEETYPE=1 THEN -DOAMOUNT ELSE DOAMOUNT END ELSE 0 END),0) DOAMOUNT" +
",ISNULL(SUM(CASE WHEN CURRENCY='USD' THEN CASE WHEN FEETYPE=1 THEN -DOAMOUNT ELSE DOAMOUNT END ELSE 0 END),0) USDDOAMOUNT" +
" ,ISNULL(SUM(CASE WHEN CURRENCY<>'" + localcurr + "' AND CURRENCY<>'USD' THEN CASE WHEN FEETYPE=1 THEN -DOAMOUNT ELSE DOAMOUNT END ELSE 0 END),0) OTDOAMOUNT" +
" from ch_fee_do where CATEGORY=4 GROUP BY BILLNO ) V ON (V.BILLNO=cm.BILLNO)");
strSql.Append(" where BILLSTATUS IN (0,4,5) ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
var PaySettlMustBeFeeLock = MsSysParamSetDAL.GetData("PARAMNAME='PaySettlMustBeFeeLock'");
if (PaySettlMustBeFeeLock.PARAMVALUE == "1")
{
strSql.Append(" and NOT EXISTS(select 1 from ch_fee_do where BILLNO=cm.BILLNO and EXISTS (select 1 from v_op_bill where OPLBNAME='海运出口' and bsno=ch_fee_do.BSNO and FEESTATUS<>1 )) ");
//strCondition = strCondition + " and B.FEESTATUS=1 ";
}
strSql.Append(") AS V ");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
sortstring = sortstring.Replace("USDBALAMOUNT", "(USDAMOUNT-USDDOAMOUNT)");
sortstring = sortstring.Replace("USDSTLAMOUNT", "(USDAMOUNT-USDDOAMOUNT)");
sortstring = sortstring.Replace("BALAMOUNT", "(AMOUNT-DOAMOUNT)");
sortstring = sortstring.Replace("STLAMOUNT", "(AMOUNT-DOAMOUNT)");
strSql.Append(" order by " + sortstring + ",APPLYTIME DESC");
}
else
{
strSql.Append(" order by APPLYTIME DESC");
}
return SetPayDCAllData(strSql);
}
private static List<ChPaySettlement> SetPayDCAllData(StringBuilder strSql)
{
var headList = new List<ChPaySettlement>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
ChPaySettlement data = new ChPaySettlement();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.BILLNO = Convert.ToString(reader["BILLNO"]);
data.BILLSTATUS = Convert.ToInt32(reader["BILLSTATUS"]);
data.BILLSTATUSREF = Convert.ToString(reader["BILLSTATUSREF"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
if (reader["CURR"] != DBNull.Value)
data.CURR = Convert.ToString(reader["CURR"]);
if (reader["PAYABLETIME"] != DBNull.Value)
data.PAYABLETIME = Convert.ToDateTime(reader["PAYABLETIME"]).ToString("yyyy-MM-dd");
if (reader["AMOUNT"] != DBNull.Value)
data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]);
if (reader["USDAMOUNT"] != DBNull.Value)
data.USDAMOUNT = Convert.ToDecimal(reader["USDAMOUNT"]);
if (reader["DOAMOUNT"] != DBNull.Value)
data.DOAMOUNT = Convert.ToDecimal(reader["DOAMOUNT"]);
if (reader["USDDOAMOUNT"] != DBNull.Value)
data.USDDOAMOUNT = Convert.ToDecimal(reader["USDDOAMOUNT"]);
if (reader["OTAMOUNT"] != DBNull.Value)
data.OTAMOUNT = Convert.ToDecimal(reader["OTAMOUNT"]);
if (reader["OTDOAMOUNT"] != DBNull.Value)
data.OTDOAMOUNT = Convert.ToDecimal(reader["OTDOAMOUNT"]);
if (reader["BALAMOUNT"] != DBNull.Value)
{
data.BALAMOUNT = Convert.ToDecimal(reader["BALAMOUNT"]);
data.STLAMOUNT = Convert.ToDecimal(reader["BALAMOUNT"]);
}
if (reader["USDBALAMOUNT"] != DBNull.Value)
{
data.USDBALAMOUNT = Convert.ToDecimal(reader["USDBALAMOUNT"]);
data.USDSTLAMOUNT = Convert.ToDecimal(reader["USDBALAMOUNT"]);
}
if (reader["OTBALAMOUNT"] != DBNull.Value)
{
data.OTBALAMOUNT = Convert.ToDecimal(reader["OTBALAMOUNT"]);
data.OTSTLAMOUNT = Convert.ToDecimal(reader["OTBALAMOUNT"]);
}
//data.BALAMOUNT = data.AMOUNT - data.DOAMOUNT;
//data.STLAMOUNT = data.AMOUNT - data.DOAMOUNT;
//data.USDBALAMOUNT = data.USDAMOUNT - data.USDDOAMOUNT;
//data.USDSTLAMOUNT = data.USDAMOUNT - data.USDDOAMOUNT;
data.APPLICANT = Convert.ToString(reader["APPLICANT"]);
data.APPLICANTNAME = Convert.ToString(reader["APPLICANTNAME"]);
if (reader["APPLYTIME"] != DBNull.Value)
data.APPLYTIME = Convert.ToDateTime(reader["APPLYTIME"]);
if (reader["ENTERTIME"] != DBNull.Value)
data.ENTERTIME = Convert.ToDateTime(reader["ENTERTIME"]);
if (reader["SETTLETIME"] != DBNull.Value)
data.SETTLETIME = Convert.ToDateTime(reader["SETTLETIME"]);
data.SETTLEUSER = Convert.ToString(reader["SETTLEUSER"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
data.CUSTACCOUNTGID = Convert.ToString(reader["CUSTACCOUNTGID"]);
data.CUSTBANKNAME = Convert.ToString(reader["CUSTBANKNAME"]);
data.CUSTACCOUNT = Convert.ToString(reader["CUSTACCOUNT"]);
if (reader["STLAMOUNT"] != DBNull.Value)
data.AUDITSTLAMOUNT = Convert.ToDecimal(reader["STLAMOUNT"]);
if (reader["STLRATE"] != DBNull.Value)
data.AUDITSTLRATE = Convert.ToDecimal(reader["STLRATE"]);
data.AUDITSTLCURR = Convert.ToString(reader["STLCURR"]);
data.AUDITSTLCURR = Convert.ToString(reader["STLCURR"]);
data.SETTLETYPE = Convert.ToString(reader["SETTLETYPE"]);
data.SETTLETYPEREF = Convert.ToString(reader["SETTLETYPEREF"]);
data.SALECORPID = Convert.ToString(reader["SALECORPID"]);
data.SALECORP = Convert.ToString(reader["SALECORP"]);
data.INVNO = Convert.ToString(reader["INVNO"]);
if (reader["AUDITTIME"] != DBNull.Value)
data.AUDITTIME = Convert.ToDateTime(reader["AUDITTIME"]).ToString("yyyy-MM-dd hh:mm:ss");
data.AUDITUSERREF = Convert.ToString(reader["AUDITUSERREF"]);
data.ISREVINV = Convert.ToString(reader["ISREVINV"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public static DBResult AddAppDCDetail(string billno, List<ChPaySettlement> bodyList, string curr, string companyid, string addcurr, List<ChFeeExrate> exratelist, bool isAuditExrate, string localcurr = "RMB")
{
var result = new DBResult();
@ -3167,14 +3340,15 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
{
var currstr = "";
if (addcurr != "")
currstr = " and c.CURRENCY='"+addcurr+"'";
currstr = " and c.CURRENCY='" + addcurr + "'";
List<Chfee_do_detail> feedolist = PayAppGetBodyList(" c.BILLNO='" + enumValue.BILLNO + "' AND c.AMOUNT<>c.DOAMOUNT AND ((f.AMOUNT>=0 AND ((f.AMOUNT-f.SETTLEMENT)-(c.ORIGAMOUNT-ISNULL(c.ORIGSTLAMOUNT,0)))>=0) OR (f.AMOUNT < 0 AND ((f.AMOUNT - f.SETTLEMENT)-(c.ORIGAMOUNT-ISNULL(c.ORIGSTLAMOUNT,0)))<= 0)) " + currstr, db, tran,"2");
List<Chfee_do_detail> feedolist = PayAppGetBodyList(" c.BILLNO='" + enumValue.BILLNO + "' AND c.AMOUNT<>c.DOAMOUNT AND ((f.AMOUNT>=0 AND ((f.AMOUNT-f.SETTLEMENT)-(c.ORIGAMOUNT-ISNULL(c.ORIGSTLAMOUNT,0)))>=0) OR (f.AMOUNT < 0 AND ((f.AMOUNT - f.SETTLEMENT)-(c.ORIGAMOUNT-ISNULL(c.ORIGSTLAMOUNT,0)))<= 0)) " + currstr, db, tran, "2");
var stlamount = enumValue.STLAMOUNT;
var usdstlamount = enumValue.USDSTLAMOUNT;
var otstlamount = enumValue.OTSTLAMOUNT;
var isAll = false;
if (enumValue.BALAMOUNT == enumValue.STLAMOUNT && enumValue.USDBALAMOUNT == enumValue.USDSTLAMOUNT) isAll = true;
if (enumValue.BALAMOUNT == enumValue.STLAMOUNT && enumValue.USDBALAMOUNT == enumValue.USDSTLAMOUNT && enumValue.OTBALAMOUNT == enumValue.OTSTLAMOUNT) isAll = true;
if (feedolist != null)
{
@ -3188,42 +3362,42 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
decimal UExrate = 0;
// if ((stlamount != 0 && feedovalue.CURRENCY == "RMB") || (usdstlamount != 0 && feedovalue.CURRENCY == "USD"))
// {
if ((stlamount != 0 && feedovalue.CURRENCY == "RMB") || (usdstlamount != 0) || isAll)
// if ((stlamount != 0 && feedovalue.CURRENCY == "RMB") || (usdstlamount != 0 && feedovalue.CURRENCY == "USD"))
// {
if ((stlamount != 0 && feedovalue.CURRENCY == localcurr) || (usdstlamount != 0) || isAll)
{
if (feedovalue.CURRENCY == "RMB")
if (feedovalue.CURRENCY == localcurr)
{
if ((stlamount>=0&&(feedovalue.AMOUNT - feedovalue.DOAMOUNT) <= stlamount)|| (stlamount<0 && (feedovalue.AMOUNT - feedovalue.DOAMOUNT) >= stlamount)|| isAll)
if ((stlamount >= 0 && (feedovalue.AMOUNT - feedovalue.DOAMOUNT) <= stlamount) || (stlamount < 0 && (feedovalue.AMOUNT - feedovalue.DOAMOUNT) >= stlamount) || isAll)
{
origamount = feedovalue.ORIGAMOUNT - feedovalue.ORIGSTLAMOUNT;
amount = feedovalue.AMOUNT - feedovalue.DOAMOUNT;
if (feedovalue.FEETYPE == 2)
stlamount = stlamount - amount;
else
stlamount = stlamount+amount;
stlamount = stlamount + amount;
}
else
{
amount = stlamount;
stlamount =0;
origamount =Convert.ToDecimal((feedovalue.ORIGAMOUNT* (amount /feedovalue.AMOUNT)).ToString("f2"));
stlamount = 0;
origamount = Convert.ToDecimal((feedovalue.ORIGAMOUNT * (amount / feedovalue.AMOUNT)).ToString("f2"));
}
}
else if (feedovalue.CURRENCY == "USD")
{
if ( (usdstlamount>=0&&(feedovalue.AMOUNT - feedovalue.DOAMOUNT) <= usdstlamount)|| (usdstlamount<0 && (feedovalue.AMOUNT - feedovalue.DOAMOUNT) >= usdstlamount) || isAll)
if ((usdstlamount >= 0 && (feedovalue.AMOUNT - feedovalue.DOAMOUNT) <= usdstlamount) || (usdstlamount < 0 && (feedovalue.AMOUNT - feedovalue.DOAMOUNT) >= usdstlamount) || isAll)
{
origamount = feedovalue.ORIGAMOUNT - feedovalue.ORIGSTLAMOUNT;
amount = feedovalue.AMOUNT - feedovalue.DOAMOUNT;
if (feedovalue.FEETYPE == 2)
usdstlamount = usdstlamount - amount;
else
usdstlamount = usdstlamount + amount;
origamount = feedovalue.ORIGAMOUNT - feedovalue.ORIGSTLAMOUNT;
amount = feedovalue.AMOUNT - feedovalue.DOAMOUNT;
if (feedovalue.FEETYPE == 2)
usdstlamount = usdstlamount - amount;
else
usdstlamount = usdstlamount + amount;
}
@ -3236,22 +3410,22 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
}
else
{
if ((feedovalue.AMOUNT - feedovalue.DOAMOUNT) <= usdstlamount || isAll)
if ((feedovalue.AMOUNT - feedovalue.DOAMOUNT) <= otstlamount || isAll)
{
origamount = feedovalue.ORIGAMOUNT - feedovalue.ORIGSTLAMOUNT;
amount = feedovalue.AMOUNT - feedovalue.DOAMOUNT;
if (feedovalue.FEETYPE == 2)
usdstlamount = usdstlamount - amount;
otstlamount = otstlamount - amount;
else
usdstlamount = usdstlamount + amount;
otstlamount = otstlamount + amount;
}
else
{
amount = usdstlamount;
usdstlamount = 0;
amount = otstlamount;
otstlamount = 0;
origamount = Convert.ToDecimal((feedovalue.ORIGAMOUNT * (amount / feedovalue.AMOUNT)).ToString("f2"));
}
}
@ -3297,7 +3471,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
//if (tops == "topseae")
// db.AddInParameter(cmdInsert, "@BSTYPE", DbType.Boolean, true);
//else
db.AddInParameter(cmdInsert, "@BSTYPE", DbType.Boolean, false);
db.AddInParameter(cmdInsert, "@BSTYPE", DbType.Boolean, false);
db.AddInParameter(cmdInsert, "@FEEID", DbType.String, feedovalue.FEEID);
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, feedovalue.FEENAME);
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, curr);
@ -3343,7 +3517,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
}
if (!string.IsNullOrEmpty(enumValue.INVNO)) {
if (!string.IsNullOrEmpty(enumValue.INVNO))
{
cmdUpdateStl.Parameters.Clear();
db.AddInParameter(cmdUpdateStl, "@BILLNO", DbType.String, billno);
db.AddInParameter(cmdUpdateStl, "@INVNO", DbType.String, enumValue.INVNO);
@ -3372,7 +3547,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
tran.Rollback();
result.Success = false;
result.Message = "保存出现错误<"+e.Message+">,请重试或联系系统管理员";
result.Message = "保存出现错误<" + e.Message + ">,请重试或联系系统管理员";
return result;
}
@ -4739,7 +4914,53 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement
return SetInvData(strSql);
}
static public List<ChInvoice> GetRecvInvAllDataList(string strCondition, string userid = "", string usercode = "", string orgcode = "", string sort = null)
{
var strSql = new StringBuilder();
strSql.Append(" SELECT GID,INVOICENO,BILLNO,CUSTOMERNAME,ACTUALCUSTOMERNAME,INVOICECUSTNAME,INVOICEMAKETIME,BANK,ACCOUNT,BSNO,VESSELVOYAGE,ETD,POL,POD");
strSql.Append(" ,FEEITEM,AMOUNT,INVAMOUNT,AMOUNTCAPITAL,OTCURRAMOUNT,CURRENCY,REMARK,APPLICANT,APPLYTIME,OPERATOR,LICENSECODE,TAXCODE,INVOICETYPE,BILLSTATUS");
strSql.Append(" ,ISNEEDPRINT,ISNEEDFEE,OPERATETIME,MBLNO,EXCHANGERATE,PRINTCAPITAL,PRINTAMOUNT,PRINTTITLE,COMPANYID,VOUCHERNO ");
strSql.Append(" ,CUSTRATENO,CUSTADDRTEL,CUSTBANK,INVOICECATEGORY,ISDELETE,DELETEOPERATOR,DELETETIME,FEEAMOUNT,SALECORPID,RECVCURR ");
strSql.Append(",(select [NAME] from [company] where GID=cm.SALECORPID) as SALECORP");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97008 and EnumValueID=cm.INVOICECATEGORY) as INVOICECATEGORYREF");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97009 and EnumValueID=cm.INVOICETYPE) as INVOICETYPEREF");
strSql.Append(",CASE WHEN cm.CURRENCY=cm.RECVCURR then (select SUM(CASE FEETYPE WHEN 1 THEN AMOUNT-DOAMOUNT ELSE DOAMOUNT-AMOUNT END) from ch_fee_do where CURRENCY=cm.RECVCURR AND BILLNO=cm.BILLNO) ELSE ");
strSql.Append(" (select SUM(CASE FEETYPE WHEN 1 THEN ORIGAMOUNT-ISNULL(ORIGSTLAMOUNT,0) ELSE ISNULL(ORIGSTLAMOUNT,0)-ORIGAMOUNT END) from ch_fee_do where ORIGCURRENCY=cm.RECVCURR AND BILLNO=cm.BILLNO) END as DOAMOUNT ");
strSql.Append(",(case cm.billstatus when 1 then '已锁定' else '未锁定' end) as BILLSTATUSREF");
strSql.Append(",(select ShowName from [user] where GID=cm.OPERATOR) as OPERATORNAME");
strSql.Append(",(select ShowName from [user] where GID=cm.DELETEOPERATOR) as DELOPERATORNAME");
strSql.Append(", INVSHENNO=stuff ((SELECT distinct BILLNO+',' FROM ch_fee_invoiceapplication p WHERE p.INVBILLNO=cm.BILLNO FOR xml path('')), 1, 0, '')");
strSql.Append(" FROM ch_fee_invoice cm where EXISTS (select 1 from ch_fee_do d left join ch_fee f on (f.gid=d.feeid) where d.BILLNO=cm.billno and d.CATEGORY=7 ");
strSql.Append(" and f.FEESTATUS IN (0,8) and (d.ORIGAMOUNT-ISNULL(d.ORIGSTLAMOUNT,0))<>0 and (( f.AMOUNT>0 AND (d.ORIGAMOUNT-ISNULL(d.ORIGSTLAMOUNT,0))<=(f.AMOUNT-isnull(f.SETTLEMENT,0)-isnull(f.ORDERAMOUNT,0)+isnull(f.ORDERSETTLEMENT,0))) ");
strSql.Append(" or ( f.AMOUNT<0 AND (d.ORIGAMOUNT-ISNULL(d.ORIGSTLAMOUNT,0))>=(f.AMOUNT-isnull(f.SETTLEMENT,0)-isnull(f.ORDERAMOUNT,0)+isnull(f.ORDERSETTLEMENT,0)))) ) ");
var STLINVPART = MsSysParamSetDAL.GetData("PARAMNAME='STLINVPART'");
if (STLINVPART.PARAMVALUE != "1")
{
strSql.Append(" and BILLNO NOT IN (SELECT distinct BILLNO FROM ch_fee_do where EXISTS ");
strSql.Append(" (select 1 from ch_fee f where ch_fee_do.FEEID=f.GID and f.FEESTATUS IN (0,8,9) ");
strSql.Append(" and (f.SETTLEMENT<>0 or f.ORDERAMOUNT<>0 or ISNULL(f.ORDERSETTLEMENT,0)<>0) )) ");
}
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring + ",APPLYTIME DESC");
}
else
{
strSql.Append(" order by APPLYTIME DESC");
}
return SetInvData(strSql);
}
private static List<ChInvoice> SetInvData(StringBuilder strSql)
{
var headList = new List<ChInvoice>();

@ -14,9 +14,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Settlement
private string _gid = String.Empty;//主键唯一值
private string _billno = "*";//主键唯一值
private int _billstatus = 1;
private string _billstatusref ="未提交";
private string _billstatusref = "未提交";
private string _customername;//
private string _payabletime ="";
private string _payabletime = "";
private string _curr = "RMB";
private decimal _amount = 0;
private decimal _doamount = 0;
@ -66,17 +66,17 @@ namespace DSWeb.Areas.Account.Models.Chfee_Settlement
set { _billno = value; }
}
public int BILLSTATUS
public int BILLSTATUS
{
get { return _billstatus; }
set { _billstatus = value; }
}
}
public string BILLSTATUSREF
{
get { return _billstatusref; }
set { _billstatusref = value; }
}
public string BILLSTATUSREF
{
get { return _billstatusref; }
set { _billstatusref = value; }
}
public string CUSTOMERNAME
{
@ -90,7 +90,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Settlement
set { _curr = value; }
}
public string PAYABLETIME
public string PAYABLETIME
{
get { return _payabletime; }
set { _payabletime = value; }
@ -143,6 +143,13 @@ namespace DSWeb.Areas.Account.Models.Chfee_Settlement
get { return _usdbalamount; }
set { _usdbalamount = value; }
}
public decimal OTAMOUNT { get; set; }
public decimal OTDOAMOUNT { get; set; }
public decimal OTSTLAMOUNT { get; set; }
public decimal OTBALAMOUNT { get; set; }
public decimal EXCHANGERATE
{
get { return _exchangerate; }
@ -167,24 +174,24 @@ namespace DSWeb.Areas.Account.Models.Chfee_Settlement
set { _applytime = value; }
}
public DateTime? ENTERTIME
{
get { return _entertime; }
set { _entertime = value; }
}
public DateTime? ENTERTIME
{
get { return _entertime; }
set { _entertime = value; }
}
public string SETTLEUSER
{
get { return _settleuser; }
set { _settleuser = value; }
}
public string SETTLEUSER
{
get { return _settleuser; }
set { _settleuser = value; }
}
public DateTime? SETTLETIME
{
get { return _settletime; }
set { _settletime = value; }
}
public DateTime? SETTLETIME
{
get { return _settletime; }
set { _settletime = value; }
}
public string COMPANYID
{
@ -245,6 +252,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Settlement
public string INVNO { get; set; }
public string AUDITTIME { get; set; }
public string AUDITUSERREF { get; set; }
public string ISREVINV { get; set; }
#endregion
}

@ -5740,7 +5740,7 @@ Ext.extend(Shipping.MsChPayAppSettlementEdit, Ext.Panel, {
var sql = '';
var customNo = form.findField('CustomNo').getValue();
sql = sql + getAndConSql(sql, customNo, " BILLNO like '%" + customNo + "%'");
sql = sql + getAndConSql(sql, customNo, " cm.BILLNO like '%" + customNo + "%'");
var BH = form.findField('BH').getValue();
sql = sql + getAndConSql(sql, BH, " EXISTS(select 1 from ch_fee_do where BILLNO=cm.BILLNO and EXISTS(select 1 from v_op_bill where bsno=ch_fee_do.BSNO and (CUSTNO like '%" + BH + "%' or MBLNO like '%" + BH + "%' or HBLNO like '%" + BH + "%') ))");

Loading…
Cancel
Save