Пример #1
0
        private void LoadFunctionalMailAddress()
        {
            if (this.functionalMailDict == null)
            {
                this.functionalMailDict = new Dictionary <MailAuthorType, FunctionalMail.AddressItem>();
                string   funcMails = OptionalData.GetOptionalDataString(ObjectOptionalDataType.OrgFunctionalMail);
                string[] rows      = funcMails.Replace("\r", "\n")
                                     .Replace("\n\n", "\n")
                                     .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

                Regex reSplitAddress = new Regex(@"^(?<Type>.+?):(?<Name>.+)[,;:]\s*(?<Address>\S+?@\S+?)$",
                                                 RegexOptions.IgnoreCase);
                foreach (string row in rows)
                {
                    Match match = reSplitAddress.Match(row);
                    try
                    {
                        MailAuthorType maType =
                            (MailAuthorType)Enum.Parse(typeof(MailAuthorType), match.Groups["Type"].Value);
                        string name    = match.Groups["Name"].Value;
                        string address = match.Groups["Address"].Value;
                        this.functionalMailDict[maType] = new FunctionalMail.AddressItem(address, name);
                    }
                    catch
                    {
                    }
                }
            }
        }
Пример #2
0
 public bool HasData(ObjectOptionalDataType dataType)
 {
     if (OptionalData.ContainsKey(dataType))
     {
         return(true);
     }
     return(false);
 }
Пример #3
0
        private void SaveFunctionalMailDict()
        {
            StringBuilder sb = new StringBuilder();

            foreach (MailAuthorType ma in functionalMailDict.Keys)
            {
                sb.AppendFormat("{0}:{1};{2}\r\n", ma.ToString(), functionalMailDict[ma].Name, functionalMailDict[ma].Email);
            }
            OptionalData.SetOptionalDataString(ObjectOptionalDataType.OrgFunctionalMail, sb.ToString());
        }
Пример #4
0
        public void SetOptionalData(ObjectOptionalDataType dataType, string data)
        {
            SwarmDb.GetDatabaseForWriting().SetObjectOptionalData(this.forObject, dataType, data);

            if (data == null && OptionalData.ContainsKey(dataType))
            {
                OptionalData.Remove(dataType);
            }
            else
            {
                this[dataType] = data;
            }
        }
Пример #5
0
        public string this [ObjectOptionalDataType dataType]
        {
            get
            {
                if (OptionalData.ContainsKey(dataType))
                {
                    return(OptionalData[dataType]);
                }

                return(null);
            }
            set
            {
                SwarmDb.GetDatabaseForWriting().SetObjectOptionalData(this.forObject, dataType, value);
                OptionalData[dataType] = value;
            }
        }
Пример #6
0
        public override void Read(BinaryReader br)
        {
            _nameHash      = br.ReadUInt32();
            _classNameHash = br.ReadUInt32();
            _parentHash    = br.ReadUInt32();
            _countOpt1     = br.ReadInt32();
            _num1          = br.ReadInt32();                    // not always 0, 0xc in one case
            _countOpt2     = br.ReadInt32();

            Debug.Assert(_countOpt1 == _countOpt2, "CountOpt1 not equal to CountOpt2");

#if CARBON
            _countTypes      = br.ReadInt16();
            _countTypesTotal = br.ReadInt16();
#else
            _countTypes = br.ReadInt32();
#endif

            _pointer = (int)br.BaseStream.Position;
            br.ReadInt32();
            _typeHashes = new uint[_countTypes];
            for (int i = 0; i < _countTypes; i++)
            {
                _typeHashes[i] = br.ReadUInt32();
            }
#if CARBON
            for (int i = _countTypes; i < _countTypesTotal; i++)
            {
                br.ReadInt32();
            }
#endif
            _optionalData = new OptionalData[_countOpt1];
            for (int i = 0; i < _countOpt1; i++)
            {
                _optionalData[i] = new OptionalData();
                _optionalData[i].Read(br);
            }
        }
