feat(email/pdf): include partner company name, partner user name and email in emails and PDF confirmations
This commit is contained in:
@@ -94,7 +94,14 @@ const styles = StyleSheet.create({
|
||||
}
|
||||
});
|
||||
|
||||
export const InvoicePDF = ({ order, orderSnapshot, customer }: any) => {
|
||||
export const InvoicePDF = ({
|
||||
order,
|
||||
orderSnapshot,
|
||||
customer,
|
||||
partnerCompanyName,
|
||||
partnerUserName,
|
||||
partnerUserEmail,
|
||||
}: any) => {
|
||||
const items = orderSnapshot?.items ?? [];
|
||||
const taxRate = orderSnapshot?.tax_rate ?? 19;
|
||||
const isSubscription = order?.type === 'subscription' || orderSnapshot?.billing_cycle === 'monthly';
|
||||
@@ -112,7 +119,6 @@ export const InvoicePDF = ({ order, orderSnapshot, customer }: any) => {
|
||||
item.selected_modules?.forEach((mod: any) => {
|
||||
const qty = mod.quantity || 1;
|
||||
const price = mod.total_price ?? (mod.price * qty);
|
||||
// Module sind monatliche wiederkehrende Beträge (Abo/Miete)
|
||||
monthlyNet += price;
|
||||
});
|
||||
});
|
||||
@@ -135,6 +141,10 @@ export const InvoicePDF = ({ order, orderSnapshot, customer }: any) => {
|
||||
groupedItems[devName].push(item);
|
||||
});
|
||||
|
||||
const displayPartnerName = partnerCompanyName || order?.partner_company_name;
|
||||
const displayUserName = partnerUserName || order?.partner_user_name;
|
||||
const displayUserEmail = partnerUserEmail || order?.partner_user_email;
|
||||
|
||||
return (
|
||||
<Document>
|
||||
<Page size="A4" style={styles.page}>
|
||||
@@ -155,20 +165,31 @@ export const InvoicePDF = ({ order, orderSnapshot, customer }: any) => {
|
||||
Anfragebestätigung: {order.order_number || order.id}
|
||||
</Text>
|
||||
|
||||
<View style={styles.section}>
|
||||
<Text style={styles.label}>Kunde</Text>
|
||||
<Text>{customer.company_name}</Text>
|
||||
<Text>{customer.first_name} {customer.last_name}</Text>
|
||||
<Text>{customer.address}</Text>
|
||||
<Text>{customer.zip_code} {customer.city}</Text>
|
||||
<Text>USt-IdNr: {customer.vat_id}</Text>
|
||||
</View>
|
||||
<View style={{ flexDirection: 'row', justify: 'space-between', marginBottom: 15 }}>
|
||||
<View style={{ width: '48%' }}>
|
||||
<Text style={styles.label}>Endkunde</Text>
|
||||
<Text style={{ fontWeight: 'bold' }}>{customer.company_name}</Text>
|
||||
{customer.first_name || customer.last_name ? <Text>{customer.first_name} {customer.last_name}</Text> : null}
|
||||
{customer.address ? <Text>{customer.address}</Text> : null}
|
||||
{customer.zip_code || customer.city ? <Text>{customer.zip_code} {customer.city}</Text> : null}
|
||||
{customer.vat_id ? <Text>USt-IdNr: {customer.vat_id}</Text> : null}
|
||||
</View>
|
||||
|
||||
<View style={styles.section}>
|
||||
<Text style={styles.label}>Bestelldetails</Text>
|
||||
<Text>Bestellnummer: {order.order_number || order.id}</Text>
|
||||
<Text>Zahlungsart: {isSubscription ? 'SEPA-Lastschrift' : 'Rechnung'}</Text>
|
||||
<Text>Datum: {new Date(order.created_at || Date.now()).toLocaleDateString('de-DE')}</Text>
|
||||
<View style={{ width: '48%' }}>
|
||||
<Text style={styles.label}>Bestelldetails</Text>
|
||||
<Text>Bestellnummer: {order.order_number || order.id}</Text>
|
||||
<Text>Zahlungsart: {isSubscription ? 'SEPA-Lastschrift' : 'Rechnung'}</Text>
|
||||
<Text>Datum: {new Date(order.created_at || Date.now()).toLocaleDateString('de-DE')}</Text>
|
||||
|
||||
{(displayPartnerName || displayUserName || displayUserEmail) && (
|
||||
<View style={{ marginTop: 6, paddingTop: 6, borderTopWidth: 1, borderColor: '#eee' }}>
|
||||
<Text style={styles.label}>Erstellt durch Partner / User</Text>
|
||||
{displayPartnerName ? <Text style={{ fontWeight: 'bold' }}>Partner: {displayPartnerName}</Text> : null}
|
||||
{displayUserName ? <Text>Erstellt von: {displayUserName}</Text> : null}
|
||||
{displayUserEmail ? <Text>E-Mail: {displayUserEmail}</Text> : null}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={{ marginTop: 10, marginBottom: 15 }}>
|
||||
|
||||
Reference in New Issue
Block a user