src/main/java/com/ruoyi/account/bean/dto/financial/FinVoucherDto.java
@@ -1,6 +1,7 @@ package com.ruoyi.account.bean.dto.financial; import com.ruoyi.account.pojo.financial.FinVoucher; import com.ruoyi.basic.dto.StorageBlobDTO; import lombok.Data; import lombok.EqualsAndHashCode; @@ -17,4 +18,6 @@ * 凭证明细分录。 */ private List<FinVoucherEntryDto> entries; private List<StorageBlobDTO> storageBlobDTOs; } src/main/java/com/ruoyi/account/bean/vo/financial/FinLedgerRowVo.java
@@ -1,5 +1,6 @@ package com.ruoyi.account.bean.vo.financial; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import java.math.BigDecimal; @@ -9,6 +10,7 @@ * 科目账行数据返回对象。 */ @Data @JsonInclude(JsonInclude.Include.NON_NULL) public class FinLedgerRowVo { /** src/main/java/com/ruoyi/account/bean/vo/financial/FinVoucherDetailVo.java
@@ -2,6 +2,8 @@ import com.ruoyi.account.pojo.financial.FinVoucher; import com.ruoyi.account.pojo.financial.FinVoucherEntry; import com.ruoyi.basic.dto.StorageBlobDTO; import com.ruoyi.basic.dto.StorageBlobVO; import lombok.Data; import lombok.EqualsAndHashCode; @@ -18,4 +20,5 @@ * 凭证分录列表。 */ private List<FinVoucherEntry> entries; private List<StorageBlobVO> storageBlobVOList; } src/main/java/com/ruoyi/account/service/impl/financial/FinLedgerServiceImpl.java
@@ -41,7 +41,7 @@ if (startMonth.isAfter(endMonth)) { throw new ServiceException("开始月份不能大于结束月份"); } return buildLedgerRows(queryDto.getSubjectCode(), startMonth, endMonth, null, null); return Collections.singletonList(buildGeneralLedgerTotalRow(queryDto.getSubjectCode(), startMonth, endMonth)); } @Override @@ -117,6 +117,37 @@ return rows; } private FinLedgerRowVo buildGeneralLedgerTotalRow(String subjectCode, YearMonth startMonth, YearMonth endMonth) { LocalDate startDate = startMonth.atDay(1); LocalDate endDate = endMonth.atEndOfMonth(); List<FinLedgerEntryRecordVo> openingEntries = finVoucherEntryMapper.listPostedEntriesBefore( subjectCode, startDate, null, null ); BigDecimal openingBalance = calculateBalance(openingEntries); List<FinLedgerEntryRecordVo> currentPeriodEntries = finVoucherEntryMapper.listPostedEntries( subjectCode, startDate, endDate, null, null ); BigDecimal totalDebit = ZERO; BigDecimal totalCredit = ZERO; for (FinLedgerEntryRecordVo entry : currentPeriodEntries) { totalDebit = totalDebit.add(money(entry.getDebit())); totalCredit = totalCredit.add(money(entry.getCredit())); } BigDecimal endingBalance = openingBalance.add(totalDebit).subtract(totalCredit); FinLedgerRowVo totalRow = new FinLedgerRowVo(); totalRow.setRowType("yearly_total"); totalRow.setDate(endDate); totalRow.setDebit(money(totalDebit)); totalRow.setCredit(money(totalCredit)); totalRow.setBalance(money(endingBalance)); totalRow.setDirection(resolveDirection(endingBalance)); return totalRow; } private Map<YearMonth, List<FinLedgerEntryRecordVo>> groupEntriesByMonth(List<FinLedgerEntryRecordVo> entries) { Map<YearMonth, List<FinLedgerEntryRecordVo>> map = new LinkedHashMap<>(); for (FinLedgerEntryRecordVo entry : entries) { src/main/java/com/ruoyi/account/service/impl/financial/FinVoucherServiceImpl.java
@@ -15,6 +15,9 @@ import com.ruoyi.account.pojo.financial.FinVoucher; import com.ruoyi.account.pojo.financial.FinVoucherEntry; import com.ruoyi.account.service.financial.FinVoucherService; import com.ruoyi.basic.enums.ApplicationTypeEnum; import com.ruoyi.basic.enums.RecordTypeEnum; import com.ruoyi.basic.utils.FileUtil; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; import lombok.RequiredArgsConstructor; @@ -38,6 +41,7 @@ private final FinVoucherEntryMapper finVoucherEntryMapper; private final AccountSubjectMapper accountSubjectMapper; private final FileUtil fileUtil; @Override public IPage<FinVoucher> pageList(Page<FinVoucher> page, FinVoucherPageDto queryDto) { @@ -80,6 +84,8 @@ } save(voucher); saveEntries(voucher.getId(), validEntries); // 5. 保存销售台账附件 fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.FIN_VOUCHER, voucher.getId(), dto.getStorageBlobDTOs()); return true; } @@ -113,6 +119,7 @@ deleteWrapper.eq(FinVoucherEntry::getVoucherId, voucher.getId()); finVoucherEntryMapper.delete(deleteWrapper); saveEntries(voucher.getId(), validEntries); fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.FIN_VOUCHER, voucher.getId(), dto.getStorageBlobDTOs()); return true; } @@ -159,6 +166,7 @@ FinVoucherDetailVo vo = new FinVoucherDetailVo(); BeanUtils.copyProperties(voucher, vo); vo.setEntries(entries); vo.setStorageBlobVOList(fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(RecordTypeEnum.FIN_VOUCHER, id)); return vo; } src/main/java/com/ruoyi/basic/enums/RecordTypeEnum.java
@@ -204,6 +204,7 @@ SALES_REFUND_AMOUNT_ORDER("sales_refund_amount_order"), SALES_RECEIPT_RETURN("sales_receipt_return"), ACCOUNT_EXPENSE("account_expense"), FIN_VOUCHER("fin_voucher"), ACCOUNT_FILE("account_file"); private final String type; src/main/resources/application-dev.yml
@@ -260,7 +260,7 @@ upload-dir: D:/ruoyi/prod/uploads # 正式目录 后期删除 path: D:/ruoyi/prod/uploads # 上传目录 urlPrefix: /common # 链接前缀 domain: http://127.0.0.1:7005 # 域名前缀 domain: http://127.0.0.1:7006 # 域名前缀 expired: 120 # 过期时间(单位:分钟) useLimit: 10 # 使用次数 compress: true # 是否压缩