import React, {Component} from 'react'; import { View, Image, Text, TouchableOpacity, SafeAreaView, ScrollView, Alert, DeviceEventEmitter, } from 'react-native'; import {WingBlank, WhiteSpace, Modal} from '@ant-design/react-native'; import { ClearAll, IndividualStorageData, RetrieveData, } from '../../../data/storage'; import { RequestNetwork, UploadImage, GetNetworkUrl, } from '../../../data/encryption'; import public_css from '../../../source/css/public_css'; import {ToastShow} from '../../../components/toast/toast'; import {rightArrowIcon} from '../../../source/icon/icon'; import {SvgXml} from 'react-native-svg'; import {GetMonthDate} from '../../../utils/date'; // import ImagePicker from 'react-native-image-crop-picker'; export default class invoice_info extends Component { constructor(props) { super(props); this.props.navigation.dangerouslyGetParent().setOptions({ tabBarVisible: false, }); this.state = { userName: '', invoiceReqFlowNo: '', invoiceStatus: false, invoiceType: '', invoiceCategory: 3, buyerName: '', buyerEntTaxId: '', invoiceTotalPrice: '', invoiceTotalPriceTax: '', invoiceTotalTax: '', sellerEntName: '', sellerEntTaxId: '', drawer: '', payee: '', checker: '', invoiceCode: '', invoiceNo: '', invoiceDate: '', invalidStatus: true, }; } render() { return ( {this.state.invoiceCategory === 3 ? ( 增值税普通纸质发票 ) : this.state.invoiceCategory === 4 ? ( 增值税专用纸质发票 ) : ( )} {this.state.invoiceStatus ? ( 开票成功 ) : ( )} 价税合计: ¥{this.state.invoiceTotalPriceTax} 购方名称: {this.state.buyerName} 企业税号: {this.state.buyerEntTaxId} 合计金额: ¥{this.state.invoiceTotalPrice} 合计税额: ¥{this.state.invoiceTotalTax} 客户名称: {this.state.sellerEntName} 客户税号: {this.state.sellerEntTaxId} 开票人: {this.state.drawer} 收款人: {this.state.payee} 审核人: {this.state.checker} 发票代码: {this.state.invoiceCode} 发票号码: {this.state.invoiceNo} 开票日期: {this.state.invoiceDate} { this.invoiceHongChong(); }}> 发票红冲 {this.state.invalidStatus ? ( { this.invoiceInvalid(); }}> 发票作废 ) : ( )} ); } //加载信息 componentDidMount(): void { let data = this.props.route.params.data; this.setState({ invoiceReqFlowNo: data.invoiceReqFlowNo, invoiceType: data.invoiceType, invoiceCategory: data.invoiceCategory, }); this.invoiceInvalidStatus(data.invoiceDate); this.getInvoiceData(data.invoiceNumber, data.invoiceCode, data.invoiceType); } // 获取发票信息 getInvoiceData = async (invoiceNumber, invoiceCode, invoiceType) => { let company = JSON.parse(await RetrieveData('company')); let account = await RetrieveData('account'); let token = await RetrieveData('token'); if (token && account) { const url = '/sys/invoiceExt/getResultData'; let response = await RequestNetwork( url, token, { entTaxId: company.entTaxId, invoiceType: invoiceType, invoiceNumber: invoiceNumber, invoiceCode: invoiceCode, }, false, 2, ); if (response) { if (response.code === 0) { this.setState({ invoiceStatus: response.data.invoiceStatus, buyerName: response.data.invoiceData.buyerName, buyerEntTaxId: response.data.invoiceData.buyerEntTaxId, invoiceTotalPrice: response.data.invoiceData.invoiceTotalPrice, invoiceTotalPriceTax: response.data.invoiceData.invoiceTotalPriceTax, invoiceTotalTax: response.data.invoiceData.invoiceTotalTax, sellerEntName: response.data.invoiceData.sellerEntName, sellerEntTaxId: response.data.invoiceData.sellerEntTaxId, drawer: response.data.invoiceData.drawer, payee: response.data.invoiceData.payee, checker: response.data.invoiceData.checker, invoiceCode: response.data.invoiceData.invoiceCode, invoiceNo: response.data.invoiceData.invoiceNo, invoiceDate: response.data.invoiceData.invoiceDate, }); } else { ToastShow(1, response.msg); } } } }; //发票红冲 invoiceHongChong = async () => { let account = await RetrieveData('account'); let token = await RetrieveData('token'); if (token && account) { const url = '/sys/invoice/quickyHongchong'; let response = await RequestNetwork( url, token, { oriInvoiceReqFlowNo: this.state.oriInvoiceReqFlowNo, mobile: account, reqChannel: 3, }, false, 1, ); if (response) { if (response.code === 0) { ToastShow(1, '红冲成功!'); } else { ToastShow(1, response.msg); } } } }; // 发票作废 invoiceInvalid = async () => { let userName = await RetrieveData('userName'); let company = JSON.parse(await RetrieveData('company')); let account = await RetrieveData('account'); let token = await RetrieveData('token'); if (token && account) { const url = '/sys/invoiceExt/invalid'; let response = await RequestNetwork( url, token, { entTaxId: company.entTaxId, deviceType: company.defaultDeviceInfo.deviceType, taxDiscId: company.defaultDeviceInfo.taxDiscId, invoiceInvalidType: this.state.invoiceType, invoiceCategory: this.state.invoiceCategory, invoiceCode: this.state.invoiceCode, invoiceNumber: this.state.invoiceNo, invalidOper: userName, mobile: account, reqChannel: 3, }, false, 1, ); if (response) { if (response.code === 0) { ToastShow(1, '作废成功!'); } else { ToastShow(1, response.msg); } } } }; // 判断发票作废按钮状态 invoiceInvalidStatus = (invoiceDate) => { let date = GetMonthDate(); if ( invoiceDate >= date.startDateString && invoiceDate <= date.endDateString ) { this.setState({ invalidStatus: true, }); } else { this.setState({ invalidStatus: false, }); } }; }