fubin 2 anni fa
parent
commit
828106e591

+ 12 - 5
src/main/java/com/dk/mdm/mapper/mac/OtherPayableItemMapper.xml

@@ -36,7 +36,7 @@
     <sql id="Condition">
     <sql id="Condition">
         <where>
         <where>
             <if test="payableId != null and payableId != ''">
             <if test="payableId != null and payableId != ''">
-                AND t.payable_id = #{payableId}
+                AND t.payable_id = #{payableId}::uuid
             </if>
             </if>
             <if test="payableType != null and payableType != ''">
             <if test="payableType != null and payableType != ''">
                 AND t.payable_type = #{payableType}
                 AND t.payable_type = #{payableType}
@@ -69,9 +69,17 @@
 
 
     <!-- 查询表t_mac_other_payable_item,(条件查询+分页)列表 -->
     <!-- 查询表t_mac_other_payable_item,(条件查询+分页)列表 -->
     <select id="selectByCond" resultMap="BaseResultMapResponse">
     <select id="selectByCond" resultMap="BaseResultMapResponse">
-        SELECT
-        <include refid="Base_Column_List"/>
+        SELECT t.item_id,
+               t.payable_id,
+               t.payable_type,
+               tmda.data_value as "payableTypeName",
+               t.qty_payable,
+               t.amt_payable,
+               t.remarks,
+               t.flg_valid,
+               t.cp_id
         FROM dkic_b.t_mac_other_payable_item as t
         FROM dkic_b.t_mac_other_payable_item as t
+                 LEFT JOIN dkic_b.t_mst_dictionary_data as tmda ON tmda.data_id = t.payable_type
         <include refid="Condition"/>
         <include refid="Condition"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
             limit #{end} offset #{start}
@@ -80,8 +88,7 @@
 
 
     <!-- 查询表t_mac_other_payable_item,(条件查询)个数 -->
     <!-- 查询表t_mac_other_payable_item,(条件查询)个数 -->
     <select id="countByCond" resultType="Long">
     <select id="countByCond" resultType="Long">
-        SELECT
-        count(1)
+        SELECT count(1)
         FROM dkic_b.t_mac_other_payable_item as t
         FROM dkic_b.t_mac_other_payable_item as t
         <include refid="Condition"/>
         <include refid="Condition"/>
     </select>
     </select>

+ 81 - 16
src/main/java/com/dk/mdm/mapper/mac/OtherPayableMapper.xml

@@ -51,7 +51,7 @@
     <sql id="Condition">
     <sql id="Condition">
         <where>
         <where>
             <if test="payableNo != null and payableNo != ''">
             <if test="payableNo != null and payableNo != ''">
