From e1b550e2dcf6d71a863d206d4a88fec6588a6fd0 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期一, 23 六月 2025 10:20:22 +0800
Subject: [PATCH] 2025-06-23 【销售台账】   增加客户合同号、销售合同号、项目名称模糊查询 增加客户名称、客户合同号、项目名称查询,不显示待回款为0,默认为打钩。 销售管理】-【回款流水】,增加合同号、项目名称列查询,增加客户名称、项目名称、合同号查询条件。 【销售管理】-【回款登记】,增加导出功能

---
 src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 108 insertions(+), 9 deletions(-)

diff --git a/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml b/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml
index 5d3b24c..fe0b44c 100644
--- a/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml
+++ b/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml
@@ -30,15 +30,114 @@
         </where>
     </select>
     <select id="listVat" resultType="com.ruoyi.purchase.dto.VatDto">
-            SELECT
-                DATE_FORMAT(il.invoice_date, '%Y-%m') AS month,
-                ROUND(SUM(pr.invoice_amount - pr.invoice_amount / (1 + pr.tax_rate / 100)), 2) AS tax_amount
-            FROM invoice_ledger il
-                     LEFT JOIN invoice_registration_product pr ON pr.id = il.invoice_registration_product_id
-            WHERE il.invoice_no IS NOT NULL
-              AND invoice_type = '澧炰笓绁�'
-            GROUP BY DATE_FORMAT(il.invoice_date, '%Y-%m')
-            ORDER BY month;
+        select *
+        from (SELECT
+                  COALESCE(a1.month, a2.month) AS month,
+                  IFNULL(a1.tax_amount, 0) AS j_tax_amount,
+                  IFNULL(a2.x_tax_amount, 0) AS x_tax_amount
+              FROM (
+                       -- 绗竴涓煡璇細鏉ヨ嚜 invoice_ledger 鐨勭◣棰�
+                       SELECT
+                           DATE_FORMAT(il.invoice_date, '%Y-%m') AS month,
+                           ROUND(SUM(pr.invoice_amount - pr.invoice_amount / (1 + pr.tax_rate / 100)), 2) AS tax_amount
+                       FROM invoice_ledger il
+                                LEFT JOIN invoice_registration_product pr ON pr.id = il.invoice_registration_product_id
+                       WHERE il.invoice_no IS NOT NULL
+                         AND invoice_type = '澧炰笓绁�'
+                       GROUP BY DATE_FORMAT(il.invoice_date, '%Y-%m')
+                   ) a1
+                       LEFT JOIN (
+                  -- 绗簩涓煡璇細鏉ヨ嚜 ticket_registration 鐨勭◣棰�
+                  SELECT
+                      DATE_FORMAT(a.issue_date, '%Y-%m') AS month,
+                      SUM(a.invoice_amount) AS x_tax_amount
+                  FROM (
+                           SELECT DISTINCT pr.id,
+                                           tr.issue_date,
+                                           ROUND(pr.tickets_amount / (1 + pr.tax_rate / 100), 2) AS un_tickets_price,
+                                           ROUND(pr.tickets_amount - pr.tickets_amount / (1 + pr.tax_rate / 100), 2) AS invoice_amount
+                           FROM product_record pr
+                                    LEFT JOIN purchase_ledger pl ON pl.id = pr.purchase_ledger_id
+                                    LEFT JOIN sales_ledger sl ON sl.id = pl.sales_ledger_id
+                                    LEFT JOIN ticket_registration tr ON tr.purchase_ledger_id = pl.id
+                                    LEFT JOIN product_model pm ON pm.id = pr.product_model_id
+                           WHERE type = 2
+                             AND tr.invoice_number IS NOT NULL
+                       ) a
+                  GROUP BY DATE_FORMAT(a.issue_date, '%Y-%m')
+              ) a2 ON a1.month = a2.month
+
+              UNION ALL
+
+              SELECT
+                  COALESCE(a1.month, a2.month) AS month,
+                  IFNULL(a1.tax_amount, 0) AS tax_amount,
+                  IFNULL(a2.x_tax_amount, 0) AS x_tax_amount
+              FROM (
+                       -- 绗簩涓煡璇細鏉ヨ嚜 ticket_registration 鐨勭◣棰濓紙鍙嶈繃鏉ヨˉ鍏ㄦ病鏈夊尮閰嶅埌鐨勶級
+                       SELECT
+                           DATE_FORMAT(a.issue_date, '%Y-%m') AS month,
+                           SUM(a.invoice_amount) AS x_tax_amount
+                       FROM (
+                                SELECT DISTINCT pr.id,
+                                                tr.issue_date,
+                                                ROUND(pr.tickets_amount / (1 + pr.tax_rate / 100), 2) AS un_tickets_price,
+                                                ROUND(pr.tickets_amount - pr.tickets_amount / (1 + pr.tax_rate / 100), 2) AS invoice_amount
+                                FROM product_record pr
+                                         LEFT JOIN purchase_ledger pl ON pl.id = pr.purchase_ledger_id
+                                         LEFT JOIN sales_ledger sl ON sl.id = pl.sales_ledger_id
+                                         LEFT JOIN ticket_registration tr ON tr.purchase_ledger_id = pl.id
+                                         LEFT JOIN product_model pm ON pm.id = pr.product_model_id
+                                WHERE type = 2
+                                  AND tr.invoice_number IS NOT NULL
+                            ) a
+                       GROUP BY DATE_FORMAT(a.issue_date, '%Y-%m')
+                   ) a2
+                       LEFT JOIN (
+                  -- 绗竴涓煡璇細鏉ヨ嚜 invoice_ledger 鐨勭◣棰�
+                  SELECT
+                      DATE_FORMAT(il.invoice_date, '%Y-%m') AS month,
+                      ROUND(SUM(pr.invoice_amount - pr.invoice_amount / (1 + pr.tax_rate / 100)), 2) AS tax_amount
+                  FROM invoice_ledger il
+                           LEFT JOIN invoice_registration_product pr ON pr.id = il.invoice_registration_product_id
+                  WHERE il.invoice_no IS NOT NULL
+                    AND invoice_type = '澧炰笓绁�'
+                  GROUP BY DATE_FORMAT(il.invoice_date, '%Y-%m')
+              ) a1 ON a1.month = a2.month
+              WHERE a1.month IS NULL
+              ORDER BY month
+             )as a
+        <where>
+            <if test="month != null">
+                and a.month = date_format(#{month})
+            </if>
+        </where>
+
+    </select>
+    <select id="listVat1" resultType="com.ruoyi.purchase.dto.VatDto">
+        #             SELECT
+#                 DATE_FORMAT(il.invoice_date, '%Y-%m') AS month,
+#                 ROUND(SUM(pr.invoice_amount - pr.invoice_amount / (1 + pr.tax_rate / 100)), 2) AS tax_amount
+#             FROM invoice_ledger il
+#                      LEFT JOIN invoice_registration_product pr ON pr.id = il.invoice_registration_product_id
+#             WHERE il.invoice_no IS NOT NULL
+#               AND invoice_type = '澧炰笓绁�'
+#             GROUP BY DATE_FORMAT(il.invoice_date, '%Y-%m')
+#             ORDER BY month;
+#         select DATE_FORMAT(a.issue_date, '%Y-%m'), sum(a.invoice_amount) as xTaxAmount
+#         from (SELECT distinct pr.id,
+#                               tr.issue_date,
+#                               ROUND(pr.tickets_amount / (1 + pr.tax_rate / 100), 2) AS un_tickets_price,
+#                               ROUND(pr.tickets_amount - pr.tickets_amount / (1 + pr.tax_rate / 100),
+#                                     2)                                              AS invoice_amount
+#               FROM product_record pr
+#                        LEFT JOIN purchase_ledger pl ON pl.id = pr.purchase_ledger_id
+#                        LEFT JOIN sales_ledger sl ON sl.id = pl.sales_ledger_id
+#                        LEFT JOIN ticket_registration tr ON tr.purchase_ledger_id = pl.id
+#                        LEFT JOIN product_model pm ON pm.id = pr.product_model_id
+#               WHERE type = 2
+#                 and tr.invoice_number is not null) a
+#         GROUP BY DATE_FORMAT(a.issue_date, '%Y-%m')
     </select>
 
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3