import React from 'react'; import Invoice from '../../..'; import 'antd/dist/antd.css'; import { Money } from '../../../tools/utils'; import { chain, bignumber } from 'mathjs'; export default () => { const callback = (e: any) => { console.log(e.target.checked) } console.log(Money.toStringChinese(0)) // console.log(chain(bignumber(null))) // console.log(chain(bignumber(5.01)).multiply(bignumber(5)).divide(bignumber(100)).done().toNumber()) // console.log(Math.abs(chain(bignumber(5.01)).multiply(bignumber(5)).divide(bignumber(100)).subtract(bignumber(0.24)).done().toNumber())) const controller = React.useMemo(() => new Invoice.InvoiceController(), []) const data = { "invoiceDataSource": null, "checkNumber": null, "id": "1723171330414006273", "invoiceCode": "051002100207", "invoiceNo": "26027235", "invoiceDate": "20230915", "checkCode": "06085105111389440471", "invoiceType": "11", "salerName": "锦江区新川西乡土菜餐厅", "salerTaxNo": "92510104MA6C07Q46X", "salerAddressPhone": null, "salerAccount": null, "buyerName": "中科迅联智慧网络科技(重庆)有限公司", "buyerTaxNo": "91500000MA6131YC2B", "buyerAddressPhone": null, "buyerAccount": null, "invoiceAmount": "97.03", "taxAmount": "0.97", "totalAmount": "", "machineNo": "929906183942", "drawer": "管理员", "payee": "管理员", "reviewer": null, "blueinvoiceCode": null, "blueinvoiceNo": null, "detailedListType": 2, "cancellationMark": "1", "remark": null, "ofdUrl": null, "pdfUrl": null, "xmlUrl": null, "productOilMark": "N", "validTaxAmount": null, "invoiceState": "0", "isSelected": null, "selectedDate": null, "authState": null, "deductibleMode": null, "authPeriodDate": null, "infoSources": null, "adminStatus": null, "isTs": 0, "isConfirm": null, "confirmDate": null, "updateTime": "2024-10-29 11:10:43", "verifyType": null, "taxCode": null, "taxMessage": null, "eInvoiceNo": null, "internationalOrInternal": null, "gpNumber": null, "name": null, "idNumber": null, "eTicketNumber": null, "departureDate": null, "departureTime": null, "departureStation": null, "destinationStation": null, "trainNumber": null, "trainCarriage": null, "seatNumber": null, "seatLevel": null, "taxRate": null, "invoiceDateFull": "2023-09-15 20:16:42", "entryAccountStatus": "01", "entryAccountFlag": "N", "entryAccountTime": null, "handleStatus": null, "handleTime": null, "handleType": null, "dataSource": null, "partAmount": null, "verifyStatus": null, "detailList": [ { "detailNo": "1", "goodsName": "*餐饮服务*餐饮服务", "goodsTaxCode": "3070401000000000000", "detailAmount": "", "num": "", "taxRate": "", "taxAmount": "", "taxUnitPrice": "", "taxDetailAmount": "98", "zeroTaxRateFlag": "", "unitPrice": "", "specificationModel": "", "unit": "", "plateNo": "", "type": "", "trafficDateStart": "", "trafficDateEnd": "", "flightSegment": null, "departureStation": null, "destinationStation": null, "carrier": null, "flightNumber": null, "seatLevel": null, "shipmentDate": null, "takeoffTime": null, "ticketType": null, "lineAttribute": "COMMON", "TaxClassificationCode": null } ], "invoiceTagResp": null } React.useEffect(() => { controller.run(async s => { s.goodsListState.isRecalculateWhenSwitchTax = true; s.goodsListState.isTaxIncluded = false; // s.stakeholder.enables = ['taxAmount']; // s.priceIntegerDigit = 25; // s.calculatingDigits = 25; // s.goodsListState.isTaxIncluded = false; // s.goodsListState.amountExcludeTax = parseFloat(data?.invoiceAmount) || undefined; // s.goodsListState.amountIncludeTax = parseFloat(data?.totalAmount) || undefined; // s.goodsListState.amountTax = parseFloat(data?.taxAmount) || undefined; // s.goodsListState.goodsList = data?.detailList?.map(e => sToCi(e)) ?? []; }) }, [controller]) return ( } invoiceHeader={ } /> ) }; function sToCi(data: any) { return { $index: Invoice.idGenerator(), lineAttribute: 0, discountGroup: 'discountGroup', // favouredPolicyMark: data.favouredPolicyMark ? 1 : 0, // favouredPolicyName: data.favouredPolicyName, // itemName: getItemName(data.goodsName), // shorthand: getShorthand(data.goodsName), unit: data.unit, itemModelName: data.specificationModel, quantity: data.num, priceIncludeTax: 0, priceExcludeTax: data.unitPrice, lineAmountIncludeTax: 0, lineAmountExcludeTax: data.detailAmount, taxRate: percentToDecimal(data.taxRate), taxFreeType: (data.zeroTaxRateFlag) as any, taxAmount: data.taxAmount, taxClassificationCode: data.taxCode } } function percentToDecimal(percent: any) { if (!percent) return 0; // 去掉百分号并转换为小数 return parseFloat(percent); }