Пример #1
0
        private static void AddBillingContent(Survey s)
        {
            //Time and rates table
            DrawStringLarge("Time Entries", GetLeftPage());
            Billing bObject = s.BillingObject;
            Dictionary <string, List <BillingItem> > dict = CreateDictionary(bObject.GetBillingItems());
            List <LineItem> lineItems = bObject.GetLineItems();

            DataTable billingItems = new DataTable();

            billingItems.Columns.Add("Description");
            billingItems.Columns.Add("Rate");
            billingItems.Columns.Add("Time");
            billingItems.Columns.Add("Tax Included?");

            foreach (string date in dict.Keys)
            {
                DrawStringBold(date, GetLeftPage());
                billingItems.Rows.Clear();
                List <BillingItem> items = dict[date];
                foreach (BillingItem item in items)
                {
                    string desc        = TrimString(item.Description).trimmedString;
                    string rate        = item.FieldTime == TimeSpan.Zero ? item.OfficeRate.ToString() : item.FieldRate.ToString();
                    string time        = item.FieldTime == TimeSpan.Zero ? ToFullString(item.OfficeTime) : ToFullString(item.FieldTime);
                    string taxIncluded = item.FieldTime == TimeSpan.Zero ? (item.FieldRate.TaxIncluded ? "Yes" : "No") : (item.OfficeRate.TaxIncluded ? "Yes" : "No");
                    billingItems.Rows.Add(desc, rate, time, taxIncluded);
                }

                DrawTable(billingItems);
            }
            string sub   = $"Sub-Total: {(bObject.GetTotalOfficeBill() + bObject.GetTotalFieldBill()).ToString("C2")}";
            float  right = GetRightPage() - pageFontBold.MeasureString(sub).Width - 20;

            DrawStringBold(sub, right);

            //Additional line items table
            DrawStringLarge("Additional Items", GetLeftPage());
            DataTable lineItemsTable = new DataTable();

            lineItemsTable.Columns.Add("Description");
            lineItemsTable.Columns.Add("Amount");
            lineItemsTable.Columns.Add("Tax");
            lineItemsTable.Columns.Add("Total");

            foreach (LineItem item in lineItems)
            {
                string desc   = item.Description;
                string amount = item.Amount.ToString("C2");
                string tax    = ((double)item.Amount * item.TaxRate).ToString("C2");
                string total  = item.SubTotal.ToString("C2");
                lineItemsTable.Rows.Add(desc, amount, tax, total);
            }
            DrawTable(lineItemsTable);
            sub   = $"Sub-Total: {bObject.GetBillingLineItemsBill():C2}";
            right = GetRightPage() - pageFontBold.MeasureString(sub).Width - 20;
            DrawStringBold(sub, right);

            //Grand total
            DrawStringLargeBold($"Grand Total: {bObject.GetTotalBill().ToString("C2")}", GetLeftPage());
        }