Пример #7
0
        public void EnableEconomy(Currency currency)
        {
            if (IsEconomyEnabled)
            {
                throw new InvalidOperationException("Economy data already enabled");
            }

            // First, set hardwired accounts


            // TODO: Set names according to org default culture

            FinancialAccounts[OrganizationFinancialAccountType.AssetsBankAccountMain] =
                FinancialAccount.Create(this.Identity, "Bank Account", FinancialAccountType.Asset, 0);
            FinancialAccounts[OrganizationFinancialAccountType.AssetsOutboundInvoices] =
                FinancialAccount.Create(this.Identity, "Outbound Invoices", FinancialAccountType.Asset, 0);
            FinancialAccounts[OrganizationFinancialAccountType.AssetsOutstandingCashAdvances] =
                FinancialAccount.Create(this.Identity, "Cash Advances", FinancialAccountType.Asset, 0);
            //FinancialAccounts[OrganizationFinancialAccountType.AssetsPaypal] =
            //    FinancialAccount.Create(this.Identity, "Paypal Account", FinancialAccountType.Asset, 0);
            //FinancialAccounts[OrganizationFinancialAccountType.AssetsBitcoinHot] =
            //    FinancialAccount.Create(this.Identity, "Bitcoin Holdings (Hot)", FinancialAccountType.Asset, 0);
            //FinancialAccounts[OrganizationFinancialAccountType.AssetsBitcoinCold] =
            //    FinancialAccount.Create(this.Identity, "Bitcoin Cold Storage", FinancialAccountType.Asset, 0);
            FinancialAccounts[OrganizationFinancialAccountType.AssetsVat] =
                FinancialAccount.Create(this.Identity, "Inbound Value Added Tax", FinancialAccountType.Asset, 0);
            FinancialAccounts[OrganizationFinancialAccountType.CostsAllocatedFunds] =
                FinancialAccount.Create(this.Identity, "Allocated funds", FinancialAccountType.Cost, 0);
            FinancialAccounts[OrganizationFinancialAccountType.CostsBankFees] =
                FinancialAccount.Create(this.Identity, "Bank Fees", FinancialAccountType.Cost, 0);
            FinancialAccounts[OrganizationFinancialAccountType.CostsInfrastructure] =
                FinancialAccount.Create(this.Identity, "ICT and Infrastructure", FinancialAccountType.Cost, 0);
            FinancialAccounts[OrganizationFinancialAccountType.CostsYearlyResult] =
                FinancialAccount.Create(this.Identity, "Yearly result", FinancialAccountType.Cost, 0);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsEquity] =
                FinancialAccount.Create(this.Identity, "Equity", FinancialAccountType.Debt, 0);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsExpenseClaims] =
                FinancialAccount.Create(this.Identity, "Expense Claims", FinancialAccountType.Debt, 0);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsInboundInvoices] =
                FinancialAccount.Create(this.Identity, "Inbound Invoices", FinancialAccountType.Debt, 0);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsOther] =
                FinancialAccount.Create(this.Identity, "General Debt", FinancialAccountType.Debt, 0);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsSalary] =
                FinancialAccount.Create(this.Identity, "Salaries Due", FinancialAccountType.Debt, 0);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsTax] =
                FinancialAccount.Create(this.Identity, "Taxes Due", FinancialAccountType.Debt, 0);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsVat] =
                FinancialAccount.Create(this.Identity, "Outbound Value Added Tax", FinancialAccountType.Debt, 0);

            FinancialAccounts[OrganizationFinancialAccountType.IncomeDonations] =
                FinancialAccount.Create(this.Identity, "Donations", FinancialAccountType.Income, 0);
            FinancialAccounts[OrganizationFinancialAccountType.IncomeSales] =
                FinancialAccount.Create(this.Identity, "Sales", FinancialAccountType.Income, 0);


            // Then, create various cost accounts that are probably needed, or that could be used as a starting point

            FinancialAccount.Create(this.Identity, "Offices", FinancialAccountType.Cost, 0);
            FinancialAccount.Create(this.Identity, "Unforeseen", FinancialAccountType.Cost, 0);
            FinancialAccount.Create(this.Identity, "Staff", FinancialAccountType.Cost, 0);
            FinancialAccount.Create(this.Identity, "Marketing and Campaigns", FinancialAccountType.Cost, 0);
            FinancialAccount.Create(this.Identity, "Research and Development", FinancialAccountType.Cost, 0);

            // Finally, create the first conference parent

            FinancialAccount conferenceBase = FinancialAccount.Create(this.Identity, "Conferences",
                                                                      FinancialAccountType.Cost, 0);

            conferenceBase.IsConferenceParent = true;

            // Set the currency

            OptionalData.SetOptionalDataString(ObjectOptionalDataType.OrgCurrency, currency.Code);

            // Set current year to first fiscal year

            this.OptionalData.SetOptionalDataInt(ObjectOptionalDataType.OrgFirstFiscalYear, DateTime.Today.Year);

            // Finally, flag the org as enabled

            this.OptionalData.SetOptionalDataBool(ObjectOptionalDataType.OrgEconomyEnabled, true);
        }
