| | |
| | | |
| | | if (['bill_count', 'unitprice', 'amount_line'].includes(key)) { |
| | | line[key] = value || 0 |
| | | if (isNaN(line[key])) { |
| | | line[key] = 0 |
| | | } |
| | | if (line[key]) { |
| | | if (key === 'bill_count') { |
| | | line[key] = Math.round(line[key] * 10000000000) / 10000000000 |
| | |
| | | line.bill_count = Math.round(line.amount_line / line.unitprice * 10000000000) / 10000000000 |
| | | } |
| | | } |
| | | } else if (key === 'amount_line') { |
| | | line.bill_count = 0 |
| | | } |
| | | |
| | | 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 |
| | |
| | | <Input defaultValue={line.unit || ''} onChange={(e) => this.onChange(e.target.value, 'unit')}/> |
| | | </div> |
| | | <div className="mk-td"> |
| | | <InputNumber value={bill_count} onChange={(val) => this.setState({bill_count: val})} onBlur={(e) => this.onChange(e.target.value, 'bill_count')}/> |
| | | <InputNumber value={bill_count} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} onChange={(val) => this.setState({bill_count: val})} onBlur={() => this.onChange(bill_count, 'bill_count')}/> |
| | | </div> |
| | | <div className="mk-td"> |
| | | <InputNumber value={unitprice} onChange={(val) => this.setState({unitprice: val})} onBlur={(e) => this.onChange(e.target.value, 'unitprice')}/> |
| | | <InputNumber value={unitprice} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} onChange={(val) => this.setState({unitprice: val})} onBlur={() => this.onChange(unitprice, 'unitprice')}/> |
| | | </div> |
| | | <div className="mk-td"> |
| | | <InputNumber value={amount_line} onChange={(val) => this.setState({amount_line: val})} onBlur={(e) => this.onChange(e.target.value, 'amount_line')}/> |
| | | <InputNumber value={amount_line} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} onChange={(val) => this.setState({amount_line: val})} onBlur={() => this.onChange(amount_line, '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).replace(/\B(?=(\d{3})+(?!\d))/g, ',')} <span className="del-line" onClick={() => delLine(line.uuid)}></span> </div> |
| | | </div> |
| | | } |
| | | } |
| | |
| | | data.forEach(item => { |
| | | if (!item.productcode) return |
| | | |
| | | price += item.amount_line |
| | | tax += item.tax_amount |
| | | price += item.amount_line * 100 |
| | | tax += item.tax_amount * 100 |
| | | }) |
| | | |
| | | this.setState({total: {price, tax, sum: price + tax, sumName: this.changeMoneyToChinese(price + tax)}}) |
| | | price = price / 100 |
| | | tax = tax / 100 |
| | | |
| | | this.setState({total: {price, tax, sum: price, sumName: this.changeMoneyToChinese(price)}}) |
| | | } |
| | | |
| | | resetDetails = (data) => { |
| | |
| | | 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 + '%' |
| | | |
| | | if (prod.vat_special_management && prod.free_tax_mark === 'true') { |
| | | item.tax_name = prod.vat_special_management |
| | | } |
| | | |
| | | item.productcode = prod.productcode |
| | | item.Description = prod.Description |
| | |
| | | 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 |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { config, tax_type } = this.props |
| | | const { editKey, data, total, visible } = this.state |
| | | |
| | | return ( |
| | |
| | | } |
| | | |
| | | return <div className="mk-tr" key={item.uuid} onClick={() => this.checkLine(item.uuid)}> |
| | | <div className="mk-td mk-left">{item.productname || '**'}</div> |
| | | <div className="mk-td mk-left">{item.productname || ''}</div> |
| | | <div className="mk-td mk-left">{item.spec || ''}</div> |
| | | <div className="mk-td mk-left">{item.unit || ''}</div> |
| | | <div className="mk-td mk-right">{item.bill_count || ''}</div> |
| | | <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.bill_count || ''}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}</div> |
| | | <div className="mk-td mk-right">{`${item.unitprice || ''}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}</div> |
| | | <div className="mk-td mk-right">{`${item.amount_line || ''}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}</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).replace(/\B(?=(\d{3})+(?!\d))/g, ',')}<span className="del-line" onClick={() => this.delLine(item.uuid)}></span></div> |
| | | </div> |
| | | })} |
| | | <div className="mk-total"> |
| | |
| | | <div className="mk-td"></div> |
| | | <div className="mk-td"></div> |
| | | <div className="mk-td"></div> |
| | | <div className="mk-td">¥{total.price}</div> |
| | | <div className="mk-td">¥{`${total.price}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}</div> |
| | | <div className="mk-td"></div> |
| | | <div className="mk-td">¥{total.tax}</div> |
| | | <div className="mk-td">¥{`${total.tax}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}</div> |
| | | </div> |
| | | <div className="mk-upcase"> |
| | | <div className="mk-td">价税合计(大写)</div> |
| | | <div className="mk-td">{total.sumName}</div> |
| | | <div className="mk-td">(小写)¥{total.sum}</div> |
| | | <div className="mk-td">(小写)¥{`${total.sum}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}</div> |
| | | </div> |
| | | <Modal |
| | | title="商品信息" |
| | |
| | | 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> |
| | | ) |