Browse Source

加计扣除-研发支出辅助明细账

zhouli 9 months ago
parent
commit
5b77cf7f66

+ 3 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/dto/XmCostDetailsDTO.java

@@ -21,6 +21,9 @@ public class XmCostDetailsDTO implements Serializable {
 	@Schema(description = "租户id", hidden = true)
 	@Schema(description = "租户id", hidden = true)
 	private String tenantId;
 	private String tenantId;
 
 
+	@Schema(description = "支出类型,1:费用化,2:资本化")
+	private Integer type;
+
 	@Schema(description = "研发项目名称")
 	@Schema(description = "研发项目名称")
 	private String xmmc;
 	private String xmmc;
 
 

+ 30 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/vo/DeductionCostDetailVO.java

@@ -0,0 +1,30 @@
+package org.sky.scientific.pojo.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class DeductionCostDetailVO {
+
+	@Schema(description = "支出类型,1:费用化,2:资本化")
+	private Integer type;
+
+	@Schema(description = "项目id")
+	private Long xmId;
+
+	@Schema(description = "项目编号")
+	private String xmbh;
+
+	@Schema(description = "项目名称")
+	private String xmmc;
+
+	@Schema(description = "")
+	private List<DeductionCostItemVO> costList;
+
+}
+
+
+
+

+ 70 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/vo/DeductionCostItemVO.java

@@ -0,0 +1,70 @@
+package org.sky.scientific.pojo.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import org.sky.core.tool.utils.DateUtil;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class DeductionCostItemVO {
+
+	@Schema(description = "凭证日期")
+	@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
+	@JsonFormat(pattern = DateUtil.PATTERN_DATE)
+	private Date recordDate;
+
+	@Schema(description = "凭证字号")
+	private String voucherNumber;
+
+	@Schema(description = "摘要")
+	private String digest;
+
+	@Schema(description = "企业科目id")
+	private Long eSubjectId;
+
+	@Schema(description = "四级科目是否为加计扣除研发费用科目,1:是,0,否")
+	private int adSubjectEnable;
+
+	@Schema(description = "四级科目代码")
+	private String l4Code;
+
+	@Schema(description = "三级科目代码")
+	private String l3Code;
+
+	@Schema(description = "二级科目代码")
+	private String l2Code;
+
+	@Schema(description = "金额")
+	private BigDecimal amount;
+
+	@Schema(description = "账簿名称")
+	private String cashbook;
+
+	@Schema(description = "1、人员人工费用")
+	private Double ryrgfy;
+
+	@Schema(description = "2、直接投入费用")
+	private Double zjtrfy;
+
+	@Schema(description = "3、折旧费用")
+	private Double zjfy;
+
+	@Schema(description = "4、无形资产摊销")
+	private Double wxzctx;
+
+	@Schema(description = "5、新产品设计费等")
+	private Double xcpsjfd;
+
+	@Schema(description = "6、其他相关费用")
+	private Double qtxgfy;
+
+	@Schema(description = "7、委托境内机构或个人进行研发活动所发生的费用")
+	private Double wtjnjgfy;
+
+	@Schema(description = "8、委托境外机构进行研发活动所发生的费用")
+	private Double wtjwjgfy;
+}

+ 17 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/XmCostDetailsController.java

@@ -17,6 +17,7 @@ import org.sky.core.tool.api.R;
 import org.sky.core.tool.utils.Func;
 import org.sky.core.tool.utils.Func;
 import org.sky.scientific.pojo.dto.XmCostDetailsDTO;
 import org.sky.scientific.pojo.dto.XmCostDetailsDTO;
 import org.sky.scientific.pojo.entity.XmCostDetailsEntity;
 import org.sky.scientific.pojo.entity.XmCostDetailsEntity;
+import org.sky.scientific.pojo.vo.DeductionCostDetailVO;
 import org.sky.scientific.pojo.vo.FinanceCostDetailVO;
 import org.sky.scientific.pojo.vo.FinanceCostDetailVO;
 import org.sky.scientific.pojo.vo.FinanceCostSummary;
 import org.sky.scientific.pojo.vo.FinanceCostSummary;
 import org.sky.scientific.service.IXmCostDetailsService;
 import org.sky.scientific.service.IXmCostDetailsService;
@@ -104,5 +105,21 @@ public class XmCostDetailsController extends KdController {
 		return R.data(service.highTechCostSummary(Condition.getPage(query), dto));
 		return R.data(service.highTechCostSummary(Condition.getPage(query), dto));
 	}
 	}
 
 
