Пример #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);
                }
            }
        }
    }
Пример #2
0
        private void AddAttestationWarnings(Person person)
        {
            TaskGroup group = new TaskGroup(TaskGroupType.AttestationWarning);

            if (!person.GetAuthority().HasPermission(Permission.CanSeeEconomyTransactions, Organization.PPSEid, 1, Authorization.Flag.AnyGeographyExactOrganization))
            {
                return;
            }

            InboundInvoices invoices = InboundInvoices.ForOrganization(Organization.PPSE);

            DateTime threshold = DateTime.Today.AddDays(10);

            foreach (InboundInvoice invoice in invoices)
            {
                if (invoice.DueDate < threshold && !invoice.Attested)
                {
                    group.Tasks.Add(new TaskAttestationLate(invoice));
                }
            }

            if (group.Tasks.Count > 0)
            {
                this.Add(group);
            }
        }
Пример #3
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._approvalRights.ContainsKey(invoice.BudgetId) ||
                invoice.Budget.OwnerPersonId == Person.NobodyId)
            {
                ApprovableCost cost = new ApprovableCost("I" + invoice.Identity.ToString(CultureInfo.InvariantCulture),
                                                         invoice.Supplier, invoice.BudgetAmountCents, invoice.Budget, invoice.Description,
                                                         "Financial_InvoiceInbound", hasDox, invoice);

                if (invoice.Attested)
                {
                    this._approvedCosts.Add(cost);
                }
                else
                {
                    this._approvableCosts.Add(cost);
                }
            }
        }
    }
Пример #4
0
    private void PopulateGrid()
    {
        InboundInvoices invoices = InboundInvoices.ForOrganization(this.Organization, true);

        invoices.Reverse();

        this.GridInvoices.DataSource = invoices;
        this.GridInvoices.Rebind();
    }
Пример #5
0
        private void PopulateInboundInvoices()
        {
            InboundInvoices invoices = InboundInvoices.ForOrganization(CurrentOrganization, true);

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

                AddDocuments(invoice.Documents, "I" + invoice.Identity.ToString(CultureInfo.InvariantCulture),
                             String.Format(Global.Financial_InboundInvoiceSpecificationWithSender + " - ",
                                           invoice.OrganizationSequenceId, invoice.Supplier) + Global.Global_ImageSpecification);
            }
        }
Пример #6
0
        private void PopulateInboundInvoices()
        {
            InboundInvoices invoices = InboundInvoices.ForOrganization(this.CurrentOrganization).WhereUnattested;

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

                if (_attestationRights.ContainsKey(invoice.BudgetId) || invoice.Budget.OwnerPersonId == Person.NobodyId)
                {
                    AddDocuments(invoice.Documents, "I" + invoice.Identity.ToString(CultureInfo.InvariantCulture), String.Format(Resources.Global.Financial_InboundInvoiceSpecificationWithSender + " - ", invoice.Identity, invoice.Supplier) + Resources.Global.Global_ImageSpecification);
                }
            }
        }
    protected void Page_Load (object sender, EventArgs e)
    {
        // Get invoices and attestation rights

        this._attestationRights = GetAttestationRights();
        this._invoices = InboundInvoices.ForOrganization(this.CurrentOrganization, true);

        _invoices.Sort(SortInvoicesByDueDateReverse);

        // Format as JSON and return

        Response.ContentType = "application/json";
        string json = FormatAsJson();
        Response.Output.WriteLine (json);
        Response.End();
    }
Пример #8
0
        private void LoadDependencies()
        {
            DependentExpenseClaims = new ExpenseClaims();
            DependentInvoices = new InboundInvoices();
            DependentSalariesNet = new Salaries();
            DependentSalariesTax = new Salaries();
            DependentCashAdvancesPayout = new CashAdvances();
            DependentCashAdvancesPayback = new CashAdvances();

            BasicFinancialDependency[] dependencies = SwarmDb.GetDatabaseForReading().GetPayoutDependencies(this.Identity);

            foreach (BasicFinancialDependency dependency in dependencies)
            {
                switch (dependency.DependencyType)
                {
                    case FinancialDependencyType.ExpenseClaim:
                        DependentExpenseClaims.Add(ExpenseClaim.FromIdentity(dependency.ForeignId));
                        break;
                    case FinancialDependencyType.InboundInvoice:
                        DependentInvoices.Add(InboundInvoice.FromIdentity(dependency.ForeignId));
                        break;
                    case FinancialDependencyType.Salary:
                        Salary salary = Salary.FromIdentity(dependency.ForeignId);
                        if (salary.NetSalaryCents == this.AmountCents)  // HACK: Assumes that tax total is not identical
                        {
                            DependentSalariesNet.Add(salary);
                        }
                        else
                        {
                            DependentSalariesTax.Add(salary);
                        }
                        break;

                    case FinancialDependencyType.CashAdvance:
                        DependentCashAdvancesPayout.Add(CashAdvance.FromIdentity(dependency.ForeignId));
                        break;

                    case FinancialDependencyType.CashAdvancePayback:
                        DependentCashAdvancesPayback.Add(CashAdvance.FromIdentity(dependency.ForeignId));
                        break;

                    default:
                        throw new NotImplementedException("Unknown financial dependency type in Payout.LoadDependencies(): " + dependency.ToString());
                }
            }
        }