-                AND t.payable_no = #{payableNo}
+                AND t.payable_no LIKE concat('%',my_ex.likequery(#{payableNo}),'%')
             </if>
             </if>
             <if test="objectType != null and objectType != ''">
             <if test="objectType != null and objectType != ''">
                 AND t.object_type = #{objectType}
                 AND t.object_type = #{objectType}
@@ -83,15 +83,25 @@
             <if test="makeStaff != null and makeStaff != ''">
             <if test="makeStaff != null and makeStaff != ''">
                 AND t.make_staff = #{makeStaff}
                 AND t.make_staff = #{makeStaff}
             </if>
             </if>
-            <if test="makeTime != null">
-                AND t.make_time = #{makeTime}
-            </if>
-            <if test="flgValid != null">
-                AND t.flg_valid = #{flgValid}
-            </if>
             <if test="cpId != null">
             <if test="cpId != null">
                 AND t.cp_id = #{cpId}
                 AND t.cp_id = #{cpId}
             </if>
             </if>
+            <if test="supName != null and supName != ''">
+                AND supplier.sup_name LIKE concat('%',my_ex.likequery(#{supName}),'%')
+            </if>
+            <if test="orgIds != null and orgIds.size() > 0">
+                AND t.org_id  =any(#{orgIds, typeHandler=UuidListTypeHandler})
+            </if>
+            <if test="staffIds != null and staffIds.size() > 0">
+                AND t.staff_id  =any(#{staffIds, typeHandler=UuidListTypeHandler})
+            </if>
+            <if test="makeTimeStart != null and makeTimeEnd != null">
+                AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+                AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
+            </if>
+            <if test="flgValidList != null and flgValidList.size()>0">
+                AND t.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
+            </if>
         </where>
         </where>
     </sql>
     </sql>
 
 
@@ -105,9 +115,34 @@
 
 
     <!-- 查询表t_mac_other_payable,(条件查询+分页)列表 -->
     <!-- 查询表t_mac_other_payable,(条件查询+分页)列表 -->
     <select id="selectByCond" resultMap="BaseResultMapResponse">
     <select id="selectByCond" resultMap="BaseResultMapResponse">
-        SELECT
-        <include refid="Base_Column_List"/>
+        SELECT t.payable_id,
+               t.payable_no,
+               t.object_type,
+               sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "objectTypeName",
+               t.object_id,
+               supplier.sup_code    as "supCode",
+               supplier.sup_name    as "supName",
+               t.org_id,
+               tmo.org_name         as "orgName",
+               t.staff_id,
+               tms.staff_name       as "staffName",
+               t.sum_amt_payable,
+               t.acc_item_id,
+               t.acc_date,
+               t.remarks,
+               t.annex_paths,
+               t.make_staff,
+               makestaff.staff_name as "makeStaffName",
+               t.make_time,
+               t.flg_valid,
+               t.cp_id
         FROM dkic_b.t_mac_other_payable as t
         FROM dkic_b.t_mac_other_payable as t
+                 left join dkic_b.t_mst_supplier as supplier
+                           on supplier.sup_id = t.object_id and t.object_type in ('对象类型-供应商')
+                 left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
+                 left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
+                 left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
+                 left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.object_type
         <include refid="Condition"/>
         <include refid="Condition"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
             limit #{end} offset #{start}
@@ -116,18 +151,48 @@
 
 
     <!-- 查询表t_mac_other_payable,(条件查询)个数 -->
     <!-- 查询表t_mac_other_payable,(条件查询)个数 -->
     <select id="countByCond" resultType="Long">
     <select id="countByCond" resultType="Long">
-        SELECT
-        count(1)
+        SELECT count(1)
         FROM dkic_b.t_mac_other_payable as t
         FROM dkic_b.t_mac_other_payable as t
+                 left join dkic_b.t_mst_supplier as supplier
+                           on supplier.sup_id = t.object_id and t.object_type in ('对象类型-供应商')
+                 left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
+                 left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
+                 left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
+                 left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.object_type
         <include refid="Condition"/>
         <include refid="Condition"/>
     </select>
     </select>
 
 
     <!-- 根据主键查询表t_mac_other_payable的一行数据 -->
     <!-- 根据主键查询表t_mac_other_payable的一行数据 -->
-    <select id="selectById" resultMap="BaseResultMap">
-        SELECT
-        <include refid="Base_Column_List"/>
-        FROM dkic_b.t_mac_other_payable
-        WHERE payable_id = #{payableId}::uuid
+    <select id="selectById" resultMap="BaseResultMapResponse">
+        SELECT t.payable_id,
+               t.payable_no,
+               t.object_type,
+               sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "objectTypeName",
+               t.object_id,
+               supplier.sup_code    as "supCode",
+               supplier.sup_name    as "supName",
+               t.org_id,
+               tmo.org_name         as "orgName",
+               t.staff_id,
+               tms.staff_name       as "staffName",
+               t.sum_amt_payable,
+               t.acc_item_id,
+               t.acc_date,
+               t.remarks,
+               t.annex_paths,
+               t.make_staff,
+               makestaff.staff_name as "makeStaffName",
+               t.make_time,
+               t.flg_valid,
+               t.cp_id
+        FROM dkic_b.t_mac_other_payable as t
+                 left join dkic_b.t_mst_supplier as supplier
+                           on supplier.sup_id = t.object_id and t.object_type in ('对象类型-供应商')
+                 left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
+                 left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
+                 left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
+                 left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.object_type
+        WHERE payable_id = #{id}::uuid
     </select>
     </select>
 
 
     <!-- 根据主键锁定表t_mac_other_payable的一行数据 -->
     <!-- 根据主键锁定表t_mac_other_payable的一行数据 -->

+ 2 - 3
src/main/java/com/dk/mdm/mapper/mac/OtherReceivableItemMapper.xml

@@ -88,9 +88,8 @@
 
 
     <!-- 查询表t_mac_other_receivable_item,(条件查询)个数 -->
     <!-- 查询表t_mac_other_receivable_item,(条件查询)个数 -->
     <select id="countByCond" resultType="Long">
     <select id="countByCond" resultType="Long">
-        SELECT
-        count(1)
-        FROM dkic_b.t_mac_other_receivable_item
+        SELECT count(1)
+        FROM dkic_b.t_mac_other_receivable_item as t
         <include refid="Condition"/>
         <include refid="Condition"/>
     </select>
     </select>
 
 

+ 0 - 6
src/main/java/com/dk/mdm/mapper/mac/OtherReceivableMapper.xml

@@ -83,12 +83,6 @@
             <if test="makeStaff != null and makeStaff != ''">
             <if test="makeStaff != null and makeStaff != ''">
                 AND t.make_staff = #{makeStaff}
                 AND t.make_staff = #{makeStaff}
             </if>
             </if>
-            <if test="makeTime != null">
-                AND t.make_time = #{makeTime}
-            </if>
-            <if test="flgValid != null">
-                AND t.flg_valid = #{flgValid}
-            </if>
             <if test="cpId != null">
             <if test="cpId != null">
                 AND t.cp_id = #{cpId}
                 AND t.cp_id = #{cpId}
             </if>
             </if>

+ 2 - 0
src/main/java/com/dk/mdm/model/response/mac/OtherPayableItemResponse.java

@@ -100,6 +100,8 @@ public class OtherPayableItemResponse extends PageInfo<OtherPayableItemResponse>
     @ApiModelProperty(value = "企业ID")
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
     private Integer cpId;
 
 
+    @ApiModelProperty(value = "支出类别")
+    private String payableTypeName;
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 }
 }

+ 17 - 0
src/main/java/com/dk/mdm/model/response/mac/OtherPayableResponse.java

@@ -172,6 +172,23 @@ public class OtherPayableResponse extends PageInfo<OtherPayableResponse> impleme
     @ApiModelProperty(value = "企业ID")
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
     private Integer cpId;
 
 
+    @ApiModelProperty(value = "对象类型")
+    private String objectTypeName;
 
 
+    @ApiModelProperty(value = "组织名称")
+    private String orgName;
+
+    @ApiModelProperty(value = "员工姓名")
+    private String staffName;
+
+    @ApiModelProperty(value = "供应商编码")
+    private String supCode;
+
+    @ApiModelProperty(value = "供应商名称")
+    private String supName;
+
+    @ApiModelProperty(value = "制单员")
+    private String makeStaffName;
+    
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 }
 }

+ 61 - 11
src/main/java/com/dk/mdm/service/mac/AccountService.java

@@ -11,6 +11,7 @@ import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.mapper.ivt.InboundMapper;
 import com.dk.mdm.mapper.ivt.InboundMapper;
 import com.dk.mdm.mapper.ivt.OutboundMapper;
 import com.dk.mdm.mapper.ivt.OutboundMapper;
 import com.dk.mdm.mapper.mac.AccountItemMapper;
 import com.dk.mdm.mapper.mac.AccountItemMapper;
+import com.dk.mdm.mapper.mac.OtherPayableMapper;
 import com.dk.mdm.mapper.mac.OtherReceivableMapper;
 import com.dk.mdm.mapper.mac.OtherReceivableMapper;
 import com.dk.mdm.mapper.mst.MoneyAccountItemMapper;
 import com.dk.mdm.mapper.mst.MoneyAccountItemMapper;
 import com.dk.mdm.model.pojo.ivt.Inbound;
 import com.dk.mdm.model.pojo.ivt.Inbound;
@@ -20,6 +21,7 @@ import com.dk.mdm.mapper.mac.AccountMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.pojo.mac.AccountItem;
 import com.dk.mdm.model.pojo.mac.AccountItem;
+import com.dk.mdm.model.pojo.mac.OtherPayable;
 import com.dk.mdm.model.pojo.mac.OtherReceivable;
 import com.dk.mdm.model.pojo.mac.OtherReceivable;
 import com.dk.mdm.model.pojo.mst.MoneyAccount;
 import com.dk.mdm.model.pojo.mst.MoneyAccount;
 import com.dk.mdm.model.query.mac.AccountItemQuery;
 import com.dk.mdm.model.query.mac.AccountItemQuery;
@@ -70,6 +72,9 @@ public class AccountService extends BaseService<Account> {
     @Autowired
     @Autowired
     private OtherReceivableMapper otherReceivableMapper;
     private OtherReceivableMapper otherReceivableMapper;
 
 
+    @Autowired
+    private OtherPayableMapper otherPayableMapper;
+
     /**
     /**
      * @desc : 查看来源单据,总单加明细
      * @desc : 查看来源单据,总单加明细
      * @author : 姜永辉
      * @author : 姜永辉
@@ -223,12 +228,12 @@ public class AccountService extends BaseService<Account> {
                     .setMakeStaff(outbound.getMakeStaff()).setCpId(outbound.getCpId());
                     .setMakeStaff(outbound.getMakeStaff()).setCpId(outbound.getCpId());
             accountItemMapper.insert(accountItemInsert);
             accountItemMapper.insert(accountItemInsert);
 
 
-            // 更新出库单上的账款明细Id
+            // 更新单上的账款明细Id
             LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
             LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(Outbound::getReceivableId, UUID.fromString(accountItemInsert.getItemId())).eq(Outbound::getOutId, UUID.fromString(invoiceId));
             updateWrapper.set(Outbound::getReceivableId, UUID.fromString(accountItemInsert.getItemId())).eq(Outbound::getOutId, UUID.fromString(invoiceId));
             outboundMapper.update(null, updateWrapper);
             outboundMapper.update(null, updateWrapper);
         }
         }
-        // 其收入单
+        // 其收入单
         else if ("t_mac_other_receivable".equals(biznisType)) {
         else if ("t_mac_other_receivable".equals(biznisType)) {
             OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
             OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
             objectId = otherReceivable.getObjectId();
             objectId = otherReceivable.getObjectId();
@@ -251,7 +256,7 @@ public class AccountService extends BaseService<Account> {
                     .setMakeStaff(otherReceivable.getMakeStaff()).setCpId(otherReceivable.getCpId());
                     .setMakeStaff(otherReceivable.getMakeStaff()).setCpId(otherReceivable.getCpId());
             accountItemMapper.insert(accountItemInsert);
             accountItemMapper.insert(accountItemInsert);
 
 
-            // 更新出库单上的账款明细Id
+            // 更新单上的账款明细Id
             LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
             LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(OtherReceivable::getAccItemId, UUID.fromString(accountItemInsert.getItemId())).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
             updateWrapper.set(OtherReceivable::getAccItemId, UUID.fromString(accountItemInsert.getItemId())).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
             otherReceivableMapper.update(null, updateWrapper);
             otherReceivableMapper.update(null, updateWrapper);
@@ -292,12 +297,12 @@ public class AccountService extends BaseService<Account> {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
             }
             }
 
 
-            // 将出库单上的账款明细Id更为null
+            // 将单上的账款明细Id更为null
             LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
             LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(Outbound::getReceivableId, null).eq(Outbound::getOutId, UUID.fromString(invoiceId));
             updateWrapper.set(Outbound::getReceivableId, null).eq(Outbound::getOutId, UUID.fromString(invoiceId));
             outboundMapper.update(null, updateWrapper);
             outboundMapper.update(null, updateWrapper);
         }
         }
-        // 其收入单
+        // 其收入单
         else if ("t_mac_other_receivable".equals(biznisType)) {
         else if ("t_mac_other_receivable".equals(biznisType)) {
             OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
             OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
             objectId = otherReceivable.getObjectId();
             objectId = otherReceivable.getObjectId();
@@ -313,7 +318,7 @@ public class AccountService extends BaseService<Account> {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
             }
             }
 
 
-            // 更新出库单上的账款明细Id
+            // 更新单上的账款明细Id
             LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
             LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(OtherReceivable::getAccItemId, null).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
             updateWrapper.set(OtherReceivable::getAccItemId, null).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
             otherReceivableMapper.update(null, updateWrapper);
             otherReceivableMapper.update(null, updateWrapper);
@@ -363,12 +368,38 @@ public class AccountService extends BaseService<Account> {
                     .setMakeStaff(inbound.getMakeStaff()).setCpId(inbound.getCpId());
                     .setMakeStaff(inbound.getMakeStaff()).setCpId(inbound.getCpId());
             accountItemMapper.insert(accountItemInsert);
             accountItemMapper.insert(accountItemInsert);
 
 
-            // 更新出库单上的账款明细Id
+            // 更新单上的账款明细Id
             LambdaUpdateWrapper<Inbound> updateWrapper = new LambdaUpdateWrapper<>();
             LambdaUpdateWrapper<Inbound> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(Inbound::getReceivableId, UUID.fromString(accountItemInsert.getItemId())).eq(Inbound::getIntoId, UUID.fromString(invoiceId));
             updateWrapper.set(Inbound::getReceivableId, UUID.fromString(accountItemInsert.getItemId())).eq(Inbound::getIntoId, UUID.fromString(invoiceId));
             inboundMapper.update(null, updateWrapper);
             inboundMapper.update(null, updateWrapper);
-        } else if ("t_mac_outlay".equals(biznisType)) {
-            // 其它支出单 todo
+        }
+        // 其他支出单
+        else if ("t_mac_other_payable".equals(biznisType)) {
+            OtherPayable otherPayable = otherPayableMapper.selectByIdForUpdate(invoiceId);
+            objectId = otherPayable.getObjectId();
+
+            // 当前单据已经记账
+            if (otherPayable.getAccItemId() != null) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISACC.getMessage());
+            }
+            // 账务日期不能为空
+            if (otherPayable.getAccDate() == null) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ACC_DATE_ISNULL.getMessage());
+            }
+
+            // 插入账款明细
+            accountItemInsert.setAccItemType(Constant.accItemType.YING_SHOU.getName())
+                    .setObjectId(objectId).setOrgId(otherPayable.getOrgId()).setStaffId(otherPayable.getStaffId())
+                    .setAccDate(otherPayable.getAccDate()).setRecStatus(Constant.recStatuse.QUE_DING.getName())
+                    .setAmtShould(otherPayable.getSumAmtPayable()).setAmtResidue(otherPayable.getSumAmtPayable())
+                    .setBiznisType(biznisType).setBiznisId(otherPayable.getPayableId()).setBiznisNo(otherPayable.getPayableNo())
+                    .setMakeStaff(otherPayable.getMakeStaff()).setCpId(otherPayable.getCpId());
+            accountItemMapper.insert(accountItemInsert);
+
+            // 更新源单上的账款明细Id
+            LambdaUpdateWrapper<OtherPayable> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.set(OtherPayable::getAccItemId, UUID.fromString(accountItemInsert.getItemId())).eq(OtherPayable::getPayableId, UUID.fromString(invoiceId));
+            otherPayableMapper.update(null, updateWrapper);
         }
         }
 
 
         // 更新账款总表上的总应收账款和总剩余应收
         // 更新账款总表上的总应收账款和总剩余应收
@@ -410,8 +441,27 @@ public class AccountService extends BaseService<Account> {
             LambdaUpdateWrapper<Inbound> updateWrapper = new LambdaUpdateWrapper<>();
             LambdaUpdateWrapper<Inbound> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(Inbound::getReceivableId, null).eq(Inbound::getIntoId, UUID.fromString(invoiceId));
             updateWrapper.set(Inbound::getReceivableId, null).eq(Inbound::getIntoId, UUID.fromString(invoiceId));
             inboundMapper.update(null, updateWrapper);
             inboundMapper.update(null, updateWrapper);
-        } else if ("t_mac_outlay".equals(biznisType)) {
-            // 其它支出单 todo
+        } 
+        // 其他支出单
+        else if ("t_mac_other_payable".equals(biznisType)) {
+            OtherPayable otherPayable = otherPayableMapper.selectByIdForUpdate(invoiceId);
+            objectId = otherPayable.getObjectId();
+
+            // 当前单据已经记账
+            if (otherPayable.getAccItemId() == null) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISREVERSE.getMessage());
+            }
+
+            accountItemForUpdate = accountItemMapper.selectByIdForUpdate(otherPayable.getAccItemId());
+            // 如果核销金额不为0,说明当前单据已核销
+            if (accountItemForUpdate.getAmtHandle().compareTo(BigDecimal.ZERO) != 0) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
+            }
+
+            // 更新源单上的账款明细Id
+            LambdaUpdateWrapper<OtherPayable> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.set(OtherPayable::getAccItemId, null).eq(OtherPayable::getPayableId, UUID.fromString(invoiceId));
+            otherPayableMapper.update(null, updateWrapper);
         }
         }
 
 
         // 删除账款明细
         // 删除账款明细

+ 6 - 6
src/main/java/com/dk/mdm/service/mac/OtherPayableService.java

@@ -104,9 +104,9 @@ public class OtherPayableService extends BaseService<OtherPayable> {
 	public ResponseResultVO<?> insert(OtherPayableVO otherPayableVO) {
 	public ResponseResultVO<?> insert(OtherPayableVO otherPayableVO) {
 
 
 		// 获取单号
 		// 获取单号
-		Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.ORDER.getName(), false);
+		Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERPAYABLE.getName(), false);
 		otherPayableVO.setPayableId(codeMap.get("outId").toString()).setPayableNo(codeMap.get("outNote").toString())
 		otherPayableVO.setPayableId(codeMap.get("outId").toString()).setPayableNo(codeMap.get("outNote").toString())
-				.setObjectType(Constant.ObjectType.CUS.getName());
+				.setObjectType(Constant.ObjectType.SUP.getName());
 		// 转化实体
 		// 转化实体
 		OtherPayable otherPayable = otherPayableConvert.convertToPo(otherPayableVO);
 		OtherPayable otherPayable = otherPayableConvert.convertToPo(otherPayableVO);
 		// 总单保存
 		// 总单保存
@@ -121,7 +121,7 @@ public class OtherPayableService extends BaseService<OtherPayable> {
 			}
 			}
 		}
 		}
 
 
-		// 应记账
+		// 应记账
 		accountService.accPayable(otherPayable.getPayableId(),"t_mac_other_payable");
 		accountService.accPayable(otherPayable.getPayableId(),"t_mac_other_payable");
 		return ResponseResultUtil.success();
 		return ResponseResultUtil.success();
 	}
 	}
@@ -141,7 +141,7 @@ public class OtherPayableService extends BaseService<OtherPayable> {
 		super.update(otherPayable, new UpdateWrapper<OtherPayable>().lambda().eq(OtherPayable::getPayableId,
 		super.update(otherPayable, new UpdateWrapper<OtherPayable>().lambda().eq(OtherPayable::getPayableId,
 				UUID.fromString(otherPayable.getPayableId())));
 				UUID.fromString(otherPayable.getPayableId())));
 
 
-		// 应反记账
+		// 应反记账
 		accountService.reversePayable(otherPayableVO.getPayableId(),"t_mac_other_payable");
 		accountService.reversePayable(otherPayableVO.getPayableId(),"t_mac_other_payable");
 
 
 		// 将之前的明细全部删除
 		// 将之前的明细全部删除
@@ -159,7 +159,7 @@ public class OtherPayableService extends BaseService<OtherPayable> {
 			}
 			}
 		}
 		}
 
 
-		// 应记账
+		// 应记账
 		accountService.accPayable(otherPayableVO.getPayableId(),"t_mac_other_payable");
 		accountService.accPayable(otherPayableVO.getPayableId(),"t_mac_other_payable");
 		return ResponseResultUtil.success();
 		return ResponseResultUtil.success();
 	}
 	}
@@ -193,7 +193,7 @@ public class OtherPayableService extends BaseService<OtherPayable> {
 		}
 		}
 		// 如果所在月份已结账,则不能作废 todo
 		// 如果所在月份已结账,则不能作废 todo
 
 
-		// 应反记账
+		// 应反记账
 		accountService.reversePayable(id,"t_mac_other_payable");
 		accountService.reversePayable(id,"t_mac_other_payable");
 
 
 		// 作废
 		// 作废

+ 1 - 1
src/main/java/com/dk/mdm/service/mac/OtherReceivableService.java

@@ -99,7 +99,7 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
 	public ResponseResultVO<?> insert(OtherReceivableVO otherReceivableVO) {
 	public ResponseResultVO<?> insert(OtherReceivableVO otherReceivableVO) {
 
 
 		// 获取单号
 		// 获取单号
-		Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.ORDER.getName(), false);
+		Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERRECEIVABLE.getName(), false);
 		otherReceivableVO.setReceivableId(codeMap.get("outId").toString()).setReceivableNo(codeMap.get("outNote").toString())
 		otherReceivableVO.setReceivableId(codeMap.get("outId").toString()).setReceivableNo(codeMap.get("outNote").toString())
 				.setObjectType(Constant.ObjectType.CUS.getName());
 				.setObjectType(Constant.ObjectType.CUS.getName());
 		// 转化实体
 		// 转化实体