import React, { useEffect, useState } from 'react'; import { BackHandler } from 'react-native'; import { View, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native'; import { WebView } from 'react-native-webview'; import { useFocusEffect } from 'expo-router'; const InvoiceScreen = ({ navigation, cfg }:any) => { let html = ''; function formatNumber(number: any) { return number.toLocaleString('id-ID', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); } const [order] = cfg && cfg.invoice && cfg.invoice.sales_order ? cfg.invoice.sales_order:[]; if(order){ const orderLine: any = cfg.invoice.sales_order_line; const [cus] = cfg.dataPilihan.customer.filter((s: any) => s.id == order.partner_id) console.log(order) const uom: any = { '27': 'PCS', '28': 'SLOP', '29': 'BAL', '30': 'DOS', } html = `

CV. KBS

Jl. Mangga No 10, DENPASAR

${(`sales order`).toUpperCase()}

:

${order?.name}

Tanggal & Jam

:

${order.write_date != 'timestamp' ? order.write_date : cfg.invoice.times}

Kode Sales

:

${order?.client_order_ref}

Customer


Nama

:

${cus.name ? cus.name : '-'}

Alamat

:

${cus.street?cus.street:'-'}

No. Telp

:

${cus.phone?cus.phone:'-'}

${(function (d: any) { console.log(d) return d.map(function (n: any) { return ` ` }).join('') })(orderLine)}
Produk Qty Harga satuan Nominal
${n?.name} ${n?.product_uom_qty} ${uom[n?.product_uom]} ${formatNumber(n?.price_unit)} Rp ${formatNumber(n?.price_subtotal)}
Jumlah Sebelum Pajak
Rp ${formatNumber(order?.amount_untaxed)}
Pajak
Rp ${formatNumber(order?.amount_total - order?.amount_untaxed)}
Total
Rp ${formatNumber(order?.amount_total)}
`; } return ( <> INVOICE Cetak Invoice Kirim Invoice ); }; const styles = StyleSheet.create({ title: { fontSize: 32, fontWeight: 'bold', marginVertical: 10, }, date: { fontSize: 16, color: '#888', marginBottom: 20, }, info: { marginBottom: 20, }, infoText: { fontSize: 16, marginBottom: 5, }, divider: { borderBottomColor: '#000', borderBottomWidth: 1, marginVertical: 10, }, itemRow: { flexDirection: 'row', justifyContent: 'space-between', marginVertical: 5, }, itemText: { fontSize: 18, }, itemTextSatuan: { fontSize: 18, textAlign: 'center' }, totalRow: { flexDirection: 'row', justifyContent: 'space-between', marginVertical: 10, }, totalText: { fontSize: 24, fontWeight: 'bold', }, button: { backgroundColor: '#4199d5', borderRadius: 8, padding: 8, alignItems: 'center', margin: 10, height: 50 }, buttonText: { color: '#fff', fontSize: 18, fontWeight: 'bold', }, }); export default InvoiceScreen;