Beispiel #1
0
 public Quote(InvoiceReportBag reportBag)
 {
     InitializeComponent();
     this.DataSource = reportBag;
 }
Beispiel #2
0
        private static InvoiceReportBag PrepareInvoiceReportBag(InvoiceModel invoice)
        {
            var bag = new InvoiceReportBag()
            {
                PreparedBy              = new SafeUserModel(AccessService.Current.User).FirstName,
                InvoiceNumber           = invoice.InvoiceNumber,
                EventName               = invoice.EventModel.Name,
                EventDate               = invoice.EventModel.Date.ToString("d"),
                QuoteDate               = invoice.InvoiceDate.ToString("d"),
                Logo                    = (!string.IsNullOrWhiteSpace(Properties.Settings.Default.ClubInfoImageUrl)) ? Properties.Settings.Default.ClubInfoImageUrl : "http://www.catster.com/files/original.jpg",
                GolfClubHeaderInfo      = Properties.Settings.Default.ClubInfoAddress,
                GolfClubLeftFooterInfo  = Properties.Settings.Default.ClubInfoFooter,
                GolfClubRightFooterInfo = Properties.Settings.Default.ClubInfoBankAccount
            };

            if (invoice.EventModel.EventType != null)
            {
                var tokens = string.Concat(invoice.EventModel.EventType.Token1,
                                           invoice.EventModel.EventType.Token2,
                                           invoice.EventModel.EventType.Token3,
                                           invoice.EventModel.EventType.Token4,
                                           invoice.EventModel.EventType.Token5);

                bag.CorrespondenceTokens = tokens;
            }

            if (!string.IsNullOrWhiteSpace(invoice.EventModel.Event.InvoiceAddress))
            {
                bag.ContactAddress = invoice.EventModel.Event.InvoiceAddress;
            }
            else if (invoice.EventModel.PrimaryContact != null && !string.IsNullOrWhiteSpace(invoice.EventModel.PrimaryContact.FullAddressSepareted))
            {
                bag.ContactAddress = invoice.EventModel.PrimaryContact.FullAddressSepareted;
            }

            bag.InvoiceProductItems = new List <InvoiceProductItem>();

            // Charges which owners don't have ShowInInvoice flag.
            var bannedCharges = new List <EventChargeModel>();

            invoice.EventModel.EventCaterings.Where(x => !x.EventCatering.ShowInInvoice).ForEach(x => bannedCharges.AddRange(x.EventBookedProducts.Select(y => y.EventCharge)));
            invoice.EventModel.EventRooms.Where(x => !x.EventRoom.ShowInInvoice).ForEach(x => bannedCharges.AddRange(x.EventBookedProducts.Select(y => y.EventCharge)));
            invoice.EventModel.EventGolfs.Where(x => !x.EventGolf.ShowInInvoice).ForEach(x => bannedCharges.AddRange(x.EventBookedProducts.Select(y => y.EventCharge)));
            invoice.EventModel.EventInvoices.Where(x => !x.EventInvoice.ShowInInvoice).ForEach(x => bannedCharges.AddRange(x.EventBookedProducts.Select(y => y.EventCharge)));

            // Convert charges to InvoiceProductItems, but with checking banned charges
            bag.InvoiceProductItems.AddRange(invoice.EventModel.EventCharges.Where(x => !bannedCharges.Select(y => y.EventCharge.ID).Contains(x.EventCharge.ID)).Select(x => new InvoiceProductItem()
            {
                Quantity    = x.Quantity,
                Description = x.Product.Name,
                Price       = x.Price,
                TotalPrice  = x.TotalPrice,
            }));

            bag.TotalWithVAT    = bag.InvoiceProductItems.Sum(x => x.TotalPrice);
            bag.TotalExceptVAT  = bag.TotalWithVAT / 120 * 100;
            bag.VAT             = bag.TotalWithVAT - bag.TotalExceptVAT;
            bag.LessDepositPaid = invoice.EventModel.EventPayments.Where(x => x.IsDeposit).Sum(x => x.Amount);
            bag.BalanceToPay    = bag.TotalWithVAT - bag.LessDepositPaid;

            invoice.InnerInvoice.Amount = bag.TotalWithVAT;

            return(bag);
        }
Beispiel #3
0
 public Confirmation(InvoiceReportBag reportBag)
 {
     InitializeComponent();
     this.DataSource = reportBag;
 }