Page 1 of 1

Invoice Layout

Posted: Wed Jul 17, 2013 6:48 pm
by Brewhaus
We are trying to build the same invoice layout that we use in 7.0.7, but when we try to make the same changes to the files in Gold we get errors. This was covered in viewtopic.php?f=42&t=15747 for version 7.0.7, but I thought that it would be best to start this thread under Gold Discussions so that others trying to make invoice layout changes in Gold will be able to find the information.

In short, here are the things that we need changed in the invoice layout:

1) Remove shipping as a line item (it causes confusion to have it listed, but not included in the subtotal, and then listed again below the subtotal). We want it only included below the subtotal
2) Add the shipping method below the Ship To information
3) Add the payment type (Visa, PayPal, etc.) below the order number and order date
4) Add notes to invoice
I have found solutions to 1,2, and 3 (notes below), but cannot seem to get #4- can anyone help with this?

I will continue to work on these, and if I have any success I will list it to help others. If anyone can help with these changes, it would be greatly appreciated.

Re: Invoice Layout

Posted: Wed Jul 17, 2013 7:13 pm
by Brewhaus
Got one! To add the payment method:

Open Admin/Orders/Print/Invoices.ascx.cs
Add

Code: Select all

using CommerceBuilder.Payments;
to the top section of code (such as below using CommerceBuilder.Orders;)

Add the following code

Code: Select all

        protected string GetPaymentMethods(Object dataItem)
        {
            Order order = (Order)dataItem;
            List<string> paymentMethodNames = new List<string>();
            foreach (Payment payment in order.Payments)
            {
                if (!paymentMethodNames.Contains(payment.PaymentMethodName))
                    paymentMethodNames.Add(payment.PaymentMethodName);
            }

            return String.Join("", paymentMethodNames.ToArray());
        }
to the bottom of the file, before the second last }

Open Admin/Orders/Print/Invoices.ascx and locate the following line of code:
<asp:Label ID="OrderDate" runat="server" Text='<%# Eval("OrderDate", "{0:g}") %>'></asp:Label><br />

Below it add:
<asp:Label ID="PaymentMethodLabel" runat="server" Text="Paid By: " SkinID="FieldHeader"></asp:Label>
<%#GetPaymentMethods(Container.DataItem) %>

I think that is it. :-)

Re: Invoice Layout

Posted: Wed Jul 17, 2013 7:24 pm
by Brewhaus
To add the phone number and shipping method to the Ship To block:

Replace

Code: Select all

                string shipTo = shipment.FormatToAddress();
                if (!addressList.Contains(shipTo)) addressList.Add(shipTo)
with

Code: Select all

                string shipTo = shipment.FormatToAddress();
                string shipToPhone = string.Empty;
                if (!String.IsNullOrEmpty(shipment.ShipToPhone))
                    shipTo += "<br />" + shipment.ShipToPhone;
                shipTo += "<br /><br /><b>Ship By: </b>" + shipment.ShipMethodName;
                if (!string.IsNullOrEmpty(shipment.ShipMessage))
                    shipTo += "<br /><b>Shipping Note: </b>" + shipment.ShipMessage;
                if (!addressList.Contains(shipTo)) addressList.Add(shipTo);

Re: Invoice Layout

Posted: Wed Jul 17, 2013 7:50 pm
by Brewhaus
To remove shipping as a line item find the following code in Admin/Orders/Print/Invoices.ascx.cs

Code: Select all

        private OrderItemType[] displayItemTypes = { OrderItemType.Product, OrderItemType.Discount, 
        OrderItemType.Coupon, OrderItemType.Shipping, OrderItemType.Handling, OrderItemType.GiftWrap,
        OrderItemType.Charge, OrderItemType.Credit, OrderItemType.GiftCertificate, OrderItemType.Tax};
Remove:
OrderItemType.Shipping

Shipping will still display below Subtotal

Re: Invoice Layout

Posted: Mon Jul 22, 2013 11:14 am
by Brewhaus
We are still not able to get the order notes to print on the invoice. Can anyone help with this?

Re: Invoice Layout

Posted: Tue Jul 23, 2013 8:33 am
by jguengerich
You could put something like this just before the last line that says </table> at the bottom of the Admin/Orders/Print/Invoices.ascx file.

Code: Select all

<tr>
    <td colspan="4" class="dataSheet">
        <asp:GridView ID="OrderNotes" runat="server" ShowHeader="true"
            AutoGenerateColumns="false" CellPadding="0" CellSpacing="0" GridLines="none" 
            Width="100%" DataSource='<%#((Order)Container.DataItem).Notes.FindAll(on => on.NoteType == NoteType.Public)%>' SkinID="PrintableList" >
            <Columns>
                <asp:BoundField DataField="Comment" HeaderText="Notes" ItemStyle-HorizontalAlign="Left" />
            </Columns>
        </asp:GridView>
    </td>
