Base solution for your next web application
Open Closed

Need help formatting company address for invoices #12609


User avatar
0
eric_pulaski created

For use in invoices in ASP.NET Zero, is it possible to show our address in multiple lines on the invoice?

I tried hitting <Enter> into the Address field from the Host account portal in Administration > Settings > Invoice on the Address field, which looked like it worked, but it just came out in one line when I went to a tenant and clicked "Show Invoice" when looking at an invoice on the Payment History tab under subscription management.

Thanks in advance for help.

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

2 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @eric_pulaski

    Yes, this is possible in ASP.NET Zero, and what you are seeing is related to how line breaks are handled internally.

    By default, ASP.NET Zero splits the invoice address into multiple lines by using either the pipe (|) character or Windows style line breaks (\r\n). In InvoiceAppService.cs, the relevant logic looks like this:

    HostAddress = hostAddress.Replace("\r\n", "|").Split('|').ToList();
    

    Because of this, if the address is entered as a single block or if the line breaks are not in \r\n format, the invoice will still render the address on one line.

    Using Pipe Character

    You can already display the address on multiple lines by entering it like this in the Address field:

    Company Name | Street Address | City, State ZIP | Country
    

    This will be rendered as separate lines on the invoice.

    Using the Enter Key

    Some browsers send only \n (Unix style) when you press Enter, instead of \r\n (Windows style). In that case, the default code does not detect the line breaks correctly, which is why everything appears on a single line in the invoice.

    To support both formats and allow pressing Enter to create new lines, you can slightly update InvoiceAppService.cs.

    Line 68

    // Old
    HostAddress = hostAddress.Replace("\r\n", "|").Split('|').ToList();
    
    // New
    HostAddress = hostAddress
        .Replace("\r\n", "|")
        .Replace("\n", "|")
        .Split('|')
        .ToList();
    

    Line 72

    // Old
    TenantAddress = invoice.TenantAddress.Replace("\r\n", "|").Split('|').ToList();
    
    // New
    TenantAddress = invoice.TenantAddress
        .Replace("\r\n", "|")
        .Replace("\n", "|")
        .Split('|')
        .ToList();
    

    If you have any questions or need further assistance, we will be happy to help.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    eric_pulaski created

    Thanks! This worked.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)