コード例 #1
0
        public static FinancialTransactionRows FromArray(BasicFinancialTransactionRow[] basicArray)
        {
            FinancialTransactionRows result = new FinancialTransactionRows {
                Capacity = (basicArray.Length * 11 / 10)
            };

            foreach (BasicFinancialTransactionRow basic in basicArray)
            {
                result.Add(FinancialTransactionRow.FromBasic(basic));
            }

            return(result);
        }
コード例 #2
0
        public Int64 this [FinancialAccount account]
        {
            get
            {
                Int64 result = 0;

                FinancialTransactionRows rows = Rows;

                foreach (FinancialTransactionRow row in rows)
                {
                    if (row.FinancialAccountId == account.Identity)
                    {
                        result += row.AmountCents;
                    }
                }

                return(result);
            }
        }
コード例 #3
0
ファイル: VatReport.cs プロジェクト: osoftware/Swarmops
        private void AddVatReportItemsFromAccountRows(FinancialAccountRows rows,
                                                      Dictionary <int, bool> transactionsIncludedLookup)
        {
            if (rows.Count == 0)
            {
                return;
            }

            Organization organization         = rows[0].Transaction.Organization; // there is always a rows[0] because check above
            int          vatInboundAccountId  = organization.FinancialAccounts.AssetsVatInboundUnreported.Identity;
            int          vatOutboundAccountId = organization.FinancialAccounts.DebtsVatOutboundUnreported.Identity;

            Dictionary <int, bool> turnoverAccountLookup = new Dictionary <int, bool>();

            FinancialAccounts turnoverAccounts = FinancialAccounts.ForOrganization(organization,
                                                                                   FinancialAccountType.Income);

            foreach (FinancialAccount turnoverAccount in turnoverAccounts)
            {
                turnoverAccountLookup[turnoverAccount.Identity] = true;
            }

            foreach (FinancialAccountRow accountRow in rows)
            {
                FinancialTransaction tx = accountRow.Transaction;

                if (tx.Dependency is VatReport)
                {
                    continue; // Never include previous VAT reports in new VAT reports
                }

                if (!transactionsIncludedLookup.ContainsKey(tx.Identity))
                {
                    Int64 vatInbound  = 0;
                    Int64 vatOutbound = 0;
                    Int64 turnOver    = 0;

                    transactionsIncludedLookup[accountRow.FinancialTransactionId] = true;

                    FinancialTransactionRows txRows = accountRow.Transaction.Rows;

                    foreach (FinancialTransactionRow txRow in txRows)
                    {
                        if (txRow.FinancialAccountId == vatInboundAccountId)
                        {
                            vatInbound += txRow.AmountCents;
                        }
                        else if (txRow.FinancialAccountId == vatOutboundAccountId)
                        {
                            vatOutbound += -txRow.AmountCents;  // this is a negative, so converting to positive
                        }
                        else if (turnoverAccountLookup.ContainsKey(txRow.FinancialAccountId))
                        {
                            turnOver -= txRow.AmountCents;  // turnover accounts are sign reversed, so convert to positive
                        }
                    }

                    // Add new row to the VAT report

                    AddItem(tx, turnOver, vatInbound, vatOutbound);
                }
            }
        }