chargebee-dotnet icon indicating copy to clipboard operation
chargebee-dotnet copied to clipboard

`Invoice.InvoiceLineItem`: add `Metered` property

Open dgaspar opened this issue 4 years ago • 2 comments

Would it be possible to expose a Metered property in the Invoice.InvoiceLineItem model? The value is already coming from the wire.

By adding this method:

        public bool Metered 
        {
            get { return GetValue<bool>("metered"); }
        }

To this class: https://github.com/chargebee/chargebee-dotnet/blob/bbf3a09eb0148249eb93f4b2335fdd3920938bd9/ChargeBee/Models/Invoice.cs#L3119

dgaspar avatar Nov 17 '21 09:11 dgaspar

Hi, In Invoice we have "status" property which will have pending as a value when it has line items that belong to items that are metered. So basically Item model has metered property but not Invoice.InvoiceLineItem. If that is not what you want could you please elaborate more what exactly you want.

cb-prajaktachavan avatar Dec 14 '21 11:12 cb-prajaktachavan

It's s just that in my use case I needed to know exactly which InvoiceLineItem(s) of an Invoice were Metered. We pulled that off in a hacky way:

private static bool IsMetered(this Invoice.InvoiceLineItem lineItem)
{
    var jToken = lineItem.GetJToken();
    return jToken["metered"] != null && (jToken["metered"]?.ToObject<bool>() ?? false);
}

dgaspar avatar Dec 14 '21 12:12 dgaspar

Hi @dgaspar, Sorry for the delayed response. This issue has been fixed in v3.31.0 — the field is now available as expected. You can find it here for reference: https://github.com/chargebee/chargebee-dotnet/blob/v3.31.0/ChargeBee/Models/Invoice.cs#L3642

I'll go ahead and close this issue since it's been resolved. Feel free to reopen it if you run into any trouble!

cb-alish avatar Jul 02 '25 05:07 cb-alish