+	@GetMapping("/deduction-list")
+	@ApiOperationSupport(order = 29)
+	@Operation(summary = "加计扣除-研发支出辅助明细账")
+	public R<List<DeductionCostDetailVO>> deductionCostDetail(XmCostDetailsDTO dto) {
+		return R.data(service.deductionCostDetail(dto));
+	}
+
+//	@GetMapping("/deduction-summary")
+//	@ApiOperationSupport(order = 30)
+//	@Operation(summary = "加计扣除-研发支出辅助汇总表")
+//	public R<IPage<FinanceCostSummary>>deductionCostSummary(Query query, XmCostDetailsDTO dto) {
+//		return R.data(service.highTechCostSummary(Condition.getPage(query), dto));
+//	}
+
+
+
 
 
 }
 }

+ 9 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmCostDetailsMapper.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
 import org.sky.core.tenant.annotation.TenantIgnore;
 import org.sky.core.tenant.annotation.TenantIgnore;
 import org.sky.scientific.pojo.dto.XmCostDetailsDTO;
 import org.sky.scientific.pojo.dto.XmCostDetailsDTO;
 import org.sky.scientific.pojo.entity.XmCostDetailsEntity;
 import org.sky.scientific.pojo.entity.XmCostDetailsEntity;
+import org.sky.scientific.pojo.vo.DeductionCostDetailVO;
 import org.sky.scientific.pojo.vo.FinanceCostDetailVO;
 import org.sky.scientific.pojo.vo.FinanceCostDetailVO;
 import org.sky.scientific.pojo.vo.FinanceCostItemVO;
 import org.sky.scientific.pojo.vo.FinanceCostItemVO;
 
 
@@ -58,4 +59,12 @@ public interface XmCostDetailsMapper extends BaseMapper<XmCostDetailsEntity> {
 
 
 	@TenantIgnore
 	@TenantIgnore
 	List<FinanceCostItemVO> selectCostItemByCondition(@Param("yearAndMonth") String yearAndMonth, @Param("xmId") Long xmId);
 	List<FinanceCostItemVO> selectCostItemByCondition(@Param("yearAndMonth") String yearAndMonth, @Param("xmId") Long xmId);
+
+	/**
+	 * 加计扣除-研发支出辅助明细账
+	 * @param dto
+	 * @return
+	 */
+	@TenantIgnore
+    List<DeductionCostDetailVO> deductionCostDetail(XmCostDetailsDTO dto);
 }
 }

+ 47 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmCostDetailsMapper.xml

@@ -166,4 +166,51 @@
         where kxcd.xm_id = #{xmId} and year_and_month between concat(left(#{yearAndMonth},4),'01') and #{yearAndMonth}
         where kxcd.xm_id = #{xmId} and year_and_month between concat(left(#{yearAndMonth},4),'01') and #{yearAndMonth}
     </select>
     </select>
 
 
+    <resultMap id="DeductionCostDetailVO" type="org.sky.scientific.pojo.vo.DeductionCostDetailVO">
+        <result column="xm_id" property="xmId"/>
+        <result column="XMBH" property="xmbh"/>
+        <result column="XMMC" property="xmmc"/>
+
+        <collection property="costList" ofType="org.sky.scientific.pojo.vo.DeductionCostItemVO">
+            <result column="record_date" property="recordDate"/>
+            <result column="voucher_number" property="voucherNumber"/>
+            <result column="digest" property="digest"/>
+            <result column="e_subject_id" property="eSubjectId"/>
+            <result column="ad_subject_enable" property="adSubjectEnable"/>
+            <result column="L4Code" property="l4Code"/>
+            <result column="L3Code" property="l3Code"/>
+            <result column="L2Code" property="l2Code"/>
+
+            <result column="amount" property="amount"/>
+            <result column="cashbook" property="cashbook"/>
+        </collection>
+    </resultMap>
+    <select id="deductionCostDetail" resultMap="DeductionCostDetailVO">
+        SELECT
+            xm.id as XMID, xm.XMBH,xm.XMMC,kxcd.record_date,kxcd.voucher_number,kxcd.digest,kxcd.amount,kxcd.cashbook,
+            kxcd.e_subject_id, s.ad_subject_enable,s.L4Code, s.L3Code, s.L2Code
+        FROM kd_xm_cost_details kxcd
+        LEFT JOIN
+        (
+            SELECT se.id,sub4.code as L4Code, sub4.ad_subject_enable,sub3.code as L3Code, sub2.code as L2Code
+            FROM kd_subject_enterprise se
+            LEFT JOIN kd_subject sub4 on sub4.id = se.subject_id
+            LEFT JOIN kd_subject sub3 on sub3.id = sub4.parent_id
+            LEFT JOIN kd_subject sub2 on sub2.id = sub3.parent_id
+        )s ON s.id = kxcd.e_subject_id
+        LEFT JOIN
+        (
+            SELECT
+                xm.id, xm.XMBH,
+                COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMMC' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMMC) AS XMMC
+            FROM kd_xm xm
+            WHERE xm.is_deleted = 0
+        ) xm on xm.id = kxcd.xm_id
+        WHERE kxcd.tenant_id = #{tenantId} and kxcd.year_and_month between concat(left(#{yearAndMonth},4),'01') and #{yearAndMonth}
+        <if test="type==1">and s.L2Code = '530101'</if>
+        <if test="type==2">and s.L2Code = '530102'</if>
+        <if test="xmmc!=null and xmmc!=''">and xm.XMMC like concat('%',#{xmmc},'%')</if>
+        order by kxcd.record_date asc
+    </select>
+
 </mapper>
 </mapper>

+ 8 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/IXmCostDetailsService.java

@@ -6,6 +6,7 @@ import jakarta.servlet.http.HttpServletResponse;
 import org.sky.core.mp.base.BaseService;
 import org.sky.core.mp.base.BaseService;
 import org.sky.scientific.pojo.dto.XmCostDetailsDTO;
 import org.sky.scientific.pojo.dto.XmCostDetailsDTO;
 import org.sky.scientific.pojo.entity.XmCostDetailsEntity;
 import org.sky.scientific.pojo.entity.XmCostDetailsEntity;
+import org.sky.scientific.pojo.vo.DeductionCostDetailVO;
 import org.sky.scientific.pojo.vo.FinanceCostDetailVO;
 import org.sky.scientific.pojo.vo.FinanceCostDetailVO;
 import org.sky.scientific.pojo.vo.FinanceCostSummary;
 import org.sky.scientific.pojo.vo.FinanceCostSummary;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
@@ -87,4 +88,11 @@ public interface IXmCostDetailsService extends BaseService<XmCostDetailsEntity>
 	 * @return
 	 * @return
 	 */
 	 */
 	IPage<FinanceCostSummary> highTechCostSummary(IPage page, XmCostDetailsDTO dto);
 	IPage<FinanceCostSummary> highTechCostSummary(IPage page, XmCostDetailsDTO dto);
+
+	/**
+	 * 加计扣除-研发支出辅助明细账
+	 * @param dto
+	 * @return
+	 */
+	List<DeductionCostDetailVO> deductionCostDetail(XmCostDetailsDTO dto);
 }
 }

+ 89 - 4
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmCostDetailsServiceImpl.java

@@ -18,9 +18,7 @@ import org.sky.scientific.mapper.XmMapper;
 import org.sky.scientific.pojo.dto.XmCostDetailsDTO;
 import org.sky.scientific.pojo.dto.XmCostDetailsDTO;
 import org.sky.scientific.pojo.entity.SubjectEnterprise;
 import org.sky.scientific.pojo.entity.SubjectEnterprise;
 import org.sky.scientific.pojo.entity.XmCostDetailsEntity;
 import org.sky.scientific.pojo.entity.XmCostDetailsEntity;
-import org.sky.scientific.pojo.vo.FinanceCostDetailVO;
-import org.sky.scientific.pojo.vo.FinanceCostItemVO;
-import org.sky.scientific.pojo.vo.FinanceCostSummary;
+import org.sky.scientific.pojo.vo.*;
 import org.sky.scientific.service.IXmCostDetailsService;
 import org.sky.scientific.service.IXmCostDetailsService;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
@@ -333,7 +331,94 @@ public class XmCostDetailsServiceImpl extends BaseServiceImpl<XmCostDetailsMappe
 		return page.setRecords(summaryList);
 		return page.setRecords(summaryList);
 	}
 	}
 
 
-	public static void judgeDate(Date date, String yearAndMonth) {
+    @Override
+    public List<DeductionCostDetailVO> deductionCostDetail(XmCostDetailsDTO dto) {
+		if (Func.isBlank(dto.getYearAndMonth())) {
+			throw new ServiceException("参数yearAndMonth不能为空");
+		}
+		if(dto.getType()==null){
+			throw new ServiceException("参数type不能为空");
+		}
+		if(!Arrays.asList(1,2).contains(dto.getType())){
+			throw new ServiceException("参数type的值只能是1:费用化,2:资本化");
+		}
+		dto.setTenantId(SecureUtil.getTenantId());
+		List<DeductionCostDetailVO> list = baseMapper.deductionCostDetail(dto);
+		for (DeductionCostDetailVO tmp : list) {
+			List<DeductionCostItemVO> vos = tmp.getCostList();
+			for (DeductionCostItemVO vo : vos) {
+				if(vo.getAdSubjectEnable() == 0){
+					//四级科目 不是加计扣除研发费用科目,费用不归集
+					continue;
+				}
+				if(dto.getType()==1){
+					//费用化
+					if(Func.equals(vo.getL3Code(),"53010101")){
+						//人员人工费用
+						vo.setRyrgfy(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL3Code(),"53010102")){
+						//直接投入费用
+						vo.setZjtrfy(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL3Code(),"53010103")){
+						//折旧费用
+						vo.setZjfy(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL3Code(),"53010104")){
+						//无形资产摊销
+						vo.setWxzctx(vo.getAmount().doubleValue());
+					}else if(Arrays.asList("5301010501","5301010502","5301010602","5301010603").contains(vo.getL4Code())){
+						//新产品设计费等
+						//三级科目中的“设计费用”-新产品设计费,新工艺规程制定费;和"装备调试费用与试验费用"-新药研制的临床试验费,勘探开发的现场试验费;归集到新产品设计费等
+ 						vo.setXcpsjfd(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL3Code(),"53010108")){
+						//其他相关费用
+						vo.setQtxgfy(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL4Code(),"5301010701")){
+						//委托境内机构或个人进行研发活动所发生的费用
+						vo.setWtjnjgfy(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL4Code(),"5301010702")){
+						//委托境外机构进行研发活动所发生的费用
+						vo.setWtjwjgfy(vo.getAmount().doubleValue());
+					}else {
+						throw new ServiceException("费用归集出错啦");
+					}
+				}else if(dto.getType() == 2){
+					//资本化
+					if(Func.equals(vo.getL3Code(),"53010201")){
+						//人员人工费用
+						vo.setRyrgfy(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL3Code(),"53010202")){
+						//直接投入费用
+						vo.setZjtrfy(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL3Code(),"53010203")){
+						//折旧费用
+						vo.setZjfy(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL3Code(),"53010204")){
+						//无形资产摊销
+						vo.setWxzctx(vo.getAmount().doubleValue());
+					}else if(Arrays.asList("5301020501","5301020502","5301020602","5301020603").contains(vo.getL4Code())){
+						//新产品设计费等
+						//三级科目中的“设计费用”-新产品设计费,新工艺规程制定费;和"装备调试费用与试验费用"-新药研制的临床试验费,勘探开发的现场试验费;归集到新产品设计费等
+						vo.setXcpsjfd(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL3Code(),"53010208")){
+						//其他相关费用
+						vo.setQtxgfy(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL4Code(),"5301020701")){
+						//委托境内机构或个人进行研发活动所发生的费用
+						vo.setWtjnjgfy(vo.getAmount().doubleValue());
+					}else if(Func.equals(vo.getL4Code(),"5301020702")){
+						//委托境外机构进行研发活动所发生的费用
+						vo.setWtjwjgfy(vo.getAmount().doubleValue());
+					}else {
+						throw new ServiceException("费用归集出错啦");
+					}
+				}
+
+			}
+		}
+		return list;
+    }
+
+    public static void judgeDate(Date date, String yearAndMonth) {
 		//日期,必须时当月日期
 		//日期,必须时当月日期
 		if (date != null) {
 		if (date != null) {
 			String format = DateUtil.format(date, DateUtil.PATTERN_YYYYMM);
 			String format = DateUtil.format(date, DateUtil.PATTERN_YYYYMM);