Exemple #1
0
        public static AirtimeBilling.Core.Entities.Company CreateEntity(this Company company)
        {
            AirtimeBilling.Core.Entities.Company entity = null;
            if (company != null)
            {
                var add = new Address
                {
                    Street = company.Street,
                    Street2 = company.Street2,
                    Suburb = company.Suburb,
                    State = company.State,
                    Postcode = company.Postcode
                };

                var postal = new Address
                {
                    Street = company.PostalStreet,
                    Street2 = company.PostalStreet2,
                    Suburb = company.PostalSuburb,
                    State = company.PostalState,
                    Postcode = company.PostalPostcode
                };

                entity = new AirtimeBilling.Core.Entities.Company(company.CompanyId)
                {
                    CompanyName = company.CompanyName,
                    ACN = company.ACN,
                    ABN = company.ABN,
                    Address = add,
                    PostalAddress = postal
                };
            }

            return entity;
        }
Exemple #2
0
        private AirtimeBilling.Core.Entities.Agent PopulateAgentEntity(Agent agent)
        {
            AirtimeBilling.Core.Entities.Agent entity = null;

            if (agent != null)
            {
                var address = new Address
                                  {
                                      Street = agent.Street,
                                      Suburb = agent.Suburb,
                                      State = agent.State,
                                      Postcode = agent.Postcode
                                  };

                entity = new AirtimeBilling.Core.Entities.Agent(agent.AgentId)
                {
                    AgentName = agent.AgentName,
                    Address = address,
                    Email = agent.Email,
                    CommissionPercent = (decimal)agent.CommissionPercent
                };
            }
            return entity;
        }
Exemple #3
0
 public void ToString_when_all_null_fields_returns_empty_string()
 {
     var address = new Address();
     Assert.AreEqual("", address.ToString());
 }
Exemple #4
0
 public void ToString_of_address_includes_all_address_fields()
 {
     var address = new Address
                           {Street = "22 Turrbal St", Suburb = "Bellbowrie", State = "QLD", Postcode = "4070"};
     Assert.AreEqual("22 Turrbal St Bellbowrie QLD 4070", address.ToString());
 }
Exemple #5
0
 public void ToString_includes_suburb_state_postcode_when_street_not_included()
 {
     var address = new Address {Suburb = "Bellbowrie", State = "QLD", Postcode = "4070"};
     Assert.AreEqual("Bellbowrie QLD 4070", address.ToString());
 }
Exemple #6
0
        public static Invoice GetInvoiceEntity(this InvoiceHeader header)
        {
            var address = new Address
            {
                Street = header.Street,
                Street2 = header.Street2,
                Suburb = header.Suburb,
                State = header.State,
                Postcode = header.Postcode
            };

            Invoice entity;

            if (header.IsInternational.HasValue && header.IsInternational.Value) {
                entity = new NoGstInvoice(header.InvoiceHeaderId);
            } else {
                entity = new Invoice(header.InvoiceHeaderId);
            }

            entity.InvoiceNumber = header.InvoiceNumber;
            entity.InvoiceDate = header.InvoiceDate;
            entity.InvoiceAddress = address;
            entity.FromDate = header.FromDate;
            entity.ToDate = header.ToDate;
            entity.InvoiceRunNumber = header.InvoiceRunNumber;
            entity.To = header.To;
            entity.PreviousBill = header.PreviousBill;
            entity.AmountPaid = header.AmountPaid;
            entity.Outstanding = header.Outstanding;
            entity.NewCharges = header.NewCharges;
            entity.CurrentBill = header.CurrentBill;
            entity.TotalIncGst = header.TotalIncGst;
            entity.TotalGst = header.TotalGst;
            entity.TotalExGst = header.TotalExGst;
            entity.HasFailedPayment = header.HasFailedPayment;

            if (header.PaymentDue.HasValue)
                entity.PaymentDue = header.PaymentDue.Value;

            foreach (var item in header.InvoiceLineItems)
            {
                var call = item.Call.CreateEntity();

                var line = new InvoiceLine(item.InvoiceLineItemId)
                {
                    Call = call,
                    Description = item.Description,
                    LineAmount = item.LineAmount,
                    GstAmount = item.GstAmount,
                    Invoice = entity,
                    ContractId = item.ContractId
                };

                entity.AddLine(line);
            }

            foreach (var account in header.AccountInvoices)
            {
                entity.AddAccount(account.AccountId);
                if (account.Account.IsInvoiceRoot)
                {
                    entity.InvoiceRootAccountId = account.AccountId;
                }
            }

            using (var db = DbFactory.GetDataContext())
            {
                var item = (from h in db.InvoiceHeaders
                            join ai in db.AccountInvoices on h.InvoiceHeaderId equals ai.InvoiceHeaderId
                            where h.InvoiceNumber.Equals(header.InvoiceNumber) && ai.Account.IsInvoiceRoot
                            select new { ai.Account.Contact.Email }).FirstOrDefault();

                if (item != null)
                {
                    entity.Email = item.Email;
                }
            }

            return entity;
        }
Exemple #7
0
 public void SetAddress(Address address)
 {
     Clear();
     Street = address.Street;
     Street2 = address.Street2;
     Suburb = address.Suburb;
     Postcode = address.Postcode;
     State = address.State;
 }