Browse Source

增加采购验退,委外验收,委外验退单据批量更新价格后上传到平台,更新相关发票表主表的应付金额及税金合计相关数据

hejq 8 years ago
parent
commit
31268c8512

+ 11 - 3
src/main/java/com/uas/platform/b2b/dao/PurchaseApBillDao.java

@@ -6,6 +6,7 @@ import java.util.List;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.jpa.repository.query.Procedure;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
@@ -32,7 +33,6 @@ public interface PurchaseApBillDao extends JpaSpecificationExecutor<PurchaseApBi
 	/**
 	 * 卖家根据卖家UU号和下载状态和反过账状态获取客户反过账的客户应付发票
 	 * @param vendUU
-	 * @param sendStatus
 	 * @param nonPosting
 	 * @return
 	 */
@@ -40,7 +40,7 @@ public interface PurchaseApBillDao extends JpaSpecificationExecutor<PurchaseApBi
 	
 	/**
 	 * 根据截止日期获取(发票日期)
-	 * @param formDate
+	 * @param vendUU
 	 * @param endDate
 	 * @return
 	 */
@@ -50,7 +50,7 @@ public interface PurchaseApBillDao extends JpaSpecificationExecutor<PurchaseApBi
 	/**
 	 * 根据起始日期获取(发票日期)
 	 * @param formDate
-	 * @param endDate
+	 * @param vendUU
 	 * @return
 	 */
 	@Query("select p.id from PurchaseApBill p where p.vendUU=:vendUU and p.date >= :fromDate")
@@ -59,4 +59,12 @@ public interface PurchaseApBillDao extends JpaSpecificationExecutor<PurchaseApBi
 	@Query("select count(p) from PurchaseApBill p where p.vendUU=:vendUU")
 	public Long countByVendUU(@Param("vendUU") Long vendUU);
 
+	/**
+	 * 根据UU号和出入库单号更新发票主表的相关数据
+	 *
+	 * @param uu
+	 * @param inoutno
+	 */
+	@Procedure(procedureName = "refreshamountandtaxsum")
+    void refreshAmountAndTaxSum(Long uu, String inoutno);
 }

+ 4 - 1
src/main/java/com/uas/platform/b2b/service/impl/PurchaseApBillServiceImpl.java

@@ -171,11 +171,14 @@ public class PurchaseApBillServiceImpl implements PurchaseApBillService {
 	public void refreshPrice(List<ProdInOutRefreshPrice> prodInOuts) {
 		if(!CollectionUtils.isEmpty(prodInOuts)) {
 			for(ProdInOutRefreshPrice prod : prodInOuts) {
-				String sql = " merge into purc$apbillitem i using purc$apbill a on (i.papi_papid = a.pab_id and i.papi_pdinoutno = '" + prod.getPbu_inoutno() + "' and a.pad_enuu = " +SystemSession.getUser().getEnterprise().getUu() + ")" +
+				// 更新明细单价、税率
+				String sql = " merge into purc$apbillitem i using purc$apbill a on (i.papi_papid = a.pab_id and i.papi_pdinoutno = '" + prod.getPbu_inoutno() + "' and a.pad_enuu = " + SystemSession.getUser().getEnterprise().getUu() + ")" +
 						" when matched then update set i.papi_price = " + prod.getPbu_orderprice();
 				if(null != prod.getPbu_taxrate())
                     sql = sql + ",i.papi_taxrate = " + prod.getPbu_taxrate();
 				commonDao.getJdbcTemplate().update(sql);
+				// 更新主表的税金合计
+				purchaseApBillDao.refreshAmountAndTaxSum(SystemSession.getUser().getEnterprise().getUu(), prod.getPbu_inoutno());
 			}
 		}
 	}