Пример #9
0
        private void AddInboundInvoices(Person person, Organization organization)
        {
            TaskGroup group = new TaskGroup(TaskGroupType.AttestInvoices);

            // TODO: Loop over roles, get all open claims for roles where person can attest

            InboundInvoices invoices = InboundInvoices.ForOrganization(organization);

            foreach (InboundInvoice invoice in invoices)
            {
                if (invoice.Budget.OwnerPersonId == person.Identity && !invoice.Attested)
                {
                    group.Tasks.Add(new TaskInboundInvoice(invoice));
                }
            }

            if (group.Tasks.Count > 0)
            {
                Add(group);
            }
        }
Пример #10
0
    private void PopulateInvoices(AttestableItems items)
    {
        InboundInvoices openInvoices       = InboundInvoices.ForOrganization(Organization.PPSE);
        InboundInvoices unattestedInvoices = new InboundInvoices();

        foreach (InboundInvoice invoice in openInvoices)
        {
            if (!invoice.Attested && invoice.Open)
            {
                if (attestationRights.ContainsKey(invoice.BudgetId))
                {
                    unattestedInvoices.Add(invoice);
                }
            }
        }

        unattestedInvoices.Sort(SortGridInvoices);

        foreach (InboundInvoice invoice in unattestedInvoices)
        {
            AddAttestableItem(items, invoice);
        }
    }
Пример #11
0
    private void PopulateDebugInfo()
    {
        debugLookup = new Dictionary <int, DebugInfoLine>();

        ExpenseClaims   expenseClaims   = ExpenseClaims.FromOrganization(Organization.PPSE);
        InboundInvoices inboundInvoices = InboundInvoices.ForOrganization(Organization.PPSE);
        Salaries        salaries        = Salaries.ForOrganization(Organization.PPSE);
        Payouts         payouts         = Payouts.ForOrganization(Organization.PPSE);

        debugLookup[Organization.PPSE.FinancialAccounts.DebtsExpenseClaims.Identity]   = new DebugInfoLine();
        debugLookup[Organization.PPSE.FinancialAccounts.DebtsInboundInvoices.Identity] = new DebugInfoLine();
        debugLookup[Organization.PPSE.FinancialAccounts.CostsAllocatedFunds.Identity]  = new DebugInfoLine();
        debugLookup[Organization.PPSE.FinancialAccounts.DebtsSalary.Identity]          = new DebugInfoLine();
        debugLookup[Organization.PPSE.FinancialAccounts.DebtsTax.Identity]             = new DebugInfoLine();

        foreach (Payout payout in payouts)
        {
            foreach (ExpenseClaim claim in payout.DependentExpenseClaims)
            {
                debugLookup[Organization.PPSE.FinancialAccounts.DebtsExpenseClaims.Identity].Payouts -= claim.Amount;
            }

            foreach (InboundInvoice invoice in payout.DependentInvoices)
            {
                debugLookup[Organization.PPSE.FinancialAccounts.DebtsInboundInvoices.Identity].Payouts -= (decimal)invoice.Amount;
            }

            foreach (Salary salary in payout.DependentSalariesNet)
            {
                debugLookup[Organization.PPSE.FinancialAccounts.DebtsSalary.Identity].Payouts -= salary.NetSalaryDecimal;
            }

            foreach (Salary salary in payout.DependentSalariesTax)
            {
                debugLookup[Organization.PPSE.FinancialAccounts.DebtsTax.Identity].Payouts -= salary.TaxTotalDecimal;
            }
        }


        foreach (ExpenseClaim claim in expenseClaims)
        {
            if (claim.Open)
            {
                AddExpenseToDebug(claim);
            }
        }

        foreach (InboundInvoice invoice in inboundInvoices)
        {
            AddInboundInvoiceToDebug(invoice);
        }

        foreach (Salary salary in salaries)
        {
            AddSalaryNetToDebug(salary);
            AddSalaryTaxToDebug(salary);
        }

        List <DebugInfoLine> debugInfoLines = new List <DebugInfoLine>();

        foreach (int accountId in debugLookup.Keys)
        {
            debugLookup[accountId].AccountId = accountId;
            debugLookup[accountId].Actual    = FinancialAccount.FromIdentity(accountId).GetDelta(new DateTime(2006, 1, 1), DateTime.Today.AddDays(2)); // two days to account for all possible time zones
        }

        foreach (DebugInfoLine line in debugLookup.Values)
        {
            debugInfoLines.Add(line);
        }

        this.GridDebug.DataSource = debugInfoLines;
    }