invoice_info.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. Image,
  5. Text,
  6. TouchableOpacity,
  7. SafeAreaView,
  8. ScrollView,
  9. Alert,
  10. DeviceEventEmitter,
  11. } from 'react-native';
  12. import {WingBlank, WhiteSpace, Modal} from '@ant-design/react-native';
  13. import {
  14. ClearAll,
  15. IndividualStorageData,
  16. RetrieveData,
  17. } from '../../../data/storage';
  18. import {
  19. RequestNetwork,
  20. UploadImage,
  21. GetNetworkUrl,
  22. } from '../../../data/encryption';
  23. import public_css from '../../../source/css/public_css';
  24. import {ToastShow} from '../../../components/toast/toast';
  25. import {rightArrowIcon} from '../../../source/icon/icon';
  26. import {SvgXml} from 'react-native-svg';
  27. import {GetMonthDate} from '../../../utils/date';
  28. // import ImagePicker from 'react-native-image-crop-picker';
  29. export default class invoice_info extends Component {
  30. constructor(props) {
  31. super(props);
  32. this.props.navigation.dangerouslyGetParent().setOptions({
  33. tabBarVisible: false,
  34. });
  35. this.state = {
  36. userName: '',
  37. invoiceReqFlowNo: '',
  38. invoiceStatus: false,
  39. invoiceType: '',
  40. invoiceCategory: 3,
  41. buyerName: '',
  42. buyerEntTaxId: '',
  43. invoiceTotalPrice: '',
  44. invoiceTotalPriceTax: '',
  45. invoiceTotalTax: '',
  46. sellerEntName: '',
  47. sellerEntTaxId: '',
  48. drawer: '',
  49. payee: '',
  50. checker: '',
  51. invoiceCode: '',
  52. invoiceNo: '',
  53. invoiceDate: '',
  54. invalidStatus: true,
  55. };
  56. }
  57. render() {
  58. return (
  59. <SafeAreaView style={public_css.body}>
  60. <ScrollView>
  61. <View style={{alignItems: 'center', marginTop: 10}}>
  62. <Image source={require('../../../source/img/tax/invoiceBack.png')} />
  63. {this.state.invoiceCategory === 3 ? (
  64. <Text
  65. style={{
  66. position: 'absolute',
  67. top: 30,
  68. color: '#9A4411',
  69. fontSize: 25,
  70. }}>
  71. 增值税普通纸质发票
  72. </Text>
  73. ) : this.state.invoiceCategory === 4 ? (
  74. <Text
  75. style={{
  76. position: 'absolute',
  77. top: 30,
  78. color: '#9A4411',
  79. fontSize: 25,
  80. }}>
  81. 增值税专用纸质发票
  82. </Text>
  83. ) : (
  84. <Text />
  85. )}
  86. </View>
  87. {this.state.invoiceStatus ? (
  88. <View style={{alignItems: 'center', marginTop: 10}}>
  89. <Text style={{color: '#A0A0A0'}}>开票成功</Text>
  90. </View>
  91. ) : (
  92. <View />
  93. )}
  94. <WingBlank>
  95. <View
  96. style={{
  97. flexDirection: 'row',
  98. alignItems: 'center',
  99. borderBottomWidth: 0.5,
  100. height: 50,
  101. }}>
  102. <View style={{width: 90}}>
  103. <Text
  104. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  105. 价税合计:
  106. </Text>
  107. </View>
  108. <View>
  109. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  110. ¥{this.state.invoiceTotalPriceTax}
  111. </Text>
  112. </View>
  113. </View>
  114. </WingBlank>
  115. <WingBlank>
  116. <View
  117. style={{
  118. flexDirection: 'row',
  119. alignItems: 'center',
  120. marginTop: 10,
  121. }}>
  122. <View style={{width: 90}}>
  123. <Text
  124. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  125. 购方名称:
  126. </Text>
  127. </View>
  128. <View>
  129. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  130. {this.state.buyerName}
  131. </Text>
  132. </View>
  133. </View>
  134. </WingBlank>
  135. <WingBlank>
  136. <View
  137. style={{
  138. flexDirection: 'row',
  139. alignItems: 'center',
  140. marginTop: 10,
  141. }}>
  142. <View style={{width: 90}}>
  143. <Text
  144. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  145. 企业税号:
  146. </Text>
  147. </View>
  148. <View>
  149. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  150. {this.state.buyerEntTaxId}
  151. </Text>
  152. </View>
  153. </View>
  154. </WingBlank>
  155. <WingBlank>
  156. <View
  157. style={{
  158. flexDirection: 'row',
  159. alignItems: 'center',
  160. marginTop: 10,
  161. }}>
  162. <View style={{width: 90}}>
  163. <Text
  164. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  165. 合计金额:
  166. </Text>
  167. </View>
  168. <View>
  169. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  170. ¥{this.state.invoiceTotalPrice}
  171. </Text>
  172. </View>
  173. </View>
  174. </WingBlank>
  175. <WingBlank>
  176. <View
  177. style={{
  178. flexDirection: 'row',
  179. alignItems: 'center',
  180. marginTop: 10,
  181. }}>
  182. <View style={{width: 90}}>
  183. <Text
  184. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  185. 合计税额:
  186. </Text>
  187. </View>
  188. <View>
  189. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  190. ¥{this.state.invoiceTotalTax}
  191. </Text>
  192. </View>
  193. </View>
  194. </WingBlank>
  195. <WingBlank>
  196. <View
  197. style={{
  198. flexDirection: 'row',
  199. alignItems: 'center',
  200. marginTop: 10,
  201. }}>
  202. <View style={{width: 90}}>
  203. <Text
  204. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  205. 客户名称:
  206. </Text>
  207. </View>
  208. <View>
  209. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  210. {this.state.sellerEntName}
  211. </Text>
  212. </View>
  213. </View>
  214. </WingBlank>
  215. <WingBlank>
  216. <View
  217. style={{
  218. flexDirection: 'row',
  219. alignItems: 'center',
  220. marginTop: 10,
  221. }}>
  222. <View style={{width: 90}}>
  223. <Text
  224. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  225. 客户税号:
  226. </Text>
  227. </View>
  228. <View>
  229. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  230. {this.state.sellerEntTaxId}
  231. </Text>
  232. </View>
  233. </View>
  234. </WingBlank>
  235. <WingBlank>
  236. <View
  237. style={{
  238. flexDirection: 'row',
  239. alignItems: 'center',
  240. marginTop: 10,
  241. }}>
  242. <View style={{width: 90}}>
  243. <Text
  244. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  245. 开票人:
  246. </Text>
  247. </View>
  248. <View>
  249. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  250. {this.state.drawer}
  251. </Text>
  252. </View>
  253. </View>
  254. </WingBlank>
  255. <WingBlank>
  256. <View
  257. style={{
  258. flexDirection: 'row',
  259. alignItems: 'center',
  260. marginTop: 10,
  261. }}>
  262. <View style={{width: 90}}>
  263. <Text
  264. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  265. 收款人:
  266. </Text>
  267. </View>
  268. <View>
  269. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  270. {this.state.payee}
  271. </Text>
  272. </View>
  273. </View>
  274. </WingBlank>
  275. <WingBlank>
  276. <View
  277. style={{
  278. flexDirection: 'row',
  279. alignItems: 'center',
  280. marginTop: 10,
  281. }}>
  282. <View style={{width: 90}}>
  283. <Text
  284. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  285. 审核人:
  286. </Text>
  287. </View>
  288. <View>
  289. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  290. {this.state.checker}
  291. </Text>
  292. </View>
  293. </View>
  294. </WingBlank>
  295. <WingBlank>
  296. <View
  297. style={{
  298. flexDirection: 'row',
  299. alignItems: 'center',
  300. marginTop: 10,
  301. }}>
  302. <View style={{width: 90}}>
  303. <Text
  304. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  305. 发票代码:
  306. </Text>
  307. </View>
  308. <View>
  309. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  310. {this.state.invoiceCode}
  311. </Text>
  312. </View>
  313. </View>
  314. </WingBlank>
  315. <WingBlank>
  316. <View
  317. style={{
  318. flexDirection: 'row',
  319. alignItems: 'center',
  320. marginTop: 10,
  321. }}>
  322. <View style={{width: 90}}>
  323. <Text
  324. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  325. 发票号码:
  326. </Text>
  327. </View>
  328. <View>
  329. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  330. {this.state.invoiceNo}
  331. </Text>
  332. </View>
  333. </View>
  334. </WingBlank>
  335. <WingBlank>
  336. <View
  337. style={{
  338. flexDirection: 'row',
  339. alignItems: 'center',
  340. marginTop: 10,
  341. }}>
  342. <View style={{width: 90}}>
  343. <Text
  344. style={{textAlign: 'right', color: '#9A4411', fontSize: 16}}>
  345. 开票日期:
  346. </Text>
  347. </View>
  348. <View>
  349. <Text style={{color: '#0C0C0C', fontSize: 16}}>
  350. {this.state.invoiceDate}
  351. </Text>
  352. </View>
  353. </View>
  354. </WingBlank>
  355. </ScrollView>
  356. <View style={{height: 50, flexDirection: 'row', alignItems: 'center'}}>
  357. <View
  358. style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
  359. <TouchableOpacity
  360. style={{
  361. alignItems: 'center',
  362. justifyContent: 'center',
  363. height: 40,
  364. width: 160,
  365. borderWidth: 1,
  366. borderRadius: 8,
  367. borderColor: '#FE2A53',
  368. }}
  369. onPress={() => {
  370. this.invoiceHongChong();
  371. }}>
  372. <Text style={{color: '#FE2A53'}}>发票红冲</Text>
  373. </TouchableOpacity>
  374. </View>
  375. <View
  376. style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
  377. {this.state.invalidStatus ? (
  378. <TouchableOpacity
  379. style={{
  380. alignItems: 'center',
  381. justifyContent: 'center',
  382. height: 40,
  383. width: 160,
  384. backgroundColor: '#F06969',
  385. borderRadius: 8,
  386. }}
  387. onPress={() => {
  388. this.invoiceInvalid();
  389. }}>
  390. <Text style={{color: '#FFFFFF'}}>发票作废</Text>
  391. </TouchableOpacity>
  392. ) : (
  393. <View />
  394. )}
  395. </View>
  396. </View>
  397. </SafeAreaView>
  398. );
  399. }
  400. //加载信息
  401. componentDidMount(): void {
  402. let data = this.props.route.params.data;
  403. this.setState({
  404. invoiceReqFlowNo: data.invoiceReqFlowNo,
  405. invoiceType: data.invoiceType,
  406. invoiceCategory: data.invoiceCategory,
  407. });
  408. this.invoiceInvalidStatus(data.invoiceDate);
  409. this.getInvoiceData(data.invoiceNumber, data.invoiceCode, data.invoiceType);
  410. }
  411. // 获取发票信息
  412. getInvoiceData = async (invoiceNumber, invoiceCode, invoiceType) => {
  413. let company = JSON.parse(await RetrieveData('company'));
  414. let account = await RetrieveData('account');
  415. let token = await RetrieveData('token');
  416. if (token && account) {
  417. const url = '/sys/invoiceExt/getResultData';
  418. let response = await RequestNetwork(
  419. url,
  420. token,
  421. {
  422. entTaxId: company.entTaxId,
  423. invoiceType: invoiceType,
  424. invoiceNumber: invoiceNumber,
  425. invoiceCode: invoiceCode,
  426. },
  427. false,
  428. 2,
  429. );
  430. if (response) {
  431. if (response.code === 0) {
  432. this.setState({
  433. invoiceStatus: response.data.invoiceStatus,
  434. buyerName: response.data.invoiceData.buyerName,
  435. buyerEntTaxId: response.data.invoiceData.buyerEntTaxId,
  436. invoiceTotalPrice: response.data.invoiceData.invoiceTotalPrice,
  437. invoiceTotalPriceTax:
  438. response.data.invoiceData.invoiceTotalPriceTax,
  439. invoiceTotalTax: response.data.invoiceData.invoiceTotalTax,
  440. sellerEntName: response.data.invoiceData.sellerEntName,
  441. sellerEntTaxId: response.data.invoiceData.sellerEntTaxId,
  442. drawer: response.data.invoiceData.drawer,
  443. payee: response.data.invoiceData.payee,
  444. checker: response.data.invoiceData.checker,
  445. invoiceCode: response.data.invoiceData.invoiceCode,
  446. invoiceNo: response.data.invoiceData.invoiceNo,
  447. invoiceDate: response.data.invoiceData.invoiceDate,
  448. });
  449. } else {
  450. ToastShow(1, response.msg);
  451. }
  452. }
  453. }
  454. };
  455. //发票红冲
  456. invoiceHongChong = async () => {
  457. let account = await RetrieveData('account');
  458. let token = await RetrieveData('token');
  459. if (token && account) {
  460. const url = '/sys/invoice/quickyHongchong';
  461. let response = await RequestNetwork(
  462. url,
  463. token,
  464. {
  465. oriInvoiceReqFlowNo: this.state.oriInvoiceReqFlowNo,
  466. mobile: account,
  467. reqChannel: 3,
  468. },
  469. false,
  470. 1,
  471. );
  472. if (response) {
  473. if (response.code === 0) {
  474. ToastShow(1, '红冲成功!');
  475. } else {
  476. ToastShow(1, response.msg);
  477. }
  478. }
  479. }
  480. };
  481. // 发票作废
  482. invoiceInvalid = async () => {
  483. let userName = await RetrieveData('userName');
  484. let company = JSON.parse(await RetrieveData('company'));
  485. let account = await RetrieveData('account');
  486. let token = await RetrieveData('token');
  487. if (token && account) {
  488. const url = '/sys/invoiceExt/invalid';
  489. let response = await RequestNetwork(
  490. url,
  491. token,
  492. {
  493. entTaxId: company.entTaxId,
  494. deviceType: company.defaultDeviceInfo.deviceType,
  495. taxDiscId: company.defaultDeviceInfo.taxDiscId,
  496. invoiceInvalidType: this.state.invoiceType,
  497. invoiceCategory: this.state.invoiceCategory,
  498. invoiceCode: this.state.invoiceCode,
  499. invoiceNumber: this.state.invoiceNo,
  500. invalidOper: userName,
  501. mobile: account,
  502. reqChannel: 3,
  503. },
  504. false,
  505. 1,
  506. );
  507. if (response) {
  508. if (response.code === 0) {
  509. ToastShow(1, '作废成功!');
  510. } else {
  511. ToastShow(1, response.msg);
  512. }
  513. }
  514. }
  515. };
  516. // 判断发票作废按钮状态
  517. invoiceInvalidStatus = (invoiceDate) => {
  518. let date = GetMonthDate();
  519. if (
  520. invoiceDate >= date.startDateString &&
  521. invoiceDate <= date.endDateString
  522. ) {
  523. this.setState({
  524. invalidStatus: true,
  525. });
  526. } else {
  527. this.setState({
  528. invalidStatus: false,
  529. });
  530. }
  531. };
  532. }