</tr>
You can adjust the FindAll predicate if you want to show other types of notes, such as

Code: Select all

.FindAll(on => on.NoteType == NoteType.Public || on.NoteType == NoteType.SystemPublic)
You could also add a column with the date, so your columns become:

Code: Select all

<Columns>
    <asp:BoundField DataField="CreatedDate" HeaderText="Date" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" HeaderStyle-Width="15%" />
    <asp:BoundField DataField="Comment" HeaderText="Note" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" />
</Columns>
You may need to adjust the HeaderStyle-Width setting if long CreatedDates are getting cut off (i.e. 12/31/2013 12:37:22 AM).

Re: Invoice Layout

Posted: Tue Jul 23, 2013 8:59 am
by jguengerich
I just realized the printed version width is quite a bit different (at least for me), but the CreatedDate does wrap to the next line. You could also switch to pixels instead of percent for the HeaderStyle-Width if it helps you get the look you want.

Code: Select all

HeaderStyle-Width="125px"

Re: Invoice Layout

Posted: Tue Jul 23, 2013 11:59 am
by Brewhaus
That first code did the trick. Thank you! :-)

Re: Invoice Layout

Posted: Tue Oct 27, 2015 7:27 am
by compunerdy
I figured out how to remove discounts on each line but how do I add it back in as a single line item or put it down near the subtotal?

Re: Invoice Layout

Posted: Tue Oct 27, 2015 7:37 am
by Brewhaus
I am not sure if this is what you are looking for, but hopefully it helps.

Re: Invoice Layout

Posted: Tue Oct 27, 2015 7:43 am
by compunerdy
I figured it out..

I added OrderItemType.Discount to the adjustments function and removed it from the subtotal and it all looks good now.

Re: Invoice Layout

Posted: Tue Oct 27, 2015 8:30 am
by compunerdy
Not sure if you did this or not but do you know how to get the product line item to display the price after discounts?

I thought what I did before would work fine but it would be easier to have the correct price per line item for doing customs forms.

Re: Invoice Layout Show Payment and balance

Posted: Tue Oct 27, 2015 6:48 pm
by vsammons
Has anyone modified the Invoices to show the amount paid and current balance? I had this function in 7.x but the Gold does not have this. Our customers like to see that there is a ZERO balance after it is paid on the invoice.

I had GetTotalPayment and GetBalance references and Gold does not have these. Has anyone else done this?

Re: Invoice Layout Show Payment and balance

Posted: Wed Oct 28, 2015 4:09 am
by jguengerich
vsammons wrote:I had GetTotalPayment and GetBalance references and Gold does not have these. Has anyone else done this?
Gold has GetBalance() and GetCustomerBalance() (methods of the Order class). For payments, there's the TotalPayments property or Order, or you could use order.Payments.Total() (can pass a bool indicating if pending payments should be included).

Re: Invoice Layout Show Payment and balance

Posted: Wed Oct 28, 2015 4:15 am
by vsammons
jguengerich wrote:
vsammons wrote:I had GetTotalPayment and GetBalance references and Gold does not have these. Has anyone else done this?
Gold has GetBalance() and GetCustomerBalance() (methods of the Order class). For payments, there's the TotalPayments property or Order, or you could use order.Payments.Total() (can pass a bool indicating if pending payments should be included).
I was not able to find this in the Intellisence within the Visual Studio environment. I will give it another try. Do you have a sample/snipet I can use?

Re: Invoice Layout

Posted: Wed Oct 28, 2015 4:20 am
by jguengerich
Not sure why it wouldn't show up in IntelliSense. Make sure you have "use CommerceBuilder.Orders;" and "use CommerceBuilder.Payments;".

Re: Invoice Layout

Posted: Wed Oct 28, 2015 4:26 am
by vsammons
Negative...

I have using CommerceBuilder.Payments and using CommerceBuilder.Orders in references but still not coming up in the intellisense when typing Get... Are your 100% certain it is in Gold 10 version?

Re: Invoice Layout

Posted: Wed Oct 28, 2015 4:38 am
by jguengerich
Yes, when I open the unmodified WSP or WAP project for R10, IntelliSense shows it (I'm on R5, and it is there too). It is listed in the .chm files for R10 and R11. The .chm file should be available in the downloads area when you log in to AbleCommerce's web site. For R10 it is called "CommerceBuilder Help File for AbleCommerce Gold". For R11 it is called "CommerceBuilder Source API Gold R11".

Re: Invoice Layout

Posted: Wed Oct 28, 2015 4:50 am
by jguengerich
This is what I see in R10:
ISense.png

Re: Invoice Layout

Posted: Wed Oct 28, 2015 5:01 am
by vsammons
jguengerich wrote:This is what I see in R10:
ISense.png
I do see it! Thanks