|
|
|
|
var commonGridObj_do;
|
|
|
|
|
var commonGridObj_recv;
|
|
|
|
|
|
|
|
|
|
var jsonCacheObj;
|
|
|
|
|
|
|
|
|
|
function $(id){
|
|
|
|
|
return document.getElementById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createRecvGrid(){
|
|
|
|
|
//header
|
|
|
|
|
var headerArgs_recv = new Array("<input type=\"checkbox\" id=\"order_checkall\" onclick=\"recvAll()\" />","付款单位","币别","结算金额","未结金额");
|
|
|
|
|
//width
|
|
|
|
|
var widthArgs_recv = new Array("40","110","60","80","80");
|
|
|
|
|
//column align
|
|
|
|
|
var colAlignArgs_recv = new Array("center","center","center","center","center");
|
|
|
|
|
//column sort
|
|
|
|
|
var colSortArgs_recv = new Array("str","str","str","str","str");
|
|
|
|
|
//column type
|
|
|
|
|
var colTypeArgs_recv = new Array("ch","ro","ro","ed","ro");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commonGridObj_recv = new TGridCommon("mygrid_container_recv","form1",headerArgs_recv,widthArgs_recv,colAlignArgs_recv,colSortArgs_recv,colTypeArgs_recv);
|
|
|
|
|
|
|
|
|
|
commonGridObj_recv.setResponseUrl("SettlementGridSourceApp.aspx");
|
|
|
|
|
|
|
|
|
|
var _verifycacheName = $("h_verifycache").value;
|
|
|
|
|
commonGridObj_recv.setRequest("SettlementGridSourceApp.aspx?handle=getverifycache&verifycachename="+_verifycacheName+"&uid="+commonGridObj_recv.newGuid());
|
|
|
|
|
commonGridObj_recv.setSourceType("json");
|
|
|
|
|
commonGridObj_recv.setSkin("xp");
|
|
|
|
|
commonGridObj_recv.setImageUrl("../images/");
|
|
|
|
|
commonGridObj_recv.initGrid();
|
|
|
|
|
commonGridObj_recv.bind();
|
|
|
|
|
|
|
|
|
|
commonGridObj_recv.getGridObj().enableEditEvents(true,false,true);
|
|
|
|
|
|
|
|
|
|
commonGridObj_recv.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
|
|
|
|
|
if(stage == 0){
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if(stage == 1){
|
|
|
|
|
var selectedId = commonGridObj_recv.getGridObj().getSelectedRowId();
|
|
|
|
|
var rowIndex = commonGridObj_recv.getGridObj().getRowIndex(selectedId);
|
|
|
|
|
|
|
|
|
|
var txtEdit
|
|
|
|
|
for(i = 0; i < document.all.length; i++){
|
|
|
|
|
if(document.all(i).tagName == "TEXTAREA"){
|
|
|
|
|
txtEdit = document.all(i);
|
|
|
|
|
|
|
|
|
|
txtEdit.focus();
|
|
|
|
|
txtEdit.select();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(cInd == 1 || cInd == 2){
|
|
|
|
|
if(flagFilter == 0){
|
|
|
|
|
//alert(txtEdit.value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(stage == 2){
|
|
|
|
|
var selectedId = commonGridObj_recv.getGridObj().getSelectedRowId();
|
|
|
|
|
var rowIndex = commonGridObj_recv.getGridObj().getRowIndex(selectedId);
|
|
|
|
|
var stl = 0.0;
|
|
|
|
|
var cstl = 0.0;
|
|
|
|
|
var ustl = 0.0;
|
|
|
|
|
//stl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue()))));
|
|
|
|
|
cstl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).getValue()))));
|
|
|
|
|
ustl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).getValue()))));
|
|
|
|
|
|
|
|
|
|
var tempCstl = 0.0;
|
|
|
|
|
var tempUstl = 0.0;
|
|
|
|
|
var totalCstl = 0.0;
|
|
|
|
|
var oldValue = parseFloat(oValue);
|
|
|
|
|
var newValue = parseFloat(nValue);
|
|
|
|
|
|
|
|
|
|
if(oldValue > 0){
|
|
|
|
|
if(ustl == 0){
|
|
|
|
|
if(cstl > (ustl+oldValue)){
|
|
|
|
|
return false;
|
|
|
|
|
}else{
|
|
|
|
|
totalCstl = oldValue+ustl;
|
|
|
|
|
tempUstl = totalCstl - newValue;
|
|
|
|
|
tempCstl = newValue;
|
|
|
|
|
}
|
|
|
|
|
}else if(oldValue == ustl){
|
|
|
|
|
if(newValue > oldValue){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
totalCstl = oldValue;
|
|
|
|
|
tempUstl = totalCstl - newValue;
|
|
|
|
|
tempCstl = newValue;
|
|
|
|
|
}else if(oldValue != ustl){
|
|
|
|
|
if(newValue > (oldValue+ustl)){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
totalCstl = oldValue+ustl;
|
|
|
|
|
tempUstl = totalCstl - newValue;
|
|
|
|
|
tempCstl = newValue;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).setValue(ConvertToMoney(outputMoney(tempCstl.toString())));
|
|
|
|
|
|
|
|
|
|
if(tempUstl == 0 && tempCstl > 0){
|
|
|
|
|
commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).setValue(ConvertToMoney(outputMoney(tempCstl.toString())));
|
|
|
|
|
}else{
|
|
|
|
|
commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).setValue(ConvertToMoney(outputMoney(tempUstl.toString())));
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
commonGridObj_recv.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
|
|
|
|
|
var openSet = "height=450, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-450)/2 + ",Left= "+(screen.width-1000)/2
|
|
|
|
|
var openType = "_blank";
|
|
|
|
|
|
|
|
|
|
var openUrl = "ReceiveAmountEdit.aspx?handle=edit&id="+rId;
|
|
|
|
|
var tempWin = window.open ("about:blank",openType,openSet);
|
|
|
|
|
tempWin.location = openUrl;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function createGrid(){
|
|
|
|
|
//header
|
|
|
|
|
var headerArgs_do = new Array("币别","金额","入账账户");
|
|
|
|
|
//width
|
|
|
|
|
var widthArgs_do = new Array("70","80","200");
|
|
|
|
|
//column align
|
|
|
|
|
var colAlignArgs_do = new Array("center","center","center");
|
|
|
|
|
//column sort
|
|
|
|
|
var colSortArgs_do = new Array("str","str","str");
|
|
|
|
|
//column type
|
|
|
|
|
var colTypeArgs_do = new Array("ro","ro","co");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commonGridObj_do = new TGridCommon("mygrid_container_do","form1",headerArgs_do,widthArgs_do,colAlignArgs_do,colSortArgs_do,colTypeArgs_do);
|
|
|
|
|
|
|
|
|
|
commonGridObj_do.setResponseUrl("SettlementGridSourceApp.aspx");
|
|
|
|
|
|
|
|
|
|
//var _billno = $("billno").value;
|
|
|
|
|
commonGridObj_do.setRequest("SettlementGridSourceApp.aspx?handle=billlist&billno="+1);
|
|
|
|
|
commonGridObj_do.setSourceType("json");
|
|
|
|
|
commonGridObj_do.setSkin("xp");
|
|
|
|
|
commonGridObj_do.setImageUrl("../images/");
|
|
|
|
|
commonGridObj_do.initGrid();
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
if($("h_settleinfo").value != ""){
|
|
|
|
|
var tempSettleInfo = $("h_settleinfo").value;
|
|
|
|
|
|
|
|
|
|
jsonSettleObj = eval('(' + tempSettleInfo + ')');
|
|
|
|
|
|
|
|
|
|
var isRun = false;
|
|
|
|
|
for(var i=0;i < commonGridObj_do.getGridObj().getRowsNum();i++){
|
|
|
|
|
var rowId = commonGridObj_do.getGridObj().getRowId(i);
|
|
|
|
|
var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rowId);
|
|
|
|
|
|
|
|
|
|
for(var j = 0;j<jsonSettleObj.settles.length;j++){
|
|
|
|
|
if(jsonSettleObj.settles[i].id = rowId){
|
|
|
|
|
commonGridObj_do.getGridObj().cellByIndex(rowIndex,2).setLabel(jsonSettleObj.settles[i].bank);
|
|
|
|
|
isRun = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(isRun){
|
|
|
|
|
commonGridObj_do.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
|
|
|
|
|
if(stage == 0){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},50);
|
|
|
|
|
commonGridObj_do.getGridObj().enableEditEvents(true,false,true);
|
|
|
|
|
|
|
|
|
|
var tempCache = $("h_feecache").value;
|
|
|
|
|
|
|
|
|
|
jsonCacheObj = eval('(' + tempCache + ')');
|
|
|
|
|
|
|
|
|
|
var totalFee = 0.0;
|
|
|
|
|
|
|
|
|
|
var totalRmbFee = 0.0;//RMB费用合计
|
|
|
|
|
var totalUsdFee = 0.0;//USD费用合计
|
|
|
|
|
var totalOtherFee = 0.0;//其他费用合计
|
|
|
|
|
|
|
|
|
|
var customerName = "";
|
|
|
|
|
if(jsonCacheObj.caches.length > 0){
|
|
|
|
|
|
|
|
|
|
for(var i=0;i<jsonCacheObj.caches.length;i++){
|
|
|
|
|
var feeType = 0;
|
|
|
|
|
if(i == 0){
|
|
|
|
|
customerName = jsonCacheObj.caches[i].cus;
|
|
|
|
|
$("txt_customerName").value = customerName;
|
|
|
|
|
}
|
|
|
|
|
feeType = parseInt(jsonCacheObj.caches[i].type);
|
|
|
|
|
var cstl = parseFloat(jsonCacheObj.caches[i].cstl);
|
|
|
|
|
var cur = jsonCacheObj.caches[i].cur;
|
|
|
|
|
|
|
|
|
|
if(cur == "RMB"){//如果此条费用为RMB
|
|
|
|
|
if(feeType == 1){//如果是应收则累加费用
|
|
|
|
|
totalRmbFee += cstl;
|
|
|
|
|
}else{//如果是应付则累减数据
|
|
|
|
|
totalRmbFee -= cstl;
|
|
|
|
|
}
|
|
|
|
|
}else if(cur == "USD"){//如果此条费用为USD
|
|
|
|
|
if(feeType == 1){//如果是应收则累加费用
|
|
|
|
|
totalUsdFee += cstl;
|
|
|
|
|
}else{//如果是应付则累减数据
|
|
|
|
|
totalUsdFee -= cstl;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(feeType == 1){//如果是应收则累加费用
|
|
|
|
|
totalOtherFee += cstl;
|
|
|
|
|
}else{//如果是应付则累减数据
|
|
|
|
|
totalOtherFee -= cstl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//alert(totalRmbFee);
|
|
|
|
|
var settleCurrency = $("h_settlecurrency").value;
|
|
|
|
|
var url = "SettlementGridSourceApp.aspx?handle=bankinfo&uid="+commonGridObj_do.newGuid();
|
|
|
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
|
|
|
|
|
|
|
|
var bankInfo = loader.xmlDoc.responseText;
|
|
|
|
|
var jsonCacheObj = eval('(' + bankInfo + ')');
|
|
|
|
|
|
|
|
|
|
if(settleCurrency == 1){
|
|
|
|
|
if(totalUsdFee != 0){
|
|
|
|
|
var newId = commonGridObj_do.newGuid();
|
|
|
|
|
var usdToRmbRate = parseFloat($("h_usdtormb").value);
|
|
|
|
|
totalFee = moneyMath(totalUsdFee * usdToRmbRate);
|
|
|
|
|
if(totalRmbFee != 0){
|
|
|
|
|
totalFee += totalRmbFee;
|
|
|
|
|
}
|
|
|
|
|
commonGridObj_do.getGridObj().addRow(newId,["RMB",totalFee,""],0);
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(var k=0;k<jsonCacheObj.banks.length;k++){
|
|
|
|
|
if(jsonCacheObj.banks[k].cur == "RMB"){
|
|
|
|
|
var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
|
|
|
|
|
newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
}else if(totalRmbFee != 0){
|
|
|
|
|
var newId = commonGridObj_do.newGuid();
|
|
|
|
|
totalFee = totalRmbFee;
|
|
|
|
|
commonGridObj_do.getGridObj().addRow(newId,["RMB",totalFee,""],0);
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(var k=0;k<jsonCacheObj.banks.length;k++){
|
|
|
|
|
if(jsonCacheObj.banks[k].cur == "RMB"){
|
|
|
|
|
var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
|
|
|
|
|
newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
}
|
|
|
|
|
}else if(settleCurrency == 2){
|
|
|
|
|
if(totalRmbFee != 0){
|
|
|
|
|
var newId = commonGridObj_do.newGuid();
|
|
|
|
|
var rmbToUsdRate = parseFloat($("h_rmbtousd").value);
|
|
|
|
|
totalFee = moneyMath(totalRmbFee * rmbToUsdRate);
|
|
|
|
|
if(totalUsdFee != 0){
|
|
|
|
|
totalFee += totalUsdFee;
|
|
|
|
|
}
|
|
|
|
|
//alert(totalFee);
|
|
|
|
|
commonGridObj_do.getGridObj().addRow(newId,["USD",totalFee,""],0);
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
|
|
|
|
|
for(var k=0;k<jsonCacheObj.banks.length;k++){
|
|
|
|
|
if(jsonCacheObj.banks[k].cur == "USD"){
|
|
|
|
|
var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
|
|
|
|
|
newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
}
|
|
|
|
|
else if(totalUsdFee != 0){
|
|
|
|
|
var newId = commonGridObj_do.newGuid();
|
|
|
|
|
totalFee = moneyMath(totalUsdFee);
|
|
|
|
|
commonGridObj_do.getGridObj().addRow(newId,["USD",totalFee,""],0);
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
|
|
|
|
|
for(var k=0;k<jsonCacheObj.banks.length;k++){
|
|
|
|
|
if(jsonCacheObj.banks[k].cur == "USD"){
|
|
|
|
|
var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
|
|
|
|
|
newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(totalRmbFee != 0){
|
|
|
|
|
var newId = commonGridObj_do.newGuid();
|
|
|
|
|
var usdToRmbRate = parseFloat($("h_usdtormb").value);
|
|
|
|
|
var sumRmdFee = totalRmbFee //+ (totalUsdFee * usdToRmbRate);
|
|
|
|
|
|
|
|
|
|
commonGridObj_do.getGridObj().addRow(newId,["RMB",sumRmdFee,""],0);
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(var k=0;k<jsonCacheObj.banks.length;k++){
|
|
|
|
|
if(jsonCacheObj.banks[k].cur == "RMB"){
|
|
|
|
|
var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
|
|
|
|
|
newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(totalUsdFee != 0){
|
|
|
|
|
var newId = commonGridObj_do.newGuid();
|
|
|
|
|
var rmbToUsdRate = parseFloat($("h_rmbtousd").value);
|
|
|
|
|
var sumUsdFee = moneyMath(totalUsdFee);
|
|
|
|
|
|
|
|
|
|
if(totalRmbFee != 0){
|
|
|
|
|
commonGridObj_do.getGridObj().addRow(newId,["USD",sumUsdFee,""],1);
|
|
|
|
|
}else{
|
|
|
|
|
commonGridObj_do.getGridObj().addRow(newId,["USD",sumUsdFee,""],0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(var k=0;k<jsonCacheObj.banks.length;k++){
|
|
|
|
|
if(jsonCacheObj.banks[k].cur == "USD"){
|
|
|
|
|
var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
|
|
|
|
|
newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
commonGridObj_do.bind();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function saveSettle(){
|
|
|
|
|
if(commonGridObj_do != null){
|
|
|
|
|
// var currency = commonGridObj_do.getGridObj().cellByIndex(0,0).getValue();
|
|
|
|
|
// var amount = commonGridObj_do.getGridObj().cellByIndex(0,1).getValue();
|
|
|
|
|
// var account = commonGridObj_do.getGridObj().cellByIndex(0,2).getValue();
|
|
|
|
|
// var bankinfo = commonGridObj_do.getGridObj().cellByIndex(0,2).getText();
|
|
|
|
|
//
|
|
|
|
|
// if(account == ""){
|
|
|
|
|
// alert("请选择要入账的账户");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// $("h_currency").value = currency;
|
|
|
|
|
// $("h_amount").value = amount;
|
|
|
|
|
// $("h_account").value = account;
|
|
|
|
|
|
|
|
|
|
// $("h_bankinfo").value = bankinfo;
|
|
|
|
|
|
|
|
|
|
var jsonSettleObj = null;
|
|
|
|
|
var rmbTotal = 0;
|
|
|
|
|
var usdTotal = 0;
|
|
|
|
|
var recvRmbTotal = 0;
|
|
|
|
|
var recvUsdTotal = 0;
|
|
|
|
|
var recvRmbCount = 0;
|
|
|
|
|
var recvUsdCount = 0;
|
|
|
|
|
|
|
|
|
|
for(var i = 0;i <commonGridObj_do.getGridObj().getRowsNum();i++){
|
|
|
|
|
//alert(commonGridObj_do.getGridObj().getRowId(0));alert(commonGridObj_do.getGridObj().getRowId(1));
|
|
|
|
|
var rId = commonGridObj_do.getGridObj().getRowId(i);
|
|
|
|
|
var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rId);
|
|
|
|
|
var tempSettleInfo = $("h_settleinfo").value;
|
|
|
|
|
|
|
|
|
|
if(commonGridObj_do.getGridObj().cellByIndex(rowIndex,0).getValue() == "RMB"){
|
|
|
|
|
rmbTotal += parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_do.getGridObj().cellByIndex(rowIndex,1).getValue()))));
|
|
|
|
|
|
|
|
|
|
}else if(commonGridObj_do.getGridObj().cellByIndex(rowIndex,0).getValue() == "USD"){
|
|
|
|
|
usdTotal += parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_do.getGridObj().cellByIndex(rowIndex,1).getValue()))));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(tempSettleInfo == ""){
|
|
|
|
|
|
|
|
|
|
var cacheBuffer = "";
|
|
|
|
|
cacheBuffer += "{";
|
|
|
|
|
cacheBuffer += "\"id\":\""+rId+"\",";
|
|
|
|
|
cacheBuffer += "\"cur\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,0).getValue()+"\",";//币别
|
|
|
|
|
cacheBuffer += "\"amount\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,1).getValue()+"\",";//金额
|
|
|
|
|
cacheBuffer += "\"account\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,2).getValue()+"\",";//入账账户GID
|
|
|
|
|
cacheBuffer += "\"bank\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,2).getText()+"\"";//入账账户显示信息
|
|
|
|
|
cacheBuffer += "}";
|
|
|
|
|
|
|
|
|
|
var result = "";
|
|
|
|
|
result += "{\"settles\":[";
|
|
|
|
|
result += cacheBuffer;
|
|
|
|
|
result += "]}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonSettleObj = eval('(' + result + ')');
|
|
|
|
|
|
|
|
|
|
$("h_settleinfo").value = JSON.stringify(jsonSettleObj);
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
jsonSettleObj = eval('(' + tempSettleInfo + ')');
|
|
|
|
|
var newSettles = jsonSettleObj.settles;
|
|
|
|
|
newSettles = {id:rId,cur:commonGridObj_do.getGridObj().cellByIndex(rowIndex,0).getValue(),amount:commonGridObj_do.getGridObj().cellByIndex(rowIndex,1).getValue(),account:commonGridObj_do.getGridObj().cellByIndex(rowIndex,2).getValue(),bank:commonGridObj_do.getGridObj().cellByIndex(rowIndex,2).getText()};
|
|
|
|
|
|
|
|
|
|
jsonSettleObj.settles.push(newSettles);
|
|
|
|
|
$("h_settleinfo").value = JSON.stringify(jsonSettleObj);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var isDoRmb = false;
|
|
|
|
|
var isDoUsd = false;
|
|
|
|
|
|
|
|
|
|
var jsonRecvAmountObj;
|
|
|
|
|
|
|
|
|
|
if(commonGridObj_recv != null){
|
|
|
|
|
for(var j = 0;j <commonGridObj_recv.getGridObj().getRowsNum();j++){
|
|
|
|
|
var rId = commonGridObj_recv.getGridObj().getRowId(j);
|
|
|
|
|
var rowIndex = commonGridObj_recv.getGridObj().getRowIndex(rId);
|
|
|
|
|
var tempRecvAmount = $("h_recvamount").value;
|
|
|
|
|
|
|
|
|
|
if(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,2).getValue() == "RMB"){
|
|
|
|
|
recvRmbTotal += parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).getValue()))));
|
|
|
|
|
recvRmbCount++;
|
|
|
|
|
}else if(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,2).getValue() == "USD"){
|
|
|
|
|
recvUsdTotal += parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).getValue()))));
|
|
|
|
|
recvUsdCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(tempRecvAmount == ""){
|
|
|
|
|
var cacheBuffer = "";
|
|
|
|
|
cacheBuffer += "{";
|
|
|
|
|
cacheBuffer += "\"id\":\""+rId+"\",";
|
|
|
|
|
cacheBuffer += "\"cur\":\""+commonGridObj_recv.getGridObj().cellByIndex(rowIndex,2).getValue()+"\",";//币别
|
|
|
|
|
cacheBuffer += "\"cstl\":\""+commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).getValue()+"\",";//结算金额
|
|
|
|
|
cacheBuffer += "\"ustl\":\""+commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).getValue()+"\"";//未结算金额
|
|
|
|
|
cacheBuffer += "}";
|
|
|
|
|
|
|
|
|
|
var result = "";
|
|
|
|
|
result += "{\"recvs\":[";
|
|
|
|
|
result += cacheBuffer;
|
|
|
|
|
result += "]}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonRecvAmountObj = eval('(' + result + ')');
|
|
|
|
|
|
|
|
|
|
$("h_recvamount").value = JSON.stringify(jsonRecvAmountObj);
|
|
|
|
|
}else{
|
|
|
|
|
jsonRecvAmountObj = eval('(' + tempRecvAmount + ')');
|
|
|
|
|
var newRecvAmount = jsonRecvAmountObj.recvs;
|
|
|
|
|
newRecvAmount = {id:rId,cur:commonGridObj_recv.getGridObj().cellByIndex(rowIndex,2).getValue(),cstl:commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).getValue(),ustl:commonGridObj_recv.getGridObj().cellByIndex(rowIndex,2).getValue()};
|
|
|
|
|
|
|
|
|
|
jsonRecvAmountObj.recvs.push(newRecvAmount);
|
|
|
|
|
$("h_recvamount").value = JSON.stringify(jsonRecvAmountObj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(rmbTotal > recvRmbTotal){
|
|
|
|
|
if(window.confirm("收费结算RMB费用大于实收RMB费用 只能做部分收费结算 是否继续进行部分结算")){
|
|
|
|
|
if($("h_feecache").value.trim() != ""){
|
|
|
|
|
var feeCache = $("h_feecache").value
|
|
|
|
|
var jsonFeeObj = eval('(' + feeCache + ')');
|
|
|
|
|
|
|
|
|
|
if(jsonFeeObj != null){
|
|
|
|
|
var isFull = false;
|
|
|
|
|
var mixFlag = false;
|
|
|
|
|
var isFinish = false;
|
|
|
|
|
var tempVal = 0;
|
|
|
|
|
var breakNum = 0;
|
|
|
|
|
for(var i = 0;i <jsonFeeObj.caches.length;i++){
|
|
|
|
|
if(!mixFlag){
|
|
|
|
|
if(jsonFeeObj.caches[i].cstl >= recvRmbTotal){
|
|
|
|
|
if(jsonFeeObj.caches[i].cur != jsonFeeObj.caches[i].ocurr){
|
|
|
|
|
var settleCurrency = $("h_settlecurrency").value;
|
|
|
|
|
var usdToRmbRate = parseFloat($("h_usdtormb").value);
|
|
|
|
|
var rmbToUsdRate = parseFloat($("h_rmbtousd").value);
|
|
|
|
|
if(settleCurrency == 1){
|
|
|
|
|
if(jsonFeeObj.caches[i].ocurr == "USD"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = moneyMath(recvRmbTotal * rmbToUsdRate);
|
|
|
|
|
}if(jsonFeeObj.caches[i].ocurr == "RMB"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = recvRmbTotal;
|
|
|
|
|
}
|
|
|
|
|
}else if(settleCurrency == 2){
|
|
|
|
|
if(jsonFeeObj.caches[i].ocurr == "RMB"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = moneyMath(recvUsdTotal * usdToRmbRate);
|
|
|
|
|
}if(jsonFeeObj.caches[i].ocurr == "USD"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = recvRmbTotal;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
jsonFeeObj.caches[i].ustl = jsonFeeObj.caches[i].cstl - recvRmbTotal;
|
|
|
|
|
jsonFeeObj.caches[i].cstl = recvRmbTotal;//alert(JSON.stringify(jsonFeeObj));
|
|
|
|
|
isFull = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(i == jsonFeeObj.caches.length - 1){
|
|
|
|
|
//如果没有单个结算没有大于等于实收费用则取最顶端结算费用组合全部或部分结算
|
|
|
|
|
if(!isFull){
|
|
|
|
|
i = -1;
|
|
|
|
|
mixFlag = true;
|
|
|
|
|
tempVal = 0;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
tempVal += jsonFeeObj.caches[i].cstl;
|
|
|
|
|
if(tempVal >= recvRmbTotal){
|
|
|
|
|
if(jsonFeeObj.caches[i].cur != jsonFeeObj.caches[i].ocurr){
|
|
|
|
|
var settleCurrency = $("h_settlecurrency").value;
|
|
|
|
|
var usdToRmbRate = parseFloat($("h_usdtormb").value);
|
|
|
|
|
var rmbToUsdRate = parseFloat($("h_rmbtousd").value);
|
|
|
|
|
if(settleCurrency == 1){
|
|
|
|
|
if(jsonFeeObj.caches[i].ocurr == "USD"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = moneyMath((jsonFeeObj.caches[i].cstl - (tempVal - recvRmbTotal)) * rmbToUsdRate);
|
|
|
|
|
}if(jsonFeeObj.caches[i].ocurr == "RMB"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = jsonFeeObj.caches[i].cstl - ((tempVal - recvRmbTotal));
|
|
|
|
|
}
|
|
|
|
|
}else if(settleCurrency == 2){
|
|
|
|
|
if(jsonFeeObj.caches[i].ocurr == "RMB"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = moneyMath(jsonFeeObj.caches[i].cstl - ((tempVal - recvUsdTotal)) * usdToRmbRate);
|
|
|
|
|
}if(jsonFeeObj.caches[i].ocurr == "USD"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = jsonFeeObj.caches[i].cstl - ((tempVal - recvUsdTotal));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = jsonFeeObj.caches[i].cstl - ((tempVal - recvRmbTotal));
|
|
|
|
|
}
|
|
|
|
|
jsonFeeObj.caches[i].ustl = tempVal - recvRmbTotal;
|
|
|
|
|
jsonFeeObj.caches[i].cstl = jsonFeeObj.caches[i].cstl - ((tempVal - recvRmbTotal));
|
|
|
|
|
breakNum = i+1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("h_feecache").value = JSON.stringify(jsonFeeObj);//alert($("h_feecache").value);
|
|
|
|
|
//$("h_settleinfo").value = "";
|
|
|
|
|
createGrid();
|
|
|
|
|
var tempSettleInfo = $("h_settleinfo").value;
|
|
|
|
|
var tempSettleObj = eval('(' + tempSettleInfo + ')');
|
|
|
|
|
|
|
|
|
|
if(tempSettleObj != null){
|
|
|
|
|
tempSettleObj.settles[0].amount = recvRmbTotal;
|
|
|
|
|
$("h_settleinfo").value = JSON.stringify(tempSettleObj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
isDoRmb = true;
|
|
|
|
|
//return;
|
|
|
|
|
}else{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(usdTotal > recvUsdTotal){
|
|
|
|
|
if(window.confirm("收费结算USD费用大于实收USD费用 只能做部分收费结算 是否继续进行部分结算")){
|
|
|
|
|
if($("h_feecache").value.trim() != ""){
|
|
|
|
|
var feeCache = $("h_feecache").value
|
|
|
|
|
var jsonFeeObj = eval('(' + feeCache + ')');
|
|
|
|
|
|
|
|
|
|
if(jsonFeeObj != null){
|
|
|
|
|
var isFull = false;
|
|
|
|
|
var mixFlag = false;
|
|
|
|
|
var isFinish = false;
|
|
|
|
|
var tempVal = 0;
|
|
|
|
|
var breakNum = 0;
|
|
|
|
|
for(var i = 0;i <jsonFeeObj.caches.length;i++){
|
|
|
|
|
if(!mixFlag){
|
|
|
|
|
if(jsonFeeObj.caches[i].cstl >= recvUsdTotal){
|
|
|
|
|
if(jsonFeeObj.caches[i].cur != jsonFeeObj.caches[i].ocurr){
|
|
|
|
|
var settleCurrency = $("h_settlecurrency").value;
|
|
|
|
|
var usdToRmbRate = parseFloat($("h_usdtormb").value);
|
|
|
|
|
var rmbToUsdRate = parseFloat($("h_rmbtousd").value);
|
|
|
|
|
if(settleCurrency == 1){
|
|
|
|
|
if(jsonFeeObj.caches[i].ocurr == "USD"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = moneyMath(recvRmbTotal * rmbToUsdRate);
|
|
|
|
|
}if(jsonFeeObj.caches[i].ocurr == "RMB"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = recvRmbTotal;
|
|
|
|
|
}
|
|
|
|
|
}else if(settleCurrency == 2){
|
|
|
|
|
if(jsonFeeObj.caches[i].ocurr == "RMB"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = moneyMath(recvUsdTotal * usdToRmbRate);
|
|
|
|
|
}if(jsonFeeObj.caches[i].ocurr == "USD"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = recvUsdTotal;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
jsonFeeObj.caches[i].ustl = jsonFeeObj.caches[i].cstl - recvUsdTotal;
|
|
|
|
|
jsonFeeObj.caches[i].cstl = recvUsdTotal;
|
|
|
|
|
isFull = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if(i == jsonFeeObj.caches.length - 1){
|
|
|
|
|
//如果没有单个结算没有大于等于实收费用则取最顶端结算费用组合全部或部分结算
|
|
|
|
|
if(!isFull){
|
|
|
|
|
i = -1;
|
|
|
|
|
mixFlag = true;
|
|
|
|
|
tempVal = 0;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
tempVal += moneyMath(jsonFeeObj.caches[i].cstl);
|
|
|
|
|
tempVal = moneyMath(tempVal);
|
|
|
|
|
|
|
|
|
|
if(tempVal >= recvUsdTotal){
|
|
|
|
|
if(jsonFeeObj.caches[i].cur != jsonFeeObj.caches[i].ocurr){
|
|
|
|
|
var settleCurrency = $("h_settlecurrency").value;
|
|
|
|
|
var usdToRmbRate = parseFloat($("h_usdtormb").value);
|
|
|
|
|
var rmbToUsdRate = parseFloat($("h_rmbtousd").value);
|
|
|
|
|
if(settleCurrency == 1){
|
|
|
|
|
if(jsonFeeObj.caches[i].ocurr == "USD"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = moneyMath((jsonFeeObj.caches[i].cstl - (tempVal - recvUsdTotal)) * rmbToUsdRate);
|
|
|
|
|
}if(jsonFeeObj.caches[i].ocurr == "RMB"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = recvRmbTotal;
|
|
|
|
|
}
|
|
|
|
|
}else if(settleCurrency == 2){
|
|
|
|
|
if(jsonFeeObj.caches[i].ocurr == "RMB"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = moneyMath((jsonFeeObj.caches[i].cstl - (tempVal - recvRmbTotal)) * usdToRmbRate);
|
|
|
|
|
}if(jsonFeeObj.caches[i].ocurr == "USD"){
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = moneyMath(jsonFeeObj.caches[i].cstl - (tempVal - recvUsdTotal));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
jsonFeeObj.caches[i].ocstl = moneyMath(jsonFeeObj.caches[i].cstl - (tempVal - recvUsdTotal));
|
|
|
|
|
}
|
|
|
|
|
jsonFeeObj.caches[i].ustl = moneyMath(tempVal - recvUsdTotal);
|
|
|
|
|
jsonFeeObj.caches[i].cstl = moneyMath(jsonFeeObj.caches[i].cstl - (tempVal - recvUsdTotal));
|
|
|
|
|
breakNum = i+1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(breakNum < jsonFeeObj.caches.length - 1){
|
|
|
|
|
for(var j = jsonFeeObj.caches.length-1;j >= 0;j--){
|
|
|
|
|
jsonCacheObj.caches.splice(breakNum,1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$("h_feecache").value = JSON.stringify(jsonFeeObj);
|
|
|
|
|
//$("h_settleinfo").value = "";
|
|
|
|
|
createGrid();
|
|
|
|
|
var tempSettleInfo = $("h_settleinfo").value;
|
|
|
|
|
var tempSettleObj = eval('(' + tempSettleInfo + ')');
|
|
|
|
|
|
|
|
|
|
if(tempSettleObj != null){
|
|
|
|
|
tempSettleObj.settles[0].amount = recvUsdTotal;
|
|
|
|
|
$("h_settleinfo").value = JSON.stringify(tempSettleObj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
isDoUsd = true;
|
|
|
|
|
//return;
|
|
|
|
|
}else{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(recvRmbTotal > rmbTotal){
|
|
|
|
|
if(recvRmbCount > 1){
|
|
|
|
|
alert("多笔实收费用需指定结算金额");
|
|
|
|
|
return;
|
|
|
|
|
}else{
|
|
|
|
|
for(var j = 0;j <commonGridObj_recv.getGridObj().getRowsNum();j++){
|
|
|
|
|
var rId = commonGridObj_recv.getGridObj().getRowId(j);
|
|
|
|
|
var rowIndex = commonGridObj_recv.getGridObj().getRowIndex(rId);
|
|
|
|
|
|
|
|
|
|
if(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,2).getValue() == "RMB"){
|
|
|
|
|
var stl = 0.0;
|
|
|
|
|
var cstl = 0.0;
|
|
|
|
|
var ustl = 0.0;
|
|
|
|
|
cstl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).getValue()))));
|
|
|
|
|
ustl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).getValue()))));
|
|
|
|
|
|
|
|
|
|
var tempCstl = 0.0;
|
|
|
|
|
var tempUstl = 0.0;
|
|
|
|
|
var totalCstl = 0.0;
|
|
|
|
|
var oldValue = cstl;
|
|
|
|
|
var newValue = rmbTotal;
|
|
|
|
|
|
|
|
|
|
if(oldValue > 0){
|
|
|
|
|
if(ustl == 0){
|
|
|
|
|
if(cstl > (ustl+oldValue)){
|
|
|
|
|
return false;
|
|
|
|
|
}else{
|
|
|
|
|
totalCstl = oldValue+ustl;
|
|
|
|
|
tempUstl = totalCstl - newValue;
|
|
|
|
|
tempCstl = newValue;
|
|
|
|
|
}
|
|
|
|
|
}else if(oldValue != ustl){
|
|
|
|
|
totalCstl = oldValue+ustl;
|
|
|
|
|
tempUstl = totalCstl - newValue;
|
|
|
|
|
tempCstl = newValue;
|
|
|
|
|
}else if(oldValue == ustl){
|
|
|
|
|
totalCstl = oldValue;
|
|
|
|
|
tempUstl = totalCstl - newValue;
|
|
|
|
|
tempCstl = newValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).setValue(ConvertToMoney(outputMoney(tempCstl.toString())));
|
|
|
|
|
commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).setValue(ConvertToMoney(outputMoney(tempUstl.toString())));
|
|
|
|
|
|
|
|
|
|
var tempRecvAmount = $("h_recvamount").value;
|
|
|
|
|
|
|
|
|
|
jsonRecvAmountObj = eval('(' + tempRecvAmount + ')');
|
|
|
|
|
for(var k=0;k<jsonRecvAmountObj.recvs.length;k++){
|
|
|
|
|
if(jsonRecvAmountObj.recvs[k].id == rId){
|
|
|
|
|
jsonRecvAmountObj.recvs[k].cstl = tempCstl;
|
|
|
|
|
jsonRecvAmountObj.recvs[k].ustl = tempUstl;
|
|
|
|
|
$("h_recvamount").value = JSON.stringify(jsonRecvAmountObj);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(recvUsdTotal > usdTotal){
|
|
|
|
|
if(recvUsdCount > 1){
|
|
|
|
|
alert("多笔实收费用需指定结算金额");
|
|
|
|
|
return;
|
|
|
|
|
}else{
|
|
|
|
|
for(var j = 0;j <commonGridObj_recv.getGridObj().getRowsNum();j++){
|
|
|
|
|
var rId = commonGridObj_recv.getGridObj().getRowId(j);
|
|
|
|
|
var rowIndex = commonGridObj_recv.getGridObj().getRowIndex(rId);
|
|
|
|
|
|
|
|
|
|
if(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,2).getValue() == "USD"){
|
|
|
|
|
var stl = 0.0;
|
|
|
|
|
var cstl = 0.0;
|
|
|
|
|
var ustl = 0.0;
|
|
|
|
|
cstl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).getValue()))));
|
|
|
|
|
ustl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).getValue()))));
|
|
|
|
|
|
|
|
|
|
var tempCstl = 0.0;
|
|
|
|
|
var tempUstl = 0.0;
|
|
|
|
|
var totalCstl = 0.0;
|
|
|
|
|
var oldValue = cstl;
|
|
|
|
|
var newValue = usdTotal;
|
|
|
|
|
|
|
|
|
|
if(oldValue > 0){
|
|
|
|
|
if(ustl == 0){
|
|
|
|
|
if(cstl > (ustl+oldValue)){
|
|
|
|
|
return false;
|
|
|
|
|
}else{
|
|
|
|
|
totalCstl = oldValue+ustl;
|
|
|
|
|
tempUstl = totalCstl - newValue;
|
|
|
|
|
tempCstl = newValue;
|
|
|
|
|
}
|
|
|
|
|
}else if(oldValue != ustl){
|
|
|
|
|
totalCstl = oldValue+ustl;
|
|
|
|
|
tempUstl = totalCstl - newValue;
|
|
|
|
|
tempCstl = newValue;
|
|
|
|
|
}else if(oldValue == ustl){
|
|
|
|
|
totalCstl = oldValue;
|
|
|
|
|
tempUstl = totalCstl - newValue;
|
|
|
|
|
tempCstl = newValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).setValue(ConvertToMoney(outputMoney(tempCstl.toString())));
|
|
|
|
|
commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).setValue(ConvertToMoney(outputMoney(tempUstl.toString())));
|
|
|
|
|
|
|
|
|
|
var tempRecvAmount = $("h_recvamount").value;
|
|
|
|
|
|
|
|
|
|
jsonRecvAmountObj = eval('(' + tempRecvAmount + ')');
|
|
|
|
|
for(var k=0;k<jsonRecvAmountObj.recvs.length;k++){
|
|
|
|
|
if(jsonRecvAmountObj.recvs[k].id == rId){
|
|
|
|
|
jsonRecvAmountObj.recvs[k].cstl = tempCstl;
|
|
|
|
|
jsonRecvAmountObj.recvs[k].ustl = tempUstl;
|
|
|
|
|
$("h_recvamount").value = JSON.stringify(jsonRecvAmountObj);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($("h_billno").value.trim() == ""){
|
|
|
|
|
$("h_enter").value = "1";
|
|
|
|
|
$("h_post").value = "1";
|
|
|
|
|
|
|
|
|
|
postEnterFee();
|
|
|
|
|
|
|
|
|
|
window.opener.location.href=window.opener.location.href;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function postEnterFee(){
|
|
|
|
|
var myForm = document.getElementById("form1");
|
|
|
|
|
myForm.submit() ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function outputMoney(number) {
|
|
|
|
|
number= number.replace(/\,/g,"");
|
|
|
|
|
if (isNaN(number)||number=="") return "";
|
|
|
|
|
number = Math.round( number*100) /100;
|
|
|
|
|
if(number<0)
|
|
|
|
|
return '-'+outputDollars(Math.floor(Math.abs(number)-0) + '') + outputCents(Math.abs(number) - 0);
|
|
|
|
|
else
|
|
|
|
|
return outputDollars(Math.floor(number-0) + '') + outputCents(number - 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function outputDollars(number)
|
|
|
|
|
{
|
|
|
|
|
if (number.length<= 3)
|
|
|
|
|
return (number == '' ? '0' : number);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var mod = number.length%3;
|
|
|
|
|
var output = (mod == 0 ? '' : (number.substring(0,mod)));
|
|
|
|
|
for (i=0 ; i< Math.floor(number.length/3) ; i++)
|
|
|
|
|
{
|
|
|
|
|
if ((mod ==0) && (i ==0))
|
|
|
|
|
output+= number.substring(mod+3*i,mod+3*i+3);
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
output+= ',' + number.substring(mod+3*i,mod+3*i+3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (output);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function outputCents(amount)
|
|
|
|
|
{
|
|
|
|
|
amount = Math.round( ( (amount) - Math.floor(amount) ) *100);
|
|
|
|
|
return (amount<10 ? '.0' + amount : '.' + amount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ConvertToMoney(strObj){
|
|
|
|
|
var result = strObj.replace(",","");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearNoNum(valObj)
|
|
|
|
|
{
|
|
|
|
|
//先把非数字的都替换掉,除了数字和.
|
|
|
|
|
valObj = valObj.replace(/[^\d.]/g,"");
|
|
|
|
|
//必须保证第一个为数字而不是.
|
|
|
|
|
valObj = valObj.replace(/^\./g,"");
|
|
|
|
|
//保证只有出现一个.而没有多个.
|
|
|
|
|
valObj = valObj.replace(/\.{2,}/g,".");
|
|
|
|
|
//保证.只出现一次,而不能出现两次以上
|
|
|
|
|
valObj = valObj.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
|
|
|
|
|
|
|
|
|
|
return valObj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isObjNaN(Obj){
|
|
|
|
|
if(Obj.toString().toLowerCase() == "nan"){
|
|
|
|
|
return 0;
|
|
|
|
|
}else{
|
|
|
|
|
return Obj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function moneyMath(original){
|
|
|
|
|
var result = Math.round(original*100)/100;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function cancelSettle(){
|
|
|
|
|
var strBillNO = "";
|
|
|
|
|
strBillNO = $("txt_billNO").value;
|
|
|
|
|
|
|
|
|
|
if(strBillNO.trim() != ""){
|
|
|
|
|
var url = "SettlementGridSourceApp.aspx?handle=cancelrecvsettle&billno="+strBillNO+"&uid="+commonGridObj_do.newGuid();
|
|
|
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
|
|
|
|
|
|
|
|
var stateInfo = loader.xmlDoc.responseText;
|
|
|
|
|
|
|
|
|
|
var state = parseInt(stateInfo);
|
|
|
|
|
|
|
|
|
|
if(state == 1){
|
|
|
|
|
alert("收费结算撤销完成");
|
|
|
|
|
}else if(state == -3){
|
|
|
|
|
alert("收费结算撤销已完成,不能重复操作");
|
|
|
|
|
}else if(state == -4){
|
|
|
|
|
alert("收费结算信息不存在");
|
|
|
|
|
}
|
|
|
|
|
$("btn_enter").disabled = true;
|
|
|
|
|
}else{
|
|
|
|
|
alert("费用未结算,不能进行撤销操作");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function printSettle(){
|
|
|
|
|
var strBillNO = "";
|
|
|
|
|
var typeName = "";
|
|
|
|
|
strBillNO = $("txt_billNO").value;
|
|
|
|
|
|
|
|
|
|
if(strBillNO.trim() != ""){
|
|
|
|
|
var printUrl = "";
|
|
|
|
|
var companyID = "";
|
|
|
|
|
var typeName = "RECVSETTLE";
|
|
|
|
|
var dbSourceID = "";
|
|
|
|
|
var userID = "";
|
|
|
|
|
var url = "";
|
|
|
|
|
|
|
|
|
|
url = "../Reports/ReportService.aspx?handle=printrecvsettle&billno="+strBillNO+"&val="+commonGridObj_do.newGuid();
|
|
|
|
|
typeName = "RECVSETTLE";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
|
|
|
var reportVal = loader.xmlDoc.responseText;
|
|
|
|
|
var reportObj = null;
|
|
|
|
|
|
|
|
|
|
if(reportVal != ""){
|
|
|
|
|
reportObj = eval('(' + reportVal + ')');
|
|
|
|
|
if(reportObj.reports.length > 0){
|
|
|
|
|
if(reportObj.reports[0].compid != ""){
|
|
|
|
|
companyID = reportObj.reports[0].compid;
|
|
|
|
|
}
|
|
|
|
|
if(reportObj.reports[0].sourceid != ""){
|
|
|
|
|
dbSourceID = reportObj.reports[0].sourceid;
|
|
|
|
|
}
|
|
|
|
|
if(reportObj.reports[0].compid != ""){
|
|
|
|
|
userID = reportObj.reports[0].userid;
|
|
|
|
|
}
|
|
|
|
|
printUrl = "print://?comp="+companyID+"&type="+typeName+"&dbid="+dbSourceID+"&uid="+userID;//alert(printUrl);
|
|
|
|
|
window.location.href = window.location.href;
|
|
|
|
|
location.href = printUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
alert("没有要打印的报表");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
alert("费用未结算不能打印");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
|
|
|
|
|
|
|
|
|
|
function recvAll(){
|
|
|
|
|
if(commonGridObj_recv != null){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|