Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Wesley de Roo 38 posts 142 karma points
    Jan 07, 2016 @ 19:18
    Wesley de Roo
    0

    How to implementate note(s) to Invoices

    Hi,

    Using Umbraco 7.3.4 and Merchello 1.13.2 and want to add a note to the Invoice for commentary.

    First i tried this, but that seemed not working at al, when requesting the invoice the Notes are null:

    if (invoice.Notes == null) {
         invoice.Notes = new List<Note>();
    }
    invoice.Notes.Add(note);
    invoiceService.Save(invoice);
    

    Tried this, but then i don't know how to connect it to the Invoice:

    //Adding notes to the Invoice
    var noteService = MerchelloContext.Current.Services.NoteService;
    Note note = new Note();
    note.Message = message;
    noteService.Save(note);
    

    Found this, but don't know how to connect it with the invoice:

    noteService.CreateNoteWithKey(entityKey, EntityType, message);
    

    Can someone give me a basic example how to implemtate this?

    Kind regards, Wesley

  • Wesley de Roo 38 posts 142 karma points
    Jan 08, 2016 @ 08:59
    Wesley de Roo
    100

    I'm now using this:

    noteService.CreateNoteWithKey(invoice.Key, EntityType.Invoice, message);
    

    And when i request the Invoice:

    var invoice = invoiceService.GetByKey(new Guid("6D4451DB-14A8-44DE-81FD-D3F4B71A7CAC"));
    

    invoice.Notes is still null.

    Using the NoteService i can get the notes with:

    var notes = noteService.GetNotesByEntityKey(invoice.Key);
    

    So is this the way it supposed to be working?

  • kristian schneider 190 posts 351 karma points
    Jun 28, 2016 @ 07:40
    kristian schneider
    0

    Did you ever get this to work? It is causing me headaches too

    Best Kristian

  • kristian schneider 190 posts 351 karma points
    Jun 28, 2016 @ 08:01
    kristian schneider
    0

    It seems that you need to ensure that the invoice is saved first.

            invoiceService.Save(invoice);
    
            var noteService = MerchelloContext.Current.Services.NoteService;
            var note = noteService.CreateNoteWithKey(invoice.Key, EntityType.Invoice, json);
            noteService.Save(note);
    
  • Biagio Paruolo 1594 posts 1825 karma points c-trib
    Jun 28, 2016 @ 15:08
    Biagio Paruolo
    0

    Because the Invoice object is not in commited state and you cannot made a relation.

  • Simon 692 posts 1068 karma points
    Sep 14, 2016 @ 07:26
    Simon
    0

    Hi Kristian... it is not working for me....

    It is staying empty :/

    var merchelloServices = MerchelloContext.Current.Services;
                var currentCustomer = new CustomerContext(Umbraco.UmbracoContext).CurrentCustomer;
                var merchelloHelper = new MerchelloHelper();
                var invoiceService = merchelloServices.InvoiceService;
                var noteService = merchelloServices.NoteService;
    
                var customerBasket = currentCustomer.Basket();
    
                var countryCode = "US";
                var address = new Address { AddressType = AddressType.Billing, CountryCode = countryCode };
                var checkoutManager = customerBasket.GetCheckoutManager();
                checkoutManager.Customer.SaveBillToAddress(address);
    
                var invoice = checkoutManager.Payment.PrepareInvoice();
                invoice.VersionKey = Guid.NewGuid();
                invoice.Items.Add(customerBasket.Items);
    
                invoiceService.Save(invoice);
    
                //save invoice note
                var note = noteService.CreateNoteWithKey(invoice.Key, EntityType.Invoice, model.AdditionalInformation);
                noteService.Save(note);
    
                //clear basket
                customerBasket.Empty();
    

    Any help would be much appreciated

  • Flavio Spezi 128 posts 314 karma points
    Nov 16, 2016 @ 14:09
Please Sign in or register to post replies

Write your reply to:

Draft