客户对账单优化

This commit is contained in:
季圣华
2017-10-28 00:12:27 +08:00
parent a348bc29f1
commit dfdfce09a0
7 changed files with 274 additions and 34 deletions

View File

@@ -292,11 +292,19 @@ public class AccountHeadAction extends BaseAction<AccountHeadModel>
JSONObject outer = new JSONObject();
Double sum = 0.0;
String getS = model.getSupplierId();
String supType = model.getSupType(); //单位类型:客户、供应商
int i = 1;
if(supType.equals("customer")){ //客户
i = 1;
}
else if(supType.equals("vendor")){ //供应商
i = -1;
}
//收付款部分
sum = sum - (allMoney(getS, "付款", "合计") + allMoney(getS, "付款", "实际"));
sum = sum + (allMoney(getS, "收款", "合计") + allMoney(getS, "收款", "实际"));
sum = sum - (allMoney(getS, "收入", "合计") - allMoney(getS, "收入", "实际"));
sum = sum + (allMoney(getS, "支出", "合计") - allMoney(getS, "支出", "实际"));
sum = sum + (allMoney(getS, "付款", "合计") + allMoney(getS, "付款", "实际"))*i;
sum = sum - (allMoney(getS, "收款", "合计") + allMoney(getS, "收款", "实际"))*i;
sum = sum + (allMoney(getS, "收入", "合计") - allMoney(getS, "收入", "实际"))*i;
sum = sum - (allMoney(getS, "支出", "合计") - allMoney(getS, "支出", "实际"))*i;
outer.put("getAllMoney", sum);
toClient(outer.toString());
}
@@ -321,9 +329,10 @@ public class AccountHeadAction extends BaseAction<AccountHeadModel>
Log.infoFileSync("getS:" + getS);
Double allMoney = 0.0;
String allReturn = "";
PageUtil pageUtil = new PageUtil();
PageUtil<AccountHead> pageUtil = new PageUtil<AccountHead>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getConditionHead_byEndTime());
try {
Integer supplierId = Integer.valueOf(getS);
accountHeadService.findAllMoney(pageUtil, supplierId, type, mode);
@@ -362,6 +371,13 @@ public class AccountHeadAction extends BaseAction<AccountHeadModel>
return condition;
}
private Map<String,Object> getConditionHead_byEndTime()
{
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("BillTime_s_lteq", model.getEndTime());
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
public AccountHeadModel getModel()
{

View File

@@ -565,13 +565,21 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
JSONObject outer = new JSONObject();
Double sum = 0.0;
String getS = model.getSupplierId();
String supType = model.getSupType(); //单位类型:客户、供应商
int i = 1;
if(supType.equals("customer")){ //客户
i = 1;
}
else if(supType.equals("vendor")){ //供应商
i = -1;
}
//进销部分
sum = sum + (allMoney(getS, "入库", "采购", "合计") - allMoney(getS, "入库", "采购", "实际"));
sum = sum + (allMoney(getS, "入库", "销售退货", "合计") - allMoney(getS, "入库", "销售退货", "实际"));
sum = sum + (allMoney(getS, "入库", "其他", "合计") - allMoney(getS, "入库", "其他", "实际"));
sum = sum - (allMoney(getS, "出库", "销售", "合计") - allMoney(getS, "出库", "销售", "实际"));
sum = sum - (allMoney(getS, "出库", "采购退货", "合计") - allMoney(getS, "出库", "采购退货", "实际"));
sum = sum - (allMoney(getS, "出库", "其他", "合计") - allMoney(getS, "出库", "其他", "实际"));
sum = sum - (allMoney(getS, "入库", "采购", "合计") - allMoney(getS, "入库", "采购", "实际"))*i;
sum = sum - (allMoney(getS, "入库", "销售退货", "合计") - allMoney(getS, "入库", "销售退货", "实际"))*i;
sum = sum - (allMoney(getS, "入库", "其他", "合计") - allMoney(getS, "入库", "其他", "实际"))*i;
sum = sum + (allMoney(getS, "出库", "销售", "合计") - allMoney(getS, "出库", "销售", "实际"))*i;
sum = sum + (allMoney(getS, "出库", "采购退货", "合计") - allMoney(getS, "出库", "采购退货", "实际"))*i;
sum = sum + (allMoney(getS, "出库", "其他", "合计") - allMoney(getS, "出库", "其他", "实际"))*i;
outer.put("getAllMoney", sum);
toClient(outer.toString());
}
@@ -598,9 +606,10 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
Log.infoFileSync("getS:" + getS);
Double allMoney = 0.0;
String allReturn = "";
PageUtil pageUtil = new PageUtil();
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getConditionHead_byEndTime());
try {
Integer supplierId = Integer.valueOf(getS);
depotHeadService.findAllMoney(pageUtil, supplierId, type, subType, mode);
@@ -755,10 +764,58 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
Object dl = dataList.get(i); //获取对象
Object[] arr = (Object[]) dl; //转为数组
item.put("number", arr[0]); //单据编号
item.put("changeAmount", arr[1]); //金额
item.put("totalPrice", arr[2]); //金额
item.put("supplierName", arr[3]); //供应商
item.put("operTime", arr[4]); //入库出库日期
item.put("type", arr[1]); //类型
item.put("changeAmount", arr[2]); //金额
item.put("totalPrice", arr[3]); //金额
String type = arr[1].toString();
Double p1 = 0.0;
Double p2 = 0.0;
if(arr[3]!=null){
p1 = Double.parseDouble(arr[3].toString());
}
if(arr[2]!=null){
p2 = Double.parseDouble(arr[2].toString());
}
Double allPrice = 0.0;
if(p1<0) {
p1 = -p1;
}
if(p2<0) {
p2 = -p2;
}
if(type.equals("采购入库")) {
allPrice = -(p1-p2);
}
else if(type.equals("销售退货入库")) {
allPrice = -(p1-p2);
}
else if(type.equals("其他入库")) {
allPrice = -(p1-p2);
}
else if(type.equals("销售出库")) {
allPrice = p1-p2;
}
else if(type.equals("采购退货出库")) {
allPrice = p1-p2;
}
else if(type.equals("其他出库")) {
allPrice = p1-p2;
}
else if(type.equals("付款")) {
allPrice = p1+p2;
}
else if(type.equals("收款")) {
allPrice = -(p1+p2);
}
else if(type.equals("收入")) {
allPrice = p1-p2;
}
else if(type.equals("支出")) {
allPrice = -(p1-p2);
}
item.put("allPrice", String .format("%.2f",allPrice)); //计算后的金额
item.put("supplierName", arr[4]); //供应商
item.put("operTime", arr[5]); //入库出库日期
dataArray.add(item);
}
}
@@ -824,6 +881,13 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
return condition;
}
private Map<String,Object> getConditionHead_byEndTime()
{
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("OperTime_s_lteq", model.getEndTime());
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
public DepotHeadModel getModel()
{

View File

@@ -131,14 +131,14 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
@SuppressWarnings("unchecked")
public void findStatementAccount(PageUtil pageUtil,String beginTime,String endTime,Long organId) throws JshException {
StringBuffer queryString = new StringBuffer();
queryString.append("select dh.Number,dh.ChangeAmount,dh.TotalPrice,s.supplier,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_depothead dh " +
queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType,dh.ChangeAmount,dh.TotalPrice,s.supplier,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_depothead dh " +
"inner join jsh_supplier s on s.id=dh.OrganId where s.type!='会员' " +
"and dh.OperTime >='"+ beginTime +"' and dh.OperTime<='"+ endTime +"' ");
if(organId!=null && !organId.equals("")) {
queryString.append(" and dh.OrganId='"+ organId +"' ");
}
queryString.append("UNION ALL " +
"select ah.BillNo,ah.ChangeAmount,ah.TotalPrice,s.supplier,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_accounthead ah " +
"select ah.BillNo,ah.Type as newType,ah.ChangeAmount,ah.TotalPrice,s.supplier,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_accounthead ah " +
"inner join jsh_supplier s on s.id=ah.OrganId where s.type!='会员' " +
"and ah.BillTime >='"+ beginTime +"' and ah.BillTime<='"+ endTime +"' ");
if(organId!=null && !organId.equals("")) {

View File

@@ -22,6 +22,8 @@ public class AccountHeadModel implements Serializable
private String MonthTime; //查询月份
private String supplierId; //单位Id用于查询单位的收付款
private String supType; //单位类型,客户、供应商
/**
* 分类ID
*/
@@ -234,4 +236,11 @@ public class AccountHeadModel implements Serializable
this.supplierId = supplierId;
}
public String getSupType() {
return supType;
}
public void setSupType(String supType) {
this.supType = supType;
}
}

View File

@@ -44,6 +44,7 @@ public class DepotHeadModel implements Serializable
private String supplierId; //单位Id用于查询单位的应收应付
private String MaterialParam; //商品参数
private String dhIds; //单据id列表
private String supType; //单位类型,客户、供应商
/**
* 分类ID
@@ -381,4 +382,12 @@ public class DepotHeadModel implements Serializable
public void setDhIds(String dhIds) {
this.dhIds = dhIds;
}
public String getSupType() {
return supType;
}
public void setSupType(String supType) {
this.supType = supType;
}
}

View File

@@ -631,13 +631,23 @@
url = path + '/supplier/update.action?supplierID=' + supplierInfo[0];
//显示累计应收和累计应付
var thisDateTime = getNowFormatDateTime(); //当前时间
var supType = "customer";
if(listType === "客户"){
supType = "customer"
}
else if(listType === "供应商"){
supType = "vendor"
}
$.ajax({
type:"post",
url: path + "/depotHead/findTotalPay.action",
dataType: "json",
async: false,
data: ({
supplierId: supplierInfo[0]
supplierId: supplierInfo[0],
EndTime:thisDateTime,
supType: supType
}),
success: function(res){
if(res) {
@@ -648,7 +658,9 @@
dataType: "json",
async: false,
data: ({
supplierId: supplierInfo[0]
supplierId: supplierInfo[0],
EndTime:thisDateTime,
supType: supType
}),
success: function(res){
if(res) {
@@ -656,14 +668,13 @@
var money = moneyA+moneyB;
var moneyBeginNeedGet = $("#BeginNeedGet").val()-0; //期初应收
var moneyBeginNeedPay = $("#BeginNeedPay").val()-0; //期初应付
money = (money + moneyBeginNeedPay - moneyBeginNeedGet).toFixed(2);
if(money>0) {
$("#AllNeedGet").val(""); //累计应收-置空
$("#AllNeedPay").val(money); //累计应付
if(listType === "客户"){
money = (money + moneyBeginNeedGet - moneyBeginNeedPay).toFixed(2);
$("#AllNeedGet").val(money); //累计应收
}
else {
$("#AllNeedGet").val(-money); //累计应收
$("#AllNeedPay").val(""); //累计应付-置空
else if(listType === "供应商"){
money = (money + moneyBeginNeedPay - moneyBeginNeedGet).toFixed(2);
$("#AllNeedPay").val(money); //累计应付
}
}
},

View File

@@ -7,7 +7,7 @@
<!DOCTYPE html>
<html>
<head>
<title>对账</title>
<title>客户对账</title>
<meta charset="utf-8">
<!-- 指定以IE8的方式来渲染 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
@@ -49,12 +49,17 @@
&nbsp;&nbsp;
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
</td>
<td>&nbsp;</td>
<td>
期初应收:<span class="first-total">0</span>&nbsp;&nbsp;
期末应收:<span class="last-total">0</span>
</td>
</tr>
</table>
</div>
<!-- 数据显示table -->
<div id = "tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="对账列表" iconCls="icon-list" collapsible="true" closable="false">
<div id = "tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="客户对账列表" iconCls="icon-list" collapsible="true" closable="false">
<table id="tableData" style="top:300px;border-bottom-color:#FFFFFF"></table>
</div>
@@ -76,7 +81,7 @@
});
//初始化供应商、客户
//初始化客户
function initSupplier(){
$('#OrganId').combobox({
url: cusUrl,
@@ -107,10 +112,11 @@
pageList: [10,50,100],
columns:[[
{ title: '单据编号',field: 'number',width:140},
{ title: '类型',field: 'type',width:100},
{ title: '单位名称',field: 'supplierName',width:200},
{ title: '金额',field: 'allPrice',width:60,formatter: function(value,rec){
return (rec.changeAmount-rec.totalPrice).toFixed(2);
}},
{ title: '单据金额',field: 'totalPrice',width:80},
{ title: '实际支付',field: 'changeAmount',width:80},
{ title: '本期变化',field: 'allPrice',width:80},
{ title: '单据日期',field: 'operTime',width:140}
]],
onLoadError:function()
@@ -209,6 +215,131 @@
success: function (res) {
if(res){
$("#tableData").datagrid('loadData',res);
//如果选择了单位信息,就进行计算期初和期末
var supplierId = $('#OrganId').combobox('getValue');
if(supplierId) {
//先查找期初信息
var beginNeedGet = 0;
var beginNeedPay = 0;
$.ajax({
type:"post",
url: "<%=path %>/supplier/findById.action",
dataType: "json",
async: false,
data: ({
supplierID: supplierId
}),
success: function(res){
if(res && res.rows && res.rows[0]) {
if(res.rows[0].BeginNeedGet) {
beginNeedGet = res.rows[0].BeginNeedGet;
}
if(res.rows[0].BeginNeedPay) {
beginNeedPay = res.rows[0].BeginNeedPay;
}
//显示期初结存
var searchBeginTime = $("#searchBeginTime").val(); //开始时间
$.ajax({
type:"post",
url: "<%=path %>/depotHead/findTotalPay.action",
dataType: "json",
async: false,
data: ({
supplierId: supplierId,
EndTime:searchBeginTime,
supType: "customer"
}),
success: function(res){
if(res) {
var moneyA = res.getAllMoney.toFixed(2)-0;
$.ajax({
type:"post",
url: "<%=path %>/accountHead/findTotalPay.action",
dataType: "json",
async: false,
data: ({
supplierId: supplierId,
EndTime:searchBeginTime,
supType: "customer"
}),
success: function(res){
if(res) {
var moneyB = res.getAllMoney.toFixed(2)-0;
var money = moneyA+moneyB;
var moneyBeginNeedGet = beginNeedGet-0; //期初应收
var moneyBeginNeedPay = beginNeedPay-0; //期初应付
money = (money + moneyBeginNeedGet - moneyBeginNeedPay).toFixed(2);
$(".first-total").text(money); //期初结存
}
},
error: function(){
$.messager.alert('提示','网络异常请稍后再试!','error');
return;
}
});
}
},
error: function(){
$.messager.alert('提示','网络异常请稍后再试!','error');
return;
}
})
//显示期末合计
var searchEndTime = $("#searchEndTime").val(); //结束时间
$.ajax({
type:"post",
url: "<%=path %>/depotHead/findTotalPay.action",
dataType: "json",
async: false,
data: ({
supplierId: supplierId,
EndTime:searchEndTime,
supType: "customer"
}),
success: function(res){
if(res) {
var moneyA = res.getAllMoney.toFixed(2)-0;
$.ajax({
type:"post",
url: "<%=path %>/accountHead/findTotalPay.action",
dataType: "json",
async: false,
data: ({
supplierId: supplierId,
EndTime:searchEndTime,
supType: "customer"
}),
success: function(res){
if(res) {
var moneyB = res.getAllMoney.toFixed(2)-0;
var money = moneyA+moneyB;
var moneyBeginNeedGet = beginNeedGet-0; //期初应收
var moneyBeginNeedPay = beginNeedPay-0; //期初应付
money = (money + moneyBeginNeedGet - moneyBeginNeedPay).toFixed(2);
$(".last-total").text(money); //期末合计
}
},
error: function(){
$.messager.alert('提示','网络异常请稍后再试!','error');
return;
}
});
}
},
error: function(){
$.messager.alert('提示','网络异常请稍后再试!','error');
return;
}
})
}
},
error: function(){
$.messager.alert('提示','网络异常请稍后再试!','error');
return;
}
});
}
}
},
//此处添加错误处理