From fc8c8d714687a22f711d642d192bd4149f3b7e88 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 22 四月 2024 11:15:14 +0800
Subject: [PATCH] 2024-04-22

---
 src/tabviews/custom/components/module/invoice/invoiceTable/index.jsx |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/tabviews/custom/components/module/invoice/invoiceTable/index.jsx b/src/tabviews/custom/components/module/invoice/invoiceTable/index.jsx
index 791d755..9d2efd2 100644
--- a/src/tabviews/custom/components/module/invoice/invoiceTable/index.jsx
+++ b/src/tabviews/custom/components/module/invoice/invoiceTable/index.jsx
@@ -52,6 +52,13 @@
           }
         }
       }
+
+      if (line.amount_line) {
+        line.tax_amount = line.amount_line - line.amount_line / (line.tax_rate + 1)
+        line.tax_amount = Math.round(line.tax_amount * 100) / 100
+      } else {
+        line.tax_amount = 0
+      }
     } else {
       line[key] = value
     }
@@ -88,8 +95,8 @@
       <div className="mk-td">
         <InputNumber value={amount_line} onChange={(val) => this.setState({amount_line: val})} onBlur={(e) => this.onChange(e.target.value, 'amount_line')}/>
       </div>
-      <div className="mk-td">{line.tax_name}</div>
-      <div className="mk-td mk-right">{line.tax_amount} <span className="del-line" onClick={() => delLine(line.uuid)}></span> </div>
+      <div className="mk-td mk-right">{line.tax_name}</div>
+      <div className="mk-td mk-right">{line.tax_amount.toFixed(2)} <span className="del-line" onClick={() => delLine(line.uuid)}></span> </div>
     </div>
   }
 }
@@ -230,7 +237,7 @@
       tax += item.tax_amount
     })
 
-    this.setState({total: {price, tax, sum: price + tax, sumName: this.changeMoneyToChinese(price + tax)}})
+    this.setState({total: {price, tax, sum: price, sumName: this.changeMoneyToChinese(price)}})
   }
 
   resetDetails = (data) => {
@@ -304,8 +311,8 @@
         item.spec = prod.spec
         item.unit = prod.unit
         item.unitprice = prod.unitprice
-        item.tax_rate = prod.tax_rate
-        item.tax_name = prod.tax_rate
+        item.tax_rate = prod.tax_rate || 0
+        item.tax_name = prod.tax_rate * 100 + '%'
 
         item.productcode = prod.productcode
         item.Description = prod.Description
@@ -315,7 +322,12 @@
         if (item.bill_count && item.unitprice) {
           item.amount_line = Math.round(item.unitprice * item.bill_count * 100) / 100
         }
-        // item.tax_amount = prod.productname
+        if (item.amount_line) {
+          item.tax_amount = item.amount_line - item.amount_line / (item.tax_rate + 1)
+          item.tax_amount = Math.round(item.tax_amount * 100) / 100
+        } else {
+          item.tax_amount = 0
+        }
       }
 
       return item
@@ -329,7 +341,7 @@
   }
 
   render() {
-    const { config } = this.props
+    const { config, tax_type } = this.props
     const { editKey, data, total, visible } = this.state
 
     return (
@@ -358,7 +370,7 @@
             <div className="mk-td mk-right">{item.unitprice || ''}</div>
             <div className="mk-td mk-right">{item.amount_line || ''}</div>
             <div className="mk-td mk-right">{item.tax_name}</div>
-            <div className="mk-td mk-right">{item.tax_amount}</div>
+            <div className="mk-td mk-right">{item.tax_amount.toFixed(2)}</div>
           </div>
         })}
         <div className="mk-total">
@@ -384,7 +396,7 @@
           onCancel={() => { this.setState({ visible: false }) }}
           footer={null}
         >
-          <SubTable config={config} onChange={this.changeDetail}/>
+          <SubTable config={config} tax_type={tax_type} onChange={this.changeDetail}/>
         </Modal>
       </div>
     )

--
Gitblit v1.8.0