BIP传税码、税率、税金逻辑改动
This commit is contained in:
parent
2516d48809
commit
dd302c682d
|
@ -16,6 +16,7 @@ import kd.bos.entity.plugin.args.*;
|
||||||
import kd.bos.entity.validate.ErrorLevel;
|
import kd.bos.entity.validate.ErrorLevel;
|
||||||
import kd.bos.logging.Log;
|
import kd.bos.logging.Log;
|
||||||
import kd.bos.logging.LogFactory;
|
import kd.bos.logging.LogFactory;
|
||||||
|
import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.sdk.plugin.Plugin;
|
import kd.sdk.plugin.Plugin;
|
||||||
|
@ -412,53 +413,55 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
||||||
items.put("globaldebit","-"+bcsqje.toString());
|
items.put("globaldebit","-"+bcsqje.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
items.put("taxcodeid","");//税码编码 应该不用传;联调再看;
|
//items.put("taxcodeid","");//税码编码 应该不用传;联调再看;
|
||||||
if(isnotext){
|
if(isnotext){
|
||||||
//费用登记单的处理方式
|
//费用登记单的处理方式
|
||||||
BigDecimal rate = payrequestinfo.getBigDecimal("taxrate");//税率
|
this.setExpenseRegTaxFields(payrequestinfo,items,eventName);
|
||||||
if(rate == null){
|
// BigDecimal rate = payrequestinfo.getBigDecimal("taxrate");//税率
|
||||||
items.put("taxrate","0");//税率
|
// if(rate == null){
|
||||||
items.put("local_tax_de","0");//税额
|
// items.put("taxrate","0");//税率
|
||||||
}else{
|
// items.put("local_tax_de","0");//税额
|
||||||
items.put("taxrate",rate.toString());//税率
|
// }else{
|
||||||
items.put("local_tax_de",payrequestinfo.getBigDecimal("tax").toString());//税额
|
// items.put("taxrate",rate.toString());//税率
|
||||||
}
|
// items.put("local_tax_de",payrequestinfo.getBigDecimal("tax").toString());//税额
|
||||||
items.put("notax_de",payrequestinfo.getBigDecimal("notaxamt").toString());//贷方无税金额,除税金额
|
// }
|
||||||
items.put("local_notax_de",payrequestinfo.getBigDecimal("notaxamt").toString());//组织本币无税金额
|
// items.put("notax_de",payrequestinfo.getBigDecimal("notaxamt").toString());//贷方无税金额,除税金额
|
||||||
if("unaudit".equals(eventName)){
|
// items.put("local_notax_de",payrequestinfo.getBigDecimal("notaxamt").toString());//组织本币无税金额
|
||||||
//如果此时是反审核,则需要将金额置为负数
|
// if("unaudit".equals(eventName)){
|
||||||
items.put("local_tax_de","-"+items.getString("local_tax_de"));
|
// //如果此时是反审核,则需要将金额置为负数
|
||||||
items.put("notax_de","-"+items.getString("notax_de"));
|
// items.put("local_tax_de","-"+items.getString("local_tax_de"));
|
||||||
items.put("local_notax_de","-"+items.getString("local_notax_de"));
|
// items.put("notax_de","-"+items.getString("notax_de"));
|
||||||
}
|
// items.put("local_notax_de","-"+items.getString("local_notax_de"));
|
||||||
|
// }
|
||||||
}else{
|
}else{
|
||||||
//付款申请单的处理方式
|
//付款申请单的处理方式
|
||||||
BigDecimal invoicetax = payrequestinfo.getBigDecimal("invoicetax");//发票的税额
|
this.setPayApplyTaxFields(payrequestinfo,items,eventName,bcsqje);
|
||||||
if(invoicetax == null || invoicetax.compareTo(BigDecimal.ZERO) == 0){
|
// BigDecimal invoicetax = payrequestinfo.getBigDecimal("invoicetax");//发票的税额
|
||||||
items.put("taxrate","0");//税率
|
// if(invoicetax == null || invoicetax.compareTo(BigDecimal.ZERO) == 0){
|
||||||
items.put("local_tax_de","0");//税额
|
// items.put("taxrate","0");//税率
|
||||||
items.put("notax_de",bcsqje.toString());//贷方无税金额,除税金额
|
// items.put("local_tax_de","0");//税额
|
||||||
items.put("local_notax_de",bcsqje.toString());//组织本币无税金额
|
// items.put("notax_de",bcsqje.toString());//贷方无税金额,除税金额
|
||||||
if("unaudit".equals(eventName)){
|
// items.put("local_notax_de",bcsqje.toString());//组织本币无税金额
|
||||||
//如果此时是反审核,则需要将金额置为负数
|
// if("unaudit".equals(eventName)){
|
||||||
items.put("notax_de","-"+bcsqje.toString());
|
// //如果此时是反审核,则需要将金额置为负数
|
||||||
items.put("local_notax_de","-"+bcsqje.toString());//组织本币无税金额
|
// items.put("notax_de","-"+bcsqje.toString());
|
||||||
}
|
// items.put("local_notax_de","-"+bcsqje.toString());//组织本币无税金额
|
||||||
}else{
|
// }
|
||||||
//不含税金额
|
// }else{
|
||||||
BigDecimal notaxv = bcsqje.subtract(invoicetax);
|
// //不含税金额
|
||||||
//除法时,指定精度和舍入模式
|
// BigDecimal notaxv = bcsqje.subtract(invoicetax);
|
||||||
items.put("taxrate",invoicetax.divide(notaxv,10,RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).toString());//税率=税额/不含税 * 100
|
// //除法时,指定精度和舍入模式
|
||||||
items.put("local_tax_de",invoicetax.toString());//税额
|
// items.put("taxrate",invoicetax.divide(notaxv,10,RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).toString());//税率=税额/不含税 * 100
|
||||||
items.put("notax_de",notaxv.toString());//贷方无税金额,除税金额
|
// items.put("local_tax_de",invoicetax.toString());//税额
|
||||||
items.put("local_notax_de",notaxv.toString());//组织本币无税金额
|
// items.put("notax_de",notaxv.toString());//贷方无税金额,除税金额
|
||||||
if("unaudit".equals(eventName)){
|
// items.put("local_notax_de",notaxv.toString());//组织本币无税金额
|
||||||
//如果此时是反审核,则需要将金额置为负数
|
// if("unaudit".equals(eventName)){
|
||||||
items.put("local_tax_de","-"+items.getString("local_tax_de"));
|
// //如果此时是反审核,则需要将金额置为负数
|
||||||
items.put("notax_de","-"+items.getString("notax_de"));
|
// items.put("local_tax_de","-"+items.getString("local_tax_de"));
|
||||||
items.put("local_notax_de","-"+items.getString("local_notax_de"));
|
// items.put("notax_de","-"+items.getString("notax_de"));
|
||||||
}
|
// items.put("local_notax_de","-"+items.getString("local_notax_de"));
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
items.put("pu_org",companyDept[0]);//业务组织编码 同表头公司编码
|
items.put("pu_org",companyDept[0]);//业务组织编码 同表头公司编码
|
||||||
|
@ -632,4 +635,207 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置费用登记发票字段传BIP
|
||||||
|
* @param payRequestInfo 费用登记||费用申请 数据
|
||||||
|
* @param items json
|
||||||
|
*/
|
||||||
|
private void setExpenseRegTaxFields(DynamicObject payRequestInfo,JSONObject items,String eventName){
|
||||||
|
//发票分录
|
||||||
|
DynamicObjectCollection invoiceEntry = payRequestInfo.getDynamicObjectCollection("invoiceentry");
|
||||||
|
//无发票
|
||||||
|
if (invoiceEntry==null || invoiceEntry.size()==0){
|
||||||
|
items.put("taxrate","0");//税率
|
||||||
|
items.put("local_tax_de","0");//税额
|
||||||
|
items.put("taxcodeid","CN07");//税码
|
||||||
|
} else {
|
||||||
|
// 税额
|
||||||
|
BigDecimal taxAmount = BigDecimal.ZERO;
|
||||||
|
// 税率相关变量
|
||||||
|
BigDecimal commonTaxRate = null;
|
||||||
|
Long commonTaxRateId = null;
|
||||||
|
boolean hasDifferentTaxRates = false;
|
||||||
|
|
||||||
|
// 遍历发票
|
||||||
|
for (DynamicObject invoiceObj : invoiceEntry) {
|
||||||
|
DynamicObject invoiceBillF7 = invoiceObj.getDynamicObject("inventry_invoicebill");
|
||||||
|
if (invoiceBillF7!=null){
|
||||||
|
Object pkValue = invoiceBillF7.getPkValue();
|
||||||
|
DynamicObject invoiceBill = BusinessDataServiceHelper.loadSingle(pkValue, "recon_invoicebill");
|
||||||
|
if (invoiceBill != null) {
|
||||||
|
// 判断【发票登记-发票类型-名称】
|
||||||
|
DynamicObject invoice = invoiceBill.getDynamicObject("invoice");
|
||||||
|
if (invoice != null) {
|
||||||
|
String invoiceName = invoice.getString("name");
|
||||||
|
if (invoiceName != null && invoiceName.contains("专用")) {
|
||||||
|
// 发票登记-发票明细
|
||||||
|
DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry");
|
||||||
|
if (invoiceDetails != null && invoiceDetails.size() != 0) {
|
||||||
|
for (DynamicObject invoiceDetail : invoiceDetails) {
|
||||||
|
BigDecimal entryTax = invoiceDetail.getBigDecimal("entry_tax");
|
||||||
|
// 税额累加
|
||||||
|
taxAmount = taxAmount.add(entryTax);
|
||||||
|
|
||||||
|
// 处理税率
|
||||||
|
DynamicObject entryTaxRate = invoiceDetail.getDynamicObject("entry_taxrate");
|
||||||
|
if (entryTaxRate != null) {
|
||||||
|
Long currentTaxRateId = (Long) entryTaxRate.getPkValue();
|
||||||
|
BigDecimal currentTaxRate = entryTaxRate.getBigDecimal("taxrate");
|
||||||
|
|
||||||
|
// 第一次遇到税率,记录下来
|
||||||
|
if (commonTaxRateId == null) {
|
||||||
|
commonTaxRateId = currentTaxRateId;
|
||||||
|
commonTaxRate = currentTaxRate;
|
||||||
|
}
|
||||||
|
// 后续遇到不同的税率,标记为不一致
|
||||||
|
else if (!commonTaxRateId.equals(currentTaxRateId)) {
|
||||||
|
hasDifferentTaxRates = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置税额
|
||||||
|
items.put("local_tax_de", taxAmount.compareTo(BigDecimal.ZERO)==0 ? "0":taxAmount.toString());
|
||||||
|
|
||||||
|
// 设置税率值:所有税率相同则使用共同税率,不同则设为null
|
||||||
|
if (hasDifferentTaxRates) {
|
||||||
|
items.put("taxrate", "0");
|
||||||
|
} else if (commonTaxRate != null) {
|
||||||
|
// 设置税率
|
||||||
|
items.put("taxrate", commonTaxRate.compareTo(BigDecimal.ZERO)==0 ? "0":commonTaxRate.toString());
|
||||||
|
//获取映射表税码
|
||||||
|
QFilter qFilter = new QFilter("qeug_taxid.id", QCP.equals, commonTaxRateId);
|
||||||
|
DynamicObject bipTaxRateMap = BusinessDataServiceHelper.loadSingle("qeug_biptaxratemap", qFilter.toArray());
|
||||||
|
if (bipTaxRateMap!=null){
|
||||||
|
String number = bipTaxRateMap.getString("number");
|
||||||
|
if (number!=null){
|
||||||
|
// 设置税码
|
||||||
|
items.put("taxcodeid", number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
items.put("taxrate", "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
items.put("notax_de",payRequestInfo.getBigDecimal("notaxamt").toString());//贷方无税金额,除税金额
|
||||||
|
items.put("local_notax_de",payRequestInfo.getBigDecimal("notaxamt").toString());//组织本币无税金额
|
||||||
|
if("unaudit".equals(eventName)){
|
||||||
|
//如果此时是反审核,则需要将金额置为负数
|
||||||
|
items.put("local_tax_de","-"+items.getString("local_tax_de"));
|
||||||
|
items.put("notax_de","-"+items.getString("notax_de"));
|
||||||
|
items.put("local_notax_de","-"+items.getString("local_notax_de"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置【付款申请】发票字段传BIP
|
||||||
|
* @param payRequestInfo 费用登记||费用申请 数据
|
||||||
|
* @param items json
|
||||||
|
*/
|
||||||
|
private void setPayApplyTaxFields(DynamicObject payRequestInfo,JSONObject items,String eventName,BigDecimal bcsqje){
|
||||||
|
//发票分录
|
||||||
|
DynamicObjectCollection invoiceEntry = payRequestInfo.getDynamicObjectCollection("invoiceentry");
|
||||||
|
//无发票
|
||||||
|
if (invoiceEntry==null || invoiceEntry.size()==0){
|
||||||
|
items.put("taxrate","0");//税率
|
||||||
|
items.put("local_tax_de","0");//税额
|
||||||
|
items.put("taxcodeid","CN07");//税码
|
||||||
|
if("unaudit".equals(eventName)){
|
||||||
|
//如果此时是反审核,则需要将金额置为负数
|
||||||
|
items.put("notax_de","-"+bcsqje.toString());
|
||||||
|
items.put("local_notax_de","-"+bcsqje.toString());//组织本币无税金额
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 税额
|
||||||
|
BigDecimal taxAmount = BigDecimal.ZERO;
|
||||||
|
// 税率相关变量
|
||||||
|
BigDecimal commonTaxRate = null;
|
||||||
|
Long commonTaxRateId = null;
|
||||||
|
boolean hasDifferentTaxRates = false;
|
||||||
|
|
||||||
|
// 遍历发票
|
||||||
|
for (DynamicObject invoiceObj : invoiceEntry) {
|
||||||
|
DynamicObject invoiceBillF7 = invoiceObj.getDynamicObject("inventry_invoicebill");
|
||||||
|
if (invoiceBillF7!=null) {
|
||||||
|
Object pkValue = invoiceBillF7.getPkValue();
|
||||||
|
DynamicObject invoiceBill = BusinessDataServiceHelper.loadSingle(pkValue, "recon_invoicebill");
|
||||||
|
if (invoiceBill != null) {
|
||||||
|
// 判断【发票登记-发票类型-名称】
|
||||||
|
DynamicObject invoice = invoiceBill.getDynamicObject("invoice");
|
||||||
|
if (invoice != null) {
|
||||||
|
String invoiceName = invoice.getString("name");
|
||||||
|
if (invoiceName != null && invoiceName.contains("专用")) {
|
||||||
|
// 发票登记-发票明细
|
||||||
|
DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry");
|
||||||
|
if (invoiceDetails != null && invoiceDetails.size() != 0) {
|
||||||
|
for (DynamicObject invoiceDetail : invoiceDetails) {
|
||||||
|
BigDecimal entryTax = invoiceDetail.getBigDecimal("entry_tax");
|
||||||
|
// 税额累加
|
||||||
|
taxAmount = taxAmount.add(entryTax);
|
||||||
|
|
||||||
|
// 处理税率
|
||||||
|
DynamicObject entryTaxRate = invoiceDetail.getDynamicObject("entry_taxrate");
|
||||||
|
if (entryTaxRate != null) {
|
||||||
|
Long currentTaxRateId = (Long) entryTaxRate.getPkValue();
|
||||||
|
BigDecimal currentTaxRate = entryTaxRate.getBigDecimal("taxrate");
|
||||||
|
|
||||||
|
// 第一次遇到税率,记录下来
|
||||||
|
if (commonTaxRateId == null) {
|
||||||
|
commonTaxRateId = currentTaxRateId;
|
||||||
|
commonTaxRate = currentTaxRate;
|
||||||
|
}
|
||||||
|
// 后续遇到不同的税率,标记为不一致
|
||||||
|
else if (!commonTaxRateId.equals(currentTaxRateId)) {
|
||||||
|
hasDifferentTaxRates = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置税额
|
||||||
|
items.put("local_tax_de", taxAmount.compareTo(BigDecimal.ZERO)==0 ? "0":taxAmount.toString());
|
||||||
|
|
||||||
|
// 设置税率值:所有税率相同则使用共同税率,不同则设为null
|
||||||
|
if (hasDifferentTaxRates) {
|
||||||
|
items.put("taxrate", "0");
|
||||||
|
} else if (commonTaxRate != null) {
|
||||||
|
// 设置税率
|
||||||
|
items.put("taxrate", commonTaxRate.compareTo(BigDecimal.ZERO)==0 ? "0":commonTaxRate.toString());
|
||||||
|
//获取映射表税码
|
||||||
|
QFilter qFilter = new QFilter("qeug_taxid.id", QCP.equals, commonTaxRateId);
|
||||||
|
DynamicObject bipTaxRateMap = BusinessDataServiceHelper.loadSingle("qeug_biptaxratemap", qFilter.toArray());
|
||||||
|
if (bipTaxRateMap!=null){
|
||||||
|
String number = bipTaxRateMap.getString("number");
|
||||||
|
if (number!=null){
|
||||||
|
// 设置税码
|
||||||
|
items.put("taxcodeid", number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
items.put("taxrate", "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
items.put("notax_de",payRequestInfo.getBigDecimal("notaxamt").toString());//贷方无税金额,除税金额
|
||||||
|
items.put("local_notax_de",payRequestInfo.getBigDecimal("notaxamt").toString());//组织本币无税金额
|
||||||
|
if("unaudit".equals(eventName)){
|
||||||
|
//如果此时是反审核,则需要将金额置为负数
|
||||||
|
items.put("local_tax_de","-"+items.getString("local_tax_de"));
|
||||||
|
items.put("notax_de","-"+items.getString("notax_de"));
|
||||||
|
items.put("local_notax_de","-"+items.getString("local_notax_de"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue