Commit 164bf50b by liuyang

2024-09-10 采购发票录入发票总金额,系统自动核销采购收货明细,按照相同供应商、从最早日期往后自动核销

parent 883aca87
......@@ -164,7 +164,7 @@ public class HGCG003 extends DaoEPBase {
private BigDecimal taxAmount = new BigDecimal("0"); /* 税额*/
private BigDecimal taxRate = new BigDecimal("0"); /* 税率*/
private Integer inventTypeDetail; /* 存货类型大类*/
private Integer isInvoicing; /* 是否开票*/
private Integer isInvoicing = 0; /* 是否开票*/
private Integer source; /* 数据来源 根据采购数据来源小代码 目前0默认采购合同,1手动录入*/
private String projCode = " "; /* 项目编码*/
private String projName = " "; /* 项目名称*/
......
......@@ -66,6 +66,8 @@ public class HGCG003B extends DaoEPBase {
public static final String FIELD_PROJ_CODE = "projCode"; /* 项目编码*/
public static final String FIELD_PROJ_NAME = "projName"; /* 项目名称*/
public static final String FIELD_CALCULATION_METHOD = "calculationMethod"; /* 计算方式 0-数量乘单价 1-重量乘单价*/
public static final String FIELD_CANCEL_AMOUNT = "cancelAmount"; /* 核销金额*/
public static final String FIELD_UN_CANCEL_AMOUNT = "unCancelAmount"; /* 未核销金额*/
public static final String COL_ID = "ID";
public static final String COL_ACCOUNT_CODE = "ACCOUNT_CODE"; /* 企业编码*/
......@@ -158,10 +160,12 @@ public class HGCG003B extends DaoEPBase {
private BigDecimal taxRate = new BigDecimal("0"); /* 税率*/
private Integer inventTypeDetail; /* 存货类型大类*/
private Long primaryId = new Long(0); /* 主表id*/
private Integer isInvoicing; /* 是否开票 0否 1是*/
private Integer isInvoicing = 0; /* 是否开票 0否 1是*/
private String projCode = " "; /* 项目编码*/
private String projName = " "; /* 项目名称*/
private Integer calculationMethod; /* 计算方式 0-数量乘单价 1-重量乘单价*/
private BigDecimal cancelAmount = new BigDecimal("0"); /* 核销金额*/
private BigDecimal unCancelAmount = new BigDecimal("0"); /* 未核销金额*/
/**
* initialize the metadata.
......@@ -384,8 +388,20 @@ public class HGCG003B extends DaoEPBase {
eiColumn = new EiColumn(FIELD_CALCULATION_METHOD);
eiColumn.setDescName("计算方式 0-数量乘单价 1-重量乘单价");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_CANCEL_AMOUNT);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("核销金额");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_UN_CANCEL_AMOUNT);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("未核销金额");
eiMetadata.addMeta(eiColumn);
}
/**
......@@ -1099,6 +1115,23 @@ public class HGCG003B extends DaoEPBase {
public void setCalculationMethod(Integer calculationMethod) {
this.calculationMethod = calculationMethod;
}
public BigDecimal getCancelAmount() {
return cancelAmount;
}
public void setCancelAmount(BigDecimal cancelAmount) {
this.cancelAmount = cancelAmount;
}
public BigDecimal getUnCancelAmount() {
return unCancelAmount;
}
public void setUnCancelAmount(BigDecimal unCancelAmount) {
this.unCancelAmount = unCancelAmount;
}
/**
* get the value from Map.
*
......@@ -1151,6 +1184,8 @@ public class HGCG003B extends DaoEPBase {
setProjCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PROJ_CODE)), projCode));
setProjName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PROJ_NAME)), projName));
setCalculationMethod(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_CALCULATION_METHOD)), calculationMethod));
setCancelAmount(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_CANCEL_AMOUNT)), cancelAmount));
setUnCancelAmount(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_UN_CANCEL_AMOUNT)), unCancelAmount));
}
/**
......@@ -1204,6 +1239,8 @@ public class HGCG003B extends DaoEPBase {
map.put(FIELD_PROJ_CODE, StringUtils.toString(projCode, eiMetadata.getMeta(FIELD_PROJ_CODE)));
map.put(FIELD_PROJ_NAME, StringUtils.toString(projName, eiMetadata.getMeta(FIELD_PROJ_NAME)));
map.put(FIELD_CALCULATION_METHOD, StringUtils.toString(calculationMethod, eiMetadata.getMeta(FIELD_CALCULATION_METHOD)));
map.put(FIELD_CANCEL_AMOUNT, StringUtils.toString(cancelAmount, eiMetadata.getMeta(FIELD_CANCEL_AMOUNT)));
map.put(FIELD_UN_CANCEL_AMOUNT, StringUtils.toString(unCancelAmount, eiMetadata.getMeta(FIELD_UN_CANCEL_AMOUNT)));
return map;
}
......
......@@ -240,6 +240,7 @@ public class ServiceHGCG003A extends ServiceBase {
cg003B.setReceiveQty(fCg002B.getBcReceiveQty());
cg003B.setReceiveWeight(fCg002B.getReceiveWeight());
cg003B.setContractDetailId(fCg002B.getId());
cg003B.setUnCancelAmount(fCg002B.getTaxIncludeAmount());
DaoUtils.insert(HGCG003B.INSERT, cg003B);
// 更新合同状态
HGCGTools.HgCg002B.updateReceive(dbCg002b, cg003B.getReceiveQty());
......
......@@ -204,6 +204,7 @@ public class ServiceHGCG003B extends ServiceBase {
hgcg003B.setCompanyName(cg003.getCompanyName());
hgcg003B.setDepCode(cg003.getDepCode());
hgcg003B.setAccountCode(cg003.getAccountCode());
hgcg003B.setUnCancelAmount(hgcg003B.getTaxIncludeAmount());
DaoUtils.insert(HGCG003B.INSERT, hgcg003B);
}
......@@ -213,6 +214,7 @@ public class ServiceHGCG003B extends ServiceBase {
* @param hgcg003B
*/
private void updateData(HGCG003B hgcg003B) {
hgcg003B.setUnCancelAmount(hgcg003B.getTaxIncludeAmount());
DaoUtils.update(HGCG003B.UPDATE, hgcg003B);
}
......
......@@ -46,7 +46,9 @@
IS_INVOICING as "isInvoicing", <!-- 是否开票 0否 1是 -->
PROJ_CODE as "projCode", <!-- 项目编码 -->
PROJ_NAME as "projName", <!-- 项目名称 -->
CALCULATION_METHOD as "calculationMethod" <!-- 计算方式 0-数量乘单价 1-重量乘单价 -->
CALCULATION_METHOD as "calculationMethod", <!-- 计算方式 0-数量乘单价 1-重量乘单价 -->
CANCEL_AMOUNT as "cancelAmount",
UN_CANCEL_AMOUNT as "unCancelAmount"
</sql>
<sql id="condition">
......@@ -169,6 +171,12 @@
<isNotEmpty prepend=" AND " property="calculationMethod">
CALCULATION_METHOD = #calculationMethod#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="cancelAmount">
CANCEL_AMOUNT = #cancelAmount#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="unCancelAmount">
UN_CANCEL_AMOUNT = #unCancelAmount#
</isNotEmpty>
</sql>
<sql id="idCondition">
......@@ -256,7 +264,9 @@
IS_INVOICING, <!-- 是否开票 0否 1是 -->
PROJ_CODE, <!-- 项目编码 -->
PROJ_NAME, <!-- 项目名称 -->
CALCULATION_METHOD <!-- 计算方式 0-数量乘单价 1-重量乘单价 -->
CALCULATION_METHOD, <!-- 计算方式 0-数量乘单价 1-重量乘单价 -->
CANCEL_AMOUNT,
UN_CANCEL_AMOUNT
) VALUES (
#accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#, #deleteFlag#,
#companyCode#, #companyName#, #receiveDate#, #receiveNo#, #planNo#, #contractNo#,
......@@ -264,7 +274,7 @@
#material#, #unit#, #length#, #width#, #thick#, #receiveQty#, #deliverQty#,
#depositQty#, #receiveUnitWeight#, #receiveWeight#, #status#, #price#, #amount#,
#taxIncludeAmount#, #taxAmount#, #taxRate#, #inventTypeDetail#, #primaryId#,
#isInvoicing#, #projCode#, #projName#, #calculationMethod#
#isInvoicing#, #projCode#, #projName#, #calculationMethod#, #cancelAmount#, #unCancelAmount#
)
</insert>
......@@ -308,7 +318,9 @@
PROJ_CODE = #projCode#, <!-- 项目编码 -->
PROJ_NAME = #projName#, <!-- 项目名称 -->
CALCULATION_METHOD = #calculationMethod#,
IS_INVOICING = #isInvoicing#
IS_INVOICING = #isInvoicing#,
CANCEL_AMOUNT = #cancelAmount#,
UN_CANCEL_AMOUNT = #unCancelAmount#
WHERE ID = #id#
</update>
......@@ -404,7 +416,9 @@
b.SUP_CODE as "supCode", <!-- 供应商编码 -->
b.SUP_NAME as "supName", <!-- 供应商名称 -->
b.PUR_USER_ID as "purUserId", <!-- 采购员 -->
b.PUR_USER_NAME as "purUserName" <!-- 采购员名称 -->
b.PUR_USER_NAME as "purUserName", <!-- 采购员名称 -->
a.CANCEL_AMOUNT as "cancelAmount",
a.UN_CANCEL_AMOUNT as "unCancelAmount"
FROM ${hggpSchema}.HGCG003A a
LEFT JOIN ${hggpSchema}.HGCG003 b ON a.PRIMARY_ID = b.id
WHERE 1=1
......@@ -470,6 +484,12 @@
<isNotEmpty prepend=" AND " property="source">
b.SOURCE = #source#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="cancelAmount">
a.CANCEL_AMOUNT = #cancelAmount#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="unCancelAmount">
a.UN_CANCEL_AMOUNT = #unCancelAmount#
</isNotEmpty>
<include refid="idCondition"/>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
......
package com.baosight.hggp.hg.cw.domain;
import com.baosight.hggp.util.DateUtils;
import com.baosight.iplat4j.core.util.NumberUtils;
import java.math.BigDecimal;
import com.baosight.iplat4j.core.ei.EiColumn;
......@@ -820,8 +821,8 @@ public class HGCW012 extends DaoEPBase {
setSettlementNumber(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_SETTLEMENT_NUMBER)), settlementNumber));
setBillTybe(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_BILL_TYBE)), billTybe));
setBillNumber(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_BILL_NUMBER)), billNumber));
setBillState(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_BILL_STATE)), billState));
setSigningDate(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_SIGNING_DATE)), signingDate));
setBillState(NumberUtils.toInteger(StringUtils.toString(DateUtils.formatShort(map.get(FIELD_BILL_STATE))), billState));
setSigningDate(StringUtils.defaultIfEmpty(StringUtils.toString(DateUtils.formatShort(map.get(FIELD_SIGNING_DATE))), signingDate));
setPartyA(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PARTY_A)), partyA));
setReviewStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_REVIEW_STATUS)), reviewStatus));
setTaxPoints(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_TAX_POINTS)), taxPoints));
......
......@@ -7,8 +7,11 @@ import com.baosight.hggp.common.ReviewStatusEnum;
import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.cg.domain.HGCG003;
import com.baosight.hggp.hg.cg.domain.HGCG003B;
import com.baosight.hggp.hg.cg.tools.HGCGTools;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.cw.domain.HGCW006;
import com.baosight.hggp.hg.cw.domain.HGCW008;
import com.baosight.hggp.hg.cw.domain.HGCW012;
......@@ -88,23 +91,18 @@ public class ServiceHGCW012 extends ServiceBase {
for (Map resultRow : resultRows) {
HGCW012 hgcw012 = new HGCW012();
hgcw012.fromMap(resultRow);
//UserVO userVO = HGCWTools.HgCw002.getUserCompany();
//hgcw012.setCompanyCode(userVO.getUsercode());
//hgcw012.setCompanyName(userVO.getUsername());
// 获取项目名称
//HGSC001 HGSC001 = HGSCTools.Hgsc001.queryByCode(HGCW012.getProjCode());
//HGCW012.setProjName(HGSC001.getProjName());
String signingDate = DateUtils.formatShort(hgcw012.getSigningDate());
hgcw012.setContractType(0);
//String signingDate = DateUtils.formatShort(hgcw012.getSigningDate());
String billState = hgcw012.getBillNumber();
if (StringUtils.isNotNull(billState)) {
hgcw012.setSigningDate(signingDate);
//hgcw012.setSigningDate(signingDate);
hgcw012.setBillState(1);
}
if (hgcw012.getReviewStatus().equals(ReviewStatusEnum.REVIEWED.getCode())){
throw new PlatException("该数据已审核,不能保存!");
}
if (hgcw012.getId() == null || hgcw012.getId() == 0) {
hgcw012.setReviewStatus(ReviewStatusEnum.UNREVIEWED.getCode());
//hgcw012.setReviewStatus(ReviewStatusEnum.UNREVIEWED.getCode());
this.add(hgcw012);
} else {
this.modify(hgcw012);
......@@ -126,7 +124,73 @@ public class ServiceHGCW012 extends ServiceBase {
* @return
*/
public void add(HGCW012 hgcw012) {
List<HGCG003B> hgcg003BList = DaoBase.getInstance().query(HGSqlConstant.HgCw012A.QUERY_HGCG003A,
new HashMap<String, Object>(){{
put(HGCG003B.FIELD_COMPANY_CODE, hgcw012.getCompanyCode());
put(HGCG003B.FIELD_PROJ_CODE, hgcw012.getProjCode());
put(HGCG003.FIELD_SUP_CODE, hgcw012.getPartyA());
put(HGCG003.FIELD_STATUS, HGConstant.CgReceiveStatus.S_5);
put(HGCG003.FIELD_IS_INVOICING, HGConstant.CgIsInvoicing.S_0);
put("isUnCancelAmount", HGConstant.CgIsInvoicing.S_0);
}}
);
AssertUtils.isEmpty(hgcg003BList, "未找到匹配的采购收货");
DaoUtils.insert(HGCW012.INSERT, hgcw012);
BigDecimal taxPoints = new BigDecimal(hgcw012.getTaxPoints()); // 假设这是以整数形式给出的税率,比如17表示17%
BigDecimal taxRateAsDecimal = taxPoints.divide(new BigDecimal("100")).add(new BigDecimal("1")); // 将税率 转换为小数形式
BigDecimal totalContractPriceIncluding = hgcw012.getTotalContractPriceIncluding(); // 发票金额
boolean flag = true;
StringBuffer settlementNumber = new StringBuffer();
//生成明细表
for (HGCG003B hgcg003B : hgcg003BList) {
settlementNumber.append(hgcg003B.getReceiveNo()).append(",");
HGCW013 hgcw013 = new HGCW013();
BeanUtils.copyProperties(hgcg003B, hgcw013,"id","accountCode","depCode","createdBy","createdName","createdTime","updatedBy","updatedName","updatedTime");
hgcw013.setMainId(hgcw012.getId());
hgcw013.setSettlementNumber(hgcg003B.getReceiveNo()); //收货单号
hgcw013.setBillNumber(hgcw012.getBillNumber()); //发票号
hgcw013.setPartyA(hgcw012.getPartyA()); //供应商
BigDecimal amount = hgcg003B.getUnCancelAmount();
BigDecimal thisSettlementAmount = BigDecimal.ZERO; //不含税金额
BigDecimal thisSettlementTax = BigDecimal.ZERO; // 计算 税额
// 发票金额大于货物金额
if (totalContractPriceIncluding.compareTo(amount) >= 0){
totalContractPriceIncluding = totalContractPriceIncluding.subtract(amount);
thisSettlementAmount = amount.divide(taxRateAsDecimal, 3, RoundingMode.HALF_UP); //不含税金额
thisSettlementTax = amount.subtract(thisSettlementAmount); // 计算 税额
hgcw013.setTotalContractPriceIncluding(amount);
BigDecimal c = hgcg003B.getCancelAmount().add(amount);
hgcg003B.setCancelAmount(c);
hgcg003B.setUnCancelAmount(BigDecimal.ZERO);
hgcg003B.setIsInvoicing(HGConstant.CgIsInvoicing.S_1);
if (totalContractPriceIncluding.compareTo(amount) == 0){
flag = false;
}
}else {
thisSettlementAmount = totalContractPriceIncluding.divide(taxRateAsDecimal, 3, RoundingMode.HALF_UP); //不含税金额
thisSettlementTax = totalContractPriceIncluding.subtract(thisSettlementAmount); // 计算 税额
hgcw013.setTotalContractPriceIncluding(totalContractPriceIncluding);
BigDecimal c = hgcg003B.getCancelAmount().add(totalContractPriceIncluding);
hgcg003B.setCancelAmount(c);
hgcg003B.setUnCancelAmount(amount.subtract(totalContractPriceIncluding));
hgcg003B.setIsInvoicing(HGConstant.CgIsInvoicing.S_0);
flag = false;
}
hgcw013.setTaxPoints(hgcw012.getTaxPoints());
hgcw013.setThisSettlementTax(String.valueOf(thisSettlementTax)); //税额
hgcw013.setThisSettlementAmount(String.valueOf(thisSettlementAmount)); //不含税金额
DaoUtils.insert(HGCW013.INSERT, hgcw013);
//跟新采购收票状态
DaoUtils.update(HGCG003B.UPDATE, hgcg003B);
if (!flag){
break;
}
}
hgcw012.setSettlementNumber(settlementNumber.toString().substring(0, settlementNumber.length() - 1));
DaoUtils.update(HGCW012.UPDATE, hgcw012);
}
/**
......@@ -495,7 +559,7 @@ public class ServiceHGCW012 extends ServiceBase {
BigDecimal taxPoints = new BigDecimal(hgcw012.getTaxPoints()); // 假设这是以整数形式给出的税率,比如17表示17%
BigDecimal thisAmount = hgcw013.getTotalContractPriceIncluding(); //开票总额
BigDecimal taxRateAsDecimal = taxPoints.divide(new BigDecimal("100")).add(new BigDecimal("1")); // 将税率转换为小数形式
BigDecimal thisSettlementAmount = thisAmount.divide(taxRateAsDecimal, 2, RoundingMode.HALF_UP);
BigDecimal thisSettlementAmount = thisAmount.divide(taxRateAsDecimal, 3, RoundingMode.HALF_UP);
BigDecimal thisSettlementTax = thisAmount.subtract(thisSettlementAmount); // 计算税额
hgcw013.setThisSettlementTax(thisSettlementTax.toString());
hgcw013.setThisSettlementAmount(thisSettlementAmount.toString());
......
......@@ -447,10 +447,16 @@
A.STATUS as "status", <!-- 状态:0-已收货,1-已入库,2-部分入库,3-退货 -->
A.PRICE as "price", <!-- 单价 -->
A.AMOUNT as "amount", <!-- 金额(不含税金额) -->
A.TAX_INCLUDE_AMOUNT as "taxIncludeAmount", <!-- 含税金额 -->
A.TAX_AMOUNT as "taxAmount", <!-- 税额 -->
A.TAX_RATE as "taxRate", <!-- 税率 -->
A.INVENT_TYPE_DETAIL as "inventTypeDetail", <!-- 存货类型大类 -->
A.PRIMARY_ID as "primaryId", <!-- 主表id -->
A.CONTRACT_DETAIL_ID as "contractDetailId", <!-- 合同明细id -->
A.IS_INVOICING as "isInvoicing"
A.IS_INVOICING as "isInvoicing",
A.CALCULATION_METHOD as "calculationMethod", <!-- 计算方式 0-数量乘单价 1-重量乘单价 -->
A.CANCEL_AMOUNT as "cancelAmount",
A.UN_CANCEL_AMOUNT as "unCancelAmount"
FROM ${hggpSchema}.HGCG003A A LEFT JOIN ${hggpSchema}.HGCG003 B ON A.PRIMARY_ID = B.ID
WHERE A.DELETE_FLAG = 0 and b.delete_flag = 0
<isNotEmpty prepend=" AND " property="id">
......@@ -555,12 +561,21 @@
<isNotEmpty prepend=" AND " property="isInvoicing">
A.IS_INVOICING = #isInvoicing#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="cancelAmount">
A.CANCEL_AMOUNT = #cancelAmount#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="unCancelAmount">
A.UN_CANCEL_AMOUNT = #unCancelAmount#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="isUnCancelAmount">
A.UN_CANCEL_AMOUNT > #isUnCancelAmount#
</isNotEmpty>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
A.ID asc
A.RECEIVE_DATE asc, A.ID asc
</isEmpty>
</dynamic>
</select>
......
$(function() {
var projRecordBox = __eiInfo.getBlock("proj_record_block_id").getMappedRows();
// 查询
$("#QUERY").on("click", function () {
query();
......@@ -15,41 +17,103 @@ $(function() {
columns: [{
field: "operator",
template: function (item) {
let template = '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="contractDetailFunc(' + item.id + ')">明细详情</a>';
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="fileDetailFunc(' + item.id + ')">附件详情</a>';
let template = '';
if (item.id){
template = '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="contractDetailFunc(' + item.id + ')">明细详情</a>';
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="fileDetailFunc(' + item.id + ')">附件详情</a>';
}
return template;
}
}, {
field: "projCode",
filter:function (option) {
let companyCode = option.model["companyCode"];
if (companyCode){
return _.filter(projRecordBox, function (item) {
return item["param1Field"] == companyCode;
})
}
return option.values;
}
}, {
field: "receiveDate",
defaultValue: function () {
return currShortDate();
}
},{
field: "signingDate",
defaultValue: function () {
return currShortDate();
}
}],
loadComplete: function (grid) {
$("#SELECT_BILL").on("click",addFunc);
//$("#BTN_UPDATE").on("click",updateFunc);
$("#SUBMIT").on("click",submitFunc);
$("#B_SAVE").on("click",saveFunc);
grid.dataSource.bind("change",function(e){
var item = e.items[0];
if(e.field === "taxPoints"){
if(item.thisSettlementTax && item.totalContractPriceIncluding){
if(item.taxPoints && item.totalContractPriceIncluding){
let thisSettlementAmount = item.totalContractPriceIncluding / (item.taxPoints / 100 + 1);
// 使用toFixed方法四舍五入到两位小数,并转换为数字
thisSettlementAmount = Number(thisSettlementAmount.toFixed(2));
thisSettlementAmount = Number(thisSettlementAmount.toFixed(3));
resultGrid.setCellValue(item,'thisSettlementAmount',thisSettlementAmount)
}
if(item.taxPoints && item.totalContractPriceIncluding){
if(item.thisSettlementAmount && item.totalContractPriceIncluding){
let thisSettlementTax = item.totalContractPriceIncluding-item.thisSettlementAmount;
// 使用toFixed方法四舍五入到两位小数,并转换为数字
thisSettlementTax = Number(thisSettlementTax.toFixed(2));
thisSettlementTax = Number(thisSettlementTax.toFixed(3));
resultGrid.setCellValue(item,'thisSettlementTax',thisSettlementTax)
}
}else if(e.field === "billNumber"){
if(isBlank(item.signingDate)){
resultGrid.setCellValue(item,'signingDate',currShortDate())
}
}else if(e.field === "totalContractPriceIncluding"){
if(item.taxPoints && item.totalContractPriceIncluding){
let thisSettlementAmount = item.totalContractPriceIncluding / (item.taxPoints / 100 + 1);
// 使用toFixed方法四舍五入到两位小数,并转换为数字
thisSettlementAmount = Number(thisSettlementAmount.toFixed(2));
resultGrid.setCellValue(item,'thisSettlementAmount',thisSettlementAmount)
}
if(item.thisSettlementAmount && item.totalContractPriceIncluding){
let thisSettlementTax = item.totalContractPriceIncluding-item.thisSettlementAmount;
// 使用toFixed方法四舍五入到两位小数,并转换为数字
thisSettlementTax = Number(thisSettlementTax.toFixed(3));
resultGrid.setCellValue(item,'thisSettlementTax',thisSettlementTax)
}
}
if (e.field === "projCode"){
let item = e.items[0];
for (let i = 0; i < projRecordBox.length; i++) {
if (projRecordBox[i]["valueField"] === item["projCode"]){
resultGrid.setCellValue(item,'projName',projRecordBox[i]["textField"]);
if (isBlank(item["companyCode"])){
resultGrid.setCellValue(item,'companyCode',projRecordBox[i]["param1Field"]);
resultGrid.setCellValue(item,'companyName',projRecordBox[i]["param2Field"]);
}
break;
}
}
if (isBlank(item["partyA"])){
loadChange(grid,e,"partyA");
}else if (isBlank(item["billNumber"])){
loadChange(grid,e,"billNumber");
}else if (!isPositiveNumber(item["totalContractPriceIncluding"])){
loadChange(grid,e,"totalContractPriceIncluding");
}
}
})
},
onSave : function (e) {
e.preventDefault();
let btnNode = $(this);
//禁用按钮
btnNode.attr("disabled", true);
saveFunc(btnNode);
},
onSuccess: function (e) {
if (e.eiInfo.extAttr.methodName == 'save' || e.eiInfo.extAttr.methodName == 'delete') {
query();
......@@ -58,14 +122,7 @@ $(function() {
}
window.document.addEventListener("keyup",function (event) {
if(event.keyCode === 13){
var grid = $("#ef_grid_result").data("kendoGrid");
// 回填
//grid.addRows(returnRows);
grid.closeCell();
}
})
downKeyUp();
});
$(window).load(function () {
......@@ -79,7 +136,6 @@ $(window).load(function () {
let query = function () {
resultGrid.dataSource.page(1);
}
/**
* 结算单选择
*/
......@@ -95,7 +151,7 @@ function addFunc() {
/**
* 保存
*/
function saveFunc() {
function saveFunc(btnNode) {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
......@@ -103,26 +159,42 @@ function saveFunc() {
}
let flag = true;
$.each(rows, function(index, item) {
let companyCode= item.get("companyCode");
let projCode= item.get("projCode");
let partyA= item.get("partyA");
let reviewStatus= item.get("reviewStatus");
let signingDate = item.get("signingDate");
if(isBlank(companyCode)){
message("勾选的第" + (index + 1) + "行公司不能为空!");
flag = false;
return false;
}
if(isBlank(projCode)){
message("勾选的第" + (index + 1) + "行项目不能为空!");
flag = false;
return false;
}
if(isBlank(partyA)){
message("勾选的第" + (index + 1) + "行供应商不能为空!")
return false;
}
if((reviewStatus === "1")){
message("数据已审核,");
message("勾选的第" + (index + 1) + "行数据已审核!");
flag = false;
return false;
}
if(isBlank(signingDate)){
message("数据未签单,");
if(isBlank(item['totalContractPriceIncluding']) || item['totalContractPriceIncluding'] <= 0){
message("勾选的第" + (index + 1) + "行发票总额必须是大于0的数字!");
flag = false;
return false;
}
});
if(flag) {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
var info = new EiInfo();
info.addBlock(JSUtils.checkedRows2Block("result"));
EiCommunicator.send("HGCW012", "save", info, {
onSuccess: function (ei) {
JSUtils.submitGridsData("result", "HGCW012", "save", true,
function (ei) {
if (ei.getStatus() >= 0) {
try {
query();
......@@ -137,14 +209,8 @@ function saveFunc() {
} else {
NotificationUtil(ei, "error");
}
},
onFail: function (ei) {
// 发生异常
NotificationUtil("操作失败,原因[" + ei + "]", "error");
}
});
//JSUtils.submitGridsData("result", "HPSC001", "save", true);
});
btnNode.attr("disabled", false);
}
});
}
......@@ -164,8 +230,8 @@ function contractDetailFunc(id) {
JSColorbox.open({
href: "HGCW012C?methodName=initLoad&inqu_status-0-mainId=" + id + "&efParentFormEname=HGCW012",
title: "<div style='text-align: center;'>明细详情</div>",
width: "90%",
height: "90%",
width: "70%",
height: "70%",
callbackName: windowCallback
});
}
......
......@@ -43,9 +43,21 @@
align="center" filter="contains" sort="true">
<EF:EFOptions blockId="roleCompany" textField="companyName" valueField="companyCode"/>
</EF:EFComboColumn>
<EF:EFColumn ename="partyA" cname="供应商名称" width="220" enable="false" readonly="true" align="center"/>
<EF:EFComboColumn ename="projCode" cname="项目名称" blockName="proj_record_block_id"
columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField"
maxLength="16" readonly="false" width="210" required="true"
align="center" filter="contains" sort="true">
</EF:EFComboColumn>
<EF:EFComboColumn ename="partyA" cname="供应商名称" blockName="sup_record_block_id"
columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField"
maxLength="16" readonly="false" width="210" required="true"
align="center" filter="contains" sort="true">
</EF:EFComboColumn>
<%--<EF:EFColumn ename="partyA" cname="供应商名称" width="220" enable="false" readonly="true" align="center"/>--%>
<EF:EFColumn ename="settlementNumber" cname="来源单号" width="200" enable="false" readonly="true" align="center"/>
<EF:EFComboColumn ename="billTybe" cname="票据类型" width="120" align="center" required="true"
<EF:EFComboColumn ename="billTybe" cname="票据类型" width="120" align="center" required="true" defaultValue="1"
columnTemplate="#=textField#" itemTemplate="#=textField#" enable="true" >
<EF:EFCodeOption codeName="hggp.cw.billTybe"/>
</EF:EFComboColumn>
......@@ -54,23 +66,23 @@
<EF:EFColumn ename="signingDate" cname="开票日期" width="120" enable="true" align="center" editType="date"
dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']" required="true" />
<EF:EFColumn ename="billNumber" cname="发票号" width="120" enable="true" readonly="false" align="center"/>
<EF:EFComboColumn ename="taxPoints" cname="税率" width="120" align="center" required="true"
<EF:EFComboColumn ename="taxPoints" cname="税率" width="80" align="center" required="true" defaultValue="13"
columnTemplate="#=textField#" itemTemplate="#=textField#" enable="true" >
<EF:EFCodeOption codeName="hggp.cw.taxPoints"/>
</EF:EFComboColumn>
<EF:EFColumn ename="thisSettlementAmount" cname="不含税金额" width="120" enable="false" format="{0:N3}" editType="text"
<EF:EFColumn ename="totalContractPriceIncluding" cname="发票总额" width="120" enable="true" format="{0:C3}" editType="text"
displayType="0.000" sort="true" align="right"
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/" maxLength="15" required="false"
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/" maxLength="15" required="true"
data-errorprompt="请输入数字,该值最大可设置15位整数和3位小数!"/>
<EF:EFColumn ename="thisSettlementTax" cname="税额" width="120" enable="false" format="{0:N3}" editType="text"
<EF:EFColumn ename="thisSettlementAmount" cname="不含税金额" width="120" enable="false" format="{0:C3}" editType="text"
displayType="0.000" sort="true" align="right"
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/" maxLength="15" required="false"
data-errorprompt="请输入数字,该值最大可设置15位整数和3位小数!"/>
<EF:EFColumn ename="totalContractPriceIncluding" cname="发票总额" width="120" enable="false" format="{0:N3}" editType="text"
<EF:EFColumn ename="thisSettlementTax" cname="税额" width="120" enable="false" format="{0:C3}" editType="text"
displayType="0.000" sort="true" align="right"
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/" maxLength="15" required="false"
data-errorprompt="请输入数字,该值最大可设置15位整数和3位小数!"/>
<EF:EFComboColumn ename="reviewStatus" cname="审批状态" width="100" align="center" required="true"
<EF:EFComboColumn ename="reviewStatus" cname="审批状态" width="100" align="center" required="true" defaultValue="0"
columnTemplate="#=textField#" itemTemplate="#=textField#" enable="false" >
<EF:EFCodeOption codeName="hggp.cw.reviewStatus"/>
</EF:EFComboColumn>
......
......@@ -236,7 +236,7 @@ $(function () {
field: "amount",
title: "收货金额",
headerTemplate: "<span style='color: '>收货金额 </span>",
format:"{0:N3}",
format:"{0:C3}",
align:"right",
enable: false,
locked: false
......@@ -245,7 +245,7 @@ $(function () {
field: "thisSettlementAmount",
title: "收票总额",
headerTemplate: "<span style='color: '>收票总额 </span>",
format:"{0:N3}",
format:"{0:C3}",
align:"right",
locked: false,
template: function (item) {
......@@ -334,35 +334,35 @@ $(function () {
field: "thisPriceTax",
title: "收票价税合计金额",
headerTemplate: "<span style='color: '>收票价税合计金额 </span>",
format:"{0:N2}",
format:"{0:C2}",
locked: false
},
{
field: "thisSettlementTax",
title: "收票税金",
headerTemplate: "<span style='color: '>收票税金 </span>",
format:"{0:N2}",
format:"{0:C2}",
locked: false
},
{
field: "thisSettlementAmount",
title: "收票金额",
headerTemplate: "<span style='color: '>收票金额 </span>",
format:"{0:N2}",
format:"{0:C2}",
locked: false
},
{
field: "thisAmount",
title: "本次收票金额",
headerTemplate: "<span style='color: '>本次收票金额 </span>",
format:"{0:N2}",
format:"{0:C2}",
locked: false
},
{
field: "remainingAmount",
title: "剩余收票金额",
headerTemplate: "<span style='color: '>剩余收票金额 </span>",
format:"{0:N2}",
format:"{0:C2}",
locked: false
}],
loadComplete: function(grid) {
......@@ -444,27 +444,27 @@ $(function () {
field: "totalContractPriceIncluding",
title: "收票价税合计金额",
headerTemplate: "<span style='color: '>收票价税合计金额 </span>",
format:"{0:N2}",
format:"{0:C2}",
locked: false
},
{
field: "valueAddedTax",
title: "收票税金",
headerTemplate: "<span style='color: '>收票税金 </span>",
format:"{0:N2}",
format:"{0:C2}",
locked: false
},
{
field: "totalContractPriceExcluding",
title: "收票金额",
headerTemplate: "<span style='color: '>收票金额 </span>",
format:"{0:N2}",
format:"{0:C2}",
locked: false
},{
field: "thisAmount",
title: "本次收票金额",
headerTemplate: "<span style='color: '>本次收票金额 </span>",
format:"{0:N2}",
format:"{0:C2}",
locked: false
}],
loadComplete: function(grid) {
......
......@@ -14,7 +14,7 @@
<EF:EFColumn ename="projName" cname="项目名称" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="partyA" cname="客户名称" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="settlementNumber" cname="来源单号" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="totalContractPriceIncluding" cname="付款总额" width="120" format="{0:N3}" align="center"/>
<EF:EFColumn ename="totalContractPriceIncluding" cname="付款总额" width="120" format="{0:C3}" align="center"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
......
......@@ -13,9 +13,9 @@
<EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn ename="companyName" cname="公司名称" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="projName" cname="项目名称" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="partyA" cname="客户名称" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="partyA" cname="供应商名称" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="settlementNumber" cname="来源单号" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="totalContractPriceIncluding" cname="收款总额" width="120" format="{0:N3}" align="center" enable="false" readonly="true"/>
<EF:EFColumn ename="totalContractPriceIncluding" cname="收款总额" width="120" format="{0:C3}" align="right" enable="false" readonly="true"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment