using System; using System.Collections.Generic; using System.Text; using Activizr.Logic.Structure; using Activizr.Logic.Support; using Activizr.Basic.Types; using Activizr.Database; namespace Activizr.Logic.Financial { public class InboundInvoices: PluralBase { /// /// Gets all open inbound invoices for a particular organization. /// /// The organization. /// The list of inbound invoices. public static InboundInvoices ForOrganization (Organization organization) { return ForOrganization(organization, false); } /// /// Gets all inbound invoices for an organization, optionally including closed ones. /// /// The organizations. /// True to include closed records. /// The list of inbound invoices. public static InboundInvoices ForOrganization (Organization organization, bool includeClosed) { return FromArray (PirateDb.GetDatabase().GetInboundInvoices(organization, includeClosed ? DatabaseCondition.None : DatabaseCondition.OpenTrue)); } public decimal TotalAmount { get { decimal result = 0.0m; foreach (InboundInvoice invoice in this) { result += invoice.Amount; } return result; } } public Int64 TotalAmountCents { get { Int64 result = 0; foreach (InboundInvoice invoice in this) { result += invoice.AmountCents; } return result; } } } }