Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { Document, PDFViewer } from '@react-pdf/renderer';
  3. import { Body } from './react-pdf/styles/styles.js';
  4. import { compose } from "redux";
  5. import { connect } from "react-redux";
  6.  
  7. import Acusederecibo from './react-pdf/Acusederecibo'
  8. import Header from './react-pdf/Header'
  9. import Footer from './react-pdf/Footer'
  10. import Table from './react-pdf/Table'
  11. import Totales from './react-pdf/Totales'
  12. import Referencias from './react-pdf/Referencias'
  13. import image from './react-pdf/assets/logo2.jpg';
  14. /* import Tablelicor from './react-pdf/Tablelicor' */
  15.  
  16. import { fetchDetails } from "../actions/showdocuments_actions";
  17.  
  18.  
  19. class FacturaGeneral extends Component {
  20.  
  21. _isMounted = false;
  22.  
  23. state = {
  24. isLoading: true
  25. }
  26.  
  27. componentDidMount() {
  28. this._isMounted = true;
  29. this.props.dispatch(fetchDetails())
  30. if (this._isMounted) {
  31. this.setState({isLoading: false})
  32. }
  33. }
  34. render() {
  35. const { previewPDF, typeDTE, details, ted } = this.props;
  36. console.log(details);
  37. const loading = this.state.isLoading;
  38. const companydata = {
  39. nombre: 'REPUESTOS ZENTENO Y COMPANIA LIMITADA',
  40. detalles: 'MANTENIMIENTO Y REPARACIÓN DE VEHÍCULOS AUTOMOTORES VENTA DE PARTES, PIEZAS Y ACCESORIOS DE VEHÍCULOS AUTOMOTORES VENTA AL POR MENOR DE OTROS PRODUCTOS EN PEQUENOS ALMACENES NO ESPECIALIZADO',
  41. direccion: 'CASA MATRIZ: AV.FREIRE 511 - Curico / E-MAIL: repzenteno@hotmail.com / TELÉFONO: 752314987'
  42. }
  43. const timbredata = {
  44. rut: '78.305.030-7',
  45. numfactura: '37535',
  46. facturadate: '26 de agosto de 2018',
  47. sii: 'CURICÓ'
  48. }
  49. const receptordata = {
  50. nombre: 'COMERCIAL Y AUTOMOTRIZ ABRICAS LIMITADA',
  51. rut: '76.758.902-6',
  52. giro: 'TALLER MECÁNICO',
  53. direccion: 'VIDAL 302',
  54. comuna: 'Curico',
  55. ciudad: 'Curico',
  56. contacto: 'CONTACTO',
  57. telefono: 'TELEFONO',
  58. formapago:'FORMA DE PAGO'
  59. }
  60. const referenciasdata = {
  61. tipodoc: 'tipodoc',
  62. folio: 'folio',
  63. fechaemision: 'fechaemision',
  64. motivo: 'motivo',
  65. otros: 'otros'
  66. }
  67. const productosdata = [{
  68. codigo: 'codigo',
  69. descripcion: 'descripcion',
  70. cantidad: 'cantidad',
  71. precio: 'precio',
  72. adicional: 'adicional',
  73. descuento: 'descuento',
  74. valor: 'valor',
  75. bruto: 'bruto',
  76. },
  77. {
  78. codigo: 'codigo2',
  79. descripcion: 'descripcion',
  80. cantidad: 'cantidad',
  81. precio: 'precio',
  82. adicional: 'adicional',
  83. descuento: 'descuento',
  84. valor: 'valor',
  85. bruto: 'bruto',
  86. }]
  87. const totalesdata = {
  88. neto: '6597',
  89. iva: '1655',
  90. total: '5484',
  91. adicionales: '6595',
  92. impuesto20: '6624',
  93. impuesto18:'656',
  94. impuesto31: '6565'
  95. }
  96. const codedata = {
  97. codigo: 'codigo'
  98. }
  99. return (
  100. <React.Fragment>
  101. {loading ? <div>Loading..</div>:
  102. <PDFViewer className="w-100" style={{height: '93%'}}>
  103. <Document>
  104. <Body wrap>
  105. <Header logo={image} companydata={companydata} timbredata={timbredata} receptordata={receptordata} />
  106. <Referencias referenciasdata={referenciasdata} />
  107. <Table productosdata={productosdata}/>
  108. <Totales totalesdata={totalesdata} codedata={codedata} />
  109. <Acusederecibo/>
  110. <Footer/>
  111. </Body>
  112. </Document>
  113. </PDFViewer>
  114. }
  115. </React.Fragment>
  116. );
  117. }
  118. }
  119. function mapStateToProps(state, ownProps) {
  120. return {
  121. previewPDF: state.fmManagerShowDocuments.previewPDF,
  122. xmlDownload: state.fmManagerReceipDocuments.xmlDownload,
  123. showDocuments: state.fmManagerShowDocuments.showDocuments,
  124. typeDTE: state.fmManagerShowDocuments.typeDTE,
  125. details: state.fmManagerShowDocuments.details,
  126. ted: state.fmManagerShowDocuments.ted
  127. };
  128. }
  129. export default compose(connect(mapStateToProps))(FacturaGeneral);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement