领域驱动设计 用DDD重构会计凭证生成(下)( 五 )

depositPays = bill.getDepositPayPOList();if (!CollectionUtils.isEmpty(depositPays)) {for (DepositPayPO po : depositPays) {depositPayAmout = depositPayAmout.add(po.getDepositPayAmount());}if (depositPayAmout.compareTo(BigDecimal.ZERO) != 0) {amount = this.buildAdCreateAmountRequestVO(AmountTypeEnum.DEPOSIT_AMOUNT, depositPayAmout);amounts.add(amount);}}//支付金额if (bill.getPaymentAmount() != null && bill.getPaymentAmount().compareTo(BigDecimal.ZERO) != 0) {amount = this.buildAdCreateAmountRequestVO(AmountTypeEnum.PAY_AMOUNT, bill.getPaymentAmount());amounts.add(amount);}//押金抵扣金额List depositDeductions = bill.getDepositDeductionPOList();if (!CollectionUtils.isEmpty(depositDeductions)) {BigDecimal depositDeductionAmount = BigDecimal.ZERO;for (DepositDeductionPO po : depositDeductions) {depositDeductionAmount = depositDeductionAmount.add(po.getDeductionAmount());}if (depositDeductionAmount.compareTo(BigDecimal.ZERO) != 0) {amount = this.buildAdCreateAmountRequestVO(AmountTypeEnum.DEDUCTIBLE_AMOUNT, depositDeductionAmount);amounts.add(amount);}}adRequest.setAmounts(amounts);}/*** 关联方交易生成凭证 。* 关联方交易涉及到 境外 供应商 , 所以需要进行本位币转换 , 而且需要生成的4张凭证** @param bill* @param adRequest*/private void buildAdCreateRequestAmounts_RelatedParty(BillPO bill, AdCreateRequestVO adRequest) {// 构建生成凭证需要的amountsList amounts = new ArrayList();AdCreateAmountRequestVO amount;//单据金额if (bill.getTotalAmount() != null && bill.getTotalAmount().compareTo(BigDecimal.ZERO) != 0) {//单据金额-应付凭证BigDecimal totalAmt = bill.getTotalAmount();if (bill.getCcyId() != adRequest.getCompanyBaseCurrencyId()) {totalAmt = super.getBaseCurrencyAmount(adRequest.getAccDate(), bill.getTotalAmount(), adRequest.getCurrencyCode(), adRequest.getCompanyBaseCurrencyCode());}amounts.add(super.buildAdCreateAmountRequestVO(AmountTypeEnum.BILL_AMOUNT, totalAmt));//单据金额-应收凭证BigDecimal supplierTotalAmt = bill.getTotalAmount();if (bill.getCcyId() != adRequest.getSupplierBaseCurrencyId()) {supplierTotalAmt = super.getBaseCurrencyAmount(adRequest.getAccDate(), bill.getTotalAmount(), adRequest.getCurrencyCode(), adRequest.getSupplierBaseCurrencyCode());}amounts.add(super.buildAdCreateAmountRequestVO(AmountTypeEnum.RETURN_AMOUNT, supplierTotalAmt));}//核销金额List safeListPOList = bill.getSafeListPOList();if (!CollectionUtils.isEmpty(safeListPOList)) {BigDecimal safeAmount = BigDecimal.ZERO;for (SafeListPO po : safeListPOList) {safeAmount = safeAmount.add(po.getSafeAmount());}if (safeAmount.compareTo(BigDecimal.ZERO) != 0) {amount = this.buildAdCreateAmountRequestVO(AmountTypeEnum.SAFE_AMOUNT, safeAmount);amounts.add(amount);}}//押金金额存在时 支付金额需去掉押金金额BigDecimal depositPayAmout = BigDecimal.ZERO;List depositPays = bill.getDepositPayPOList();if (!CollectionUtils.isEmpty(depositPays)) {for (DepositPayPO po : depositPays) {depositPayAmout = depositPayAmout.add(po.getDepositPayAmount());}if (depositPayAmout.compareTo(BigDecimal.ZERO) != 0) {amount = this.buildAdCreateAmountRequestVO(AmountTypeEnum.DEPOSIT_AMOUNT, depositPayAmout);amounts.add(amount);}}//支付金额if (bill.getPaymentAmount() != null && bill.getPaymentAmount().compareTo(BigDecimal.ZERO) > 0) {//支付金额--付款凭证BigDecimal paymentAmount = bill.getPaymentAmount();if (bill.getCcyId() != adRequest.getCompanyBaseCurrencyId()) {paymentAmount = super.getBaseCurrencyAmount(adRequest.getAccDate(), bill.getPaymentAmount(), adRequest.getCurrencyCode(), adRequest.getCompanyBaseCurrencyCode());}amounts.add(this.buildAdCreateAmountRequestVO(AmountTypeEnum.PAY_AMOUNT, paymentAmount));//支付金额--收款凭证BigDecimal supplierPaymentAmount = bill.getPaymentAmount();if (bill.getCcyId() != adRequest.getSupplierBaseCurrencyId()) {supplierPaymentAmount = super.getBaseCurrencyAmount(adRequest.getAccDate(), bill.getPaymentAmount(), adRequest.getCurrencyCode(), adRequest.getSupplierBaseCurrencyCode());}amounts.add(super.buildAdCreateAmountRequestVO(AmountTypeEnum.COLLECT_AMOUNT, supplierPaymentAmount));}//押金抵扣金额List