From 0da945da9f19f45d849fe8b14dc06bb59c5e4283 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期五, 22 五月 2026 14:36:24 +0800
Subject: [PATCH] feat(purchase): 完善采购报表及增值税比对功能

---
 src/main/resources/mapper/account/AccountStatementMapper.xml |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/account/AccountStatementMapper.xml b/src/main/resources/mapper/account/AccountStatementMapper.xml
index 331c61b..32b1621 100644
--- a/src/main/resources/mapper/account/AccountStatementMapper.xml
+++ b/src/main/resources/mapper/account/AccountStatementMapper.xml
@@ -40,4 +40,39 @@
             </if>
     ORDER BY lj.statement_month DESC
     </select>
+    <select id="selectVatDtoPage" resultType="com.ruoyi.purchase.dto.VatDto">
+    SELECT
+        month,
+        jTaxAmount,
+        xTaxAmount,
+        (jTaxAmount - xTaxAmount) AS taxAmount
+    FROM (
+        SELECT
+            month,
+            SUM(IF(type = 'purchase', tax_price, 0)) AS xTaxAmount,
+            SUM(IF(type = 'sales', tax_price, 0)) AS jTaxAmount
+        FROM (
+            SELECT
+                DATE_FORMAT(issue_date, '%Y-%m') AS month,
+                tax_price,
+                'sales' AS type
+            FROM account_sales_invoice
+            WHERE status != 1
+            UNION ALL
+            SELECT
+                DATE_FORMAT(issue_date, '%Y-%m') AS month,
+                tax_price,
+                'purchase' AS type
+            FROM account_purchase_invoice
+            WHERE status != 1
+        ) AS all_data
+    GROUP BY month
+    ) AS TT
+     <where>
+            <if test="month != null">
+                and TT.month = #{month}
+            </if>
+     </where>
+    ORDER BY TT.month
+    </select>
 </mapper>

--
Gitblit v1.9.3