Exemple #1
0
    private void PopulateInboundInvoices()
    {
        InboundInvoices invoices = InboundInvoices.ForOrganization(CurrentOrganization);

        foreach (InboundInvoice invoice in invoices)
        {
            Documents dox    = invoice.Documents;
            bool      hasDox = (dox.Count > 0 ? true : false);

            if (this._attestationRights.ContainsKey(invoice.BudgetId) ||
                invoice.Budget.OwnerPersonId == Person.NobodyId)
            {
                AttestableItem item = new AttestableItem("I" + invoice.Identity.ToString(CultureInfo.InvariantCulture),
                                                         invoice.Supplier, invoice.AmountCents, invoice.Budget, invoice.InvoiceReference,
                                                         "Financial_InvoiceInbound", hasDox, invoice);

                if (invoice.Attested)
                {
                    this._attestedItems.Add(item);
                }
                else
                {
                    this._items.Add(item);
                }
            }
        }
    }
Exemple #2
0
    private void PopulateCashAdvances()
    {
        CashAdvances advances = CashAdvances.ForOrganization(CurrentOrganization);

        foreach (CashAdvance advance in advances)
        {
            if (this._attestationRights.ContainsKey(advance.BudgetId) ||
                advance.Budget.OwnerPersonId == Person.NobodyId)
            {
                AttestableItem item = new AttestableItem(
                    "A" + advance.Identity.ToString(CultureInfo.InvariantCulture),
                    advance.Person.Name, advance.AmountCents, advance.Budget,
                    advance.Description, "Financial_CashAdvance", false, advance);

                if (advance.Attested)
                {
                    this._attestedItems.Add(item);
                }
                else
                {
                    this._items.Add(item);
                }
            }
        }
    }
Exemple #3
0
    private void PopulateExpenses()
    {
        ExpenseClaims expenses = ExpenseClaims.ForOrganization(CurrentOrganization);

        foreach (ExpenseClaim expenseClaim in expenses)
        {
            if (this._attestationRights.ContainsKey(expenseClaim.BudgetId) ||
                expenseClaim.Budget.OwnerPersonId == Person.NobodyId)
            {
                Documents dox    = expenseClaim.Documents;
                bool      hasDox = (dox.Count > 0 ? true : false);

                AttestableItem item = new AttestableItem(
                    "E" + expenseClaim.Identity.ToString(CultureInfo.InvariantCulture),
                    expenseClaim.ClaimerCanonical, expenseClaim.AmountCents, expenseClaim.Budget,
                    expenseClaim.Description, "Financial_ExpenseClaim", hasDox, expenseClaim);

                if (expenseClaim.Attested)
                {
                    this._attestedItems.Add(item);
                }
                else
                {
                    this._items.Add(item);
                }
            }
        }
    }
Exemple #4
0
    protected void GridAttestables_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            AttestableItem item = (AttestableItem)e.Item.DataItem;

            if (item == null)
            {
                return;
            }

            // Set Description field

            Label description = (Label)e.Item.FindControl("LabelDescription");

            description.Text = item.Description;

            if (item.Item is InboundInvoice)
            {
                InboundInvoice invoice = item.Item as InboundInvoice;

                Controls_v4_DocumentList docList = (Controls_v4_DocumentList)e.Item.FindControl("DocList");
                docList.Documents   = invoice.Documents;
                docList.Visible     = true;
                description.Visible = false;

                HyperLink editLink = (HyperLink)e.Item.FindControl("LinkEdit");
                editLink.Attributes["href"]    = "#";
                editLink.Attributes["onclick"] = String.Format("return ShowInboundInvoiceForm('{0}','{1}');",
                                                               invoice.Identity, e.Item.ItemIndex);
            }
            else if (item.Item is ExpenseClaim)
            {
                ExpenseClaim claim = item.Item as ExpenseClaim;

                HyperLink editLink = (HyperLink)e.Item.FindControl("LinkEdit");
                editLink.Attributes["href"]    = "#";
                editLink.Attributes["onclick"] = String.Format("return ShowExpenseClaimForm('{0}','{1}');",
                                                               claim.Identity, e.Item.ItemIndex);
            }

            // Calculate or retrieve remaining budget

            if (!budgetsRemainingLookup.ContainsKey(item.Budget.Identity))
            {
                int year = DateTime.Today.Year; // HACK: Should be item's date

                Int64 budgetCents = (Int64)item.Budget.GetBudget(year) * 100;

                Int64 centsUsed = item.Budget.GetDeltaCents(new DateTime(year, 1, 1), new DateTime(year + 1, 1, 1));

                decimal budgetRemaining = (-budgetCents - centsUsed) / 100.0m;

                budgetsRemainingLookup[item.Budget.Identity] = budgetRemaining;
            }

            Label labelBudgetRemaining = (Label)e.Item.FindControl("LabelBudgetRemaining");

            labelBudgetRemaining.Text = String.Format("{0:N2}", budgetsRemainingLookup[item.Budget.Identity]);
        }


        // Set the images for the status indicators.

        return; // fix later

        if (e.Item is GridDataItem)
        {
            ExpenseClaim claim = (ExpenseClaim)e.Item.DataItem;

            if (claim == null)
            {
                return;
            }

            Label labelBudgetYear = (Label)e.Item.FindControl("LabelBudgetYear");

            if (claim.BudgetId == 0)
            {
                labelBudgetYear.Text = "UNBUDGETED!";
            }
            else
            {
                labelBudgetYear.Text = claim.Budget.Name + ", " + claim.BudgetYear.ToString();
            }

            HyperLink editLink = (HyperLink)e.Item.FindControl("LinkEdit");
            editLink.Attributes["href"]    = "#";
            editLink.Attributes["onclick"] = String.Format("return ShowExpenseClaimForm('{0}','{1}');",
                                                           claim.Identity, e.Item.ItemIndex);
        }
    }