Пример #8
0
        public void EnableEconomy(Currency currency)
        {
            if (IsEconomyEnabled)
            {
                throw new InvalidOperationException("Economy data already enabled");
            }

            // First, set hardwired accounts

            FinancialAccounts[OrganizationFinancialAccountType.AssetsBankAccountMain] =
                FinancialAccount.Create(this, "[LOC]Asset_BankAccounts", FinancialAccountType.Asset, null);
            FinancialAccounts[OrganizationFinancialAccountType.AssetsOutboundInvoices] =
                FinancialAccount.Create(this, "[LOC]Asset_OutboundInvoices", FinancialAccountType.Asset, null);
            FinancialAccounts[OrganizationFinancialAccountType.AssetsOutstandingCashAdvances] =
                FinancialAccount.Create(this, "[LOC]Asset_CashAdvances", FinancialAccountType.Asset, null);
            FinancialAccounts[OrganizationFinancialAccountType.AssetsTaxAdvances] =
                FinancialAccount.Create(this, "[LOC]Asset_TaxAdvances", FinancialAccountType.Asset, null);

            FinancialAccount shortTermAssets = FinancialAccount.Create(this, "[LOC]Asset_ShortTerm",
                                                                       FinancialAccountType.Asset, null);

            FinancialAccounts[OrganizationFinancialAccountType.AssetsShortTerm]           = shortTermAssets;
            FinancialAccounts[OrganizationFinancialAccountType.AssetsTransfersInProgress] =
                FinancialAccount.Create(this, "[LOC]Asset_TransfersInProgress", FinancialAccountType.Asset,
                                        shortTermAssets);

            FinancialAccounts [OrganizationFinancialAccountType.AssetsBitcoinHot] =
                FinancialAccount.Create(this, "[LOC]Asset_BitcoinHot",
                                        FinancialAccountType.Asset, null);


            FinancialAccounts[OrganizationFinancialAccountType.CostsAllocatedFunds] =
                FinancialAccount.Create(this, "[LOC]Cost_AllocatedFunds", FinancialAccountType.Cost, null);
            FinancialAccounts[OrganizationFinancialAccountType.CostsInfrastructure] =
                FinancialAccount.Create(this, "[LOC]Cost_IctInfrastructure", FinancialAccountType.Cost, null);
            FinancialAccounts[OrganizationFinancialAccountType.CostsYearlyResult] =
                FinancialAccount.Create(this, "[LOC]Cost_AnnualResult", FinancialAccountType.Cost, null);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsEquity] =
                FinancialAccount.Create(this, "[LOC]Debt_Equity", FinancialAccountType.Debt, null);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsExpenseClaims] =
                FinancialAccount.Create(this, "[LOC]Debt_ExpenseClaims", FinancialAccountType.Debt, null);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsInboundInvoices] =
                FinancialAccount.Create(this, "[LOC]Debt_InboundInvoices", FinancialAccountType.Debt, null);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsOther] =
                FinancialAccount.Create(this, "[LOC]Debt_General", FinancialAccountType.Debt, null);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsSalary] =
                FinancialAccount.Create(this, "[LOC]Debt_Salaries", FinancialAccountType.Debt, null);
            FinancialAccounts[OrganizationFinancialAccountType.DebtsTax] =
                FinancialAccount.Create(this, "[LOC]Debt_Taxes", FinancialAccountType.Debt, null);

            FinancialAccount financialFeesMaster = FinancialAccount.Create(this, "[LOC]Cost_FinancialFees",
                                                                           FinancialAccountType.Cost, null);

            FinancialAccounts[OrganizationFinancialAccountType.CostsBankFees] =
                FinancialAccount.Create(this, "[LOC]Cost_BankFees", FinancialAccountType.Cost, financialFeesMaster);
            FinancialAccounts[OrganizationFinancialAccountType.CostsBitcoinFees] =
                FinancialAccount.Create(this, "[LOC]Cost_BitcoinFees", FinancialAccountType.Cost, financialFeesMaster);

            FinancialAccounts[OrganizationFinancialAccountType.IncomeDonations] =
                FinancialAccount.Create(this, "[LOC]Income_Donations", FinancialAccountType.Income, null);
            FinancialAccounts[OrganizationFinancialAccountType.IncomeSales] =
                FinancialAccount.Create(this, "[LOC]Income_Sales", FinancialAccountType.Income, null);

            // Then, create various cost accounts that are probably needed, or that could be used as a starting point

            FinancialAccount officeMaster = FinancialAccount.Create(this, "[LOC]Cost_Offices", FinancialAccountType.Cost, null);

            FinancialAccount.Create(this, "[LOC]Cost_OfficeSpace", FinancialAccountType.Cost, officeMaster);
            FinancialAccount.Create(this, "[LOC]Cost_OfficeEquipment", FinancialAccountType.Cost, officeMaster);
            FinancialAccount.Create(this, "[LOC]Cost_OfficeSupplies", FinancialAccountType.Cost, officeMaster);

            FinancialAccount.Create(this, "[LOC]Cost_BusinessServices", FinancialAccountType.Cost, null);

            FinancialAccount.Create(this, "[LOC]Cost_Unforeseen", FinancialAccountType.Cost, null);
            FinancialAccount.Create(this, "[LOC]Cost_MarketingCampaigns", FinancialAccountType.Cost, null);
            FinancialAccount.Create(this, "[LOC]Cost_ResearchDevelopment", FinancialAccountType.Cost, null);

            FinancialAccount staffMaster = FinancialAccount.Create(this, "[LOC]Cost_Staff", FinancialAccountType.Cost, null);

            FinancialAccount.Create(this, "[LOC]Cost_StaffSalaries", FinancialAccountType.Cost, staffMaster);
            FinancialAccount.Create(this, "[LOC]Cost_StaffExpenses", FinancialAccountType.Cost, staffMaster);
            FinancialAccount.Create(this, "[LOC]Cost_StaffBenefits", FinancialAccountType.Cost, staffMaster);


            FinancialAccount travelMaster = FinancialAccount.Create(this, "[LOC]Cost_Travel", FinancialAccountType.Cost,
                                                                    null);
            FinancialAccount airfare = FinancialAccount.Create(this, "[LOC]Cost_Airfare", FinancialAccountType.Cost, travelMaster);

            FinancialAccount.Create(this, "[LOC]Cost_AirfareBusiness", FinancialAccountType.Cost, airfare);
            FinancialAccount.Create(this, "[LOC]Cost_AirfareCoach", FinancialAccountType.Cost, airfare);
            FinancialAccount.Create(this, "[LOC]Cost_TaxiTransport", FinancialAccountType.Cost, travelMaster);
            FinancialAccount.Create(this, "[LOC]Cost_PublicTransit", FinancialAccountType.Cost, travelMaster);
            FinancialAccount lodging = FinancialAccount.Create(this, "[LOC]Cost_TravelLodging", FinancialAccountType.Cost, travelMaster);

            FinancialAccount.Create(this, "[LOC]Cost_LodgingHostel", FinancialAccountType.Cost, lodging);
            FinancialAccount.Create(this, "[LOC]Cost_LodgingShared", FinancialAccountType.Cost, lodging);
            FinancialAccount.Create(this, "[LOC]Cost_LodgingThreeStar", FinancialAccountType.Cost, lodging);
            FinancialAccount.Create(this, "[LOC]Cost_LodgingFourStar", FinancialAccountType.Cost, lodging);
            FinancialAccount.Create(this, "[LOC]Cost_LodgingFiveStar", FinancialAccountType.Cost, lodging);
            FinancialAccount.Create(this, "[LOC]Cost_TrainsFerries", FinancialAccountType.Cost, travelMaster);
            FinancialAccount.Create(this, "[LOC]Cost_TravelPerDiem", FinancialAccountType.Cost, travelMaster);
            FinancialAccount.Create(this, "[LOC]Cost_EventTickets", FinancialAccountType.Cost, travelMaster);

            FinancialAccount.Create(this, "[LOC]Cost_Taxes", FinancialAccountType.Cost, null);

            // Finally, create the first conference parent

            FinancialAccount conferenceBase = FinancialAccount.Create(this, "[LOC]Cost_Conferences",
                                                                      FinancialAccountType.Cost, null);

            conferenceBase.IsConferenceParent = true;

            // Set the currency

            OptionalData.SetOptionalDataString(ObjectOptionalDataType.OrgCurrency, currency.Code);

            // If presentation currency is something else than bitcoin cash, then we also
            // need forex gain/loss accounts to account for (at least) the hotwallet

            if (!currency.IsBitcoinCash)
            {
                this.FinancialAccounts.IncomeCurrencyFluctuations =
                    FinancialAccount.Create(this, "[LOC]Income_ForexGains",
                                            FinancialAccountType.Income, null);
                this.FinancialAccounts.CostsCurrencyFluctuations =
                    FinancialAccount.Create(this, "[LOC]Cost_ForexLosses",
                                            FinancialAccountType.Cost, null);
            }

            // Set current year to first fiscal year

            OptionalData.SetOptionalDataInt(ObjectOptionalDataType.OrgFirstFiscalYear, DateTime.Today.Year);

            // Finally, flag the org as enabled

            OptionalData.SetOptionalDataBool(ObjectOptionalDataType.OrgEconomyEnabled, true);
        }