Ejemplo n.º 1
0
 public string delAccounting(string idJson)
 {
     if (idJson != "")
     {
         try
         {
             int[] ids = FinanceJson.getFinanceJson().toObject <int[]>(idJson);
             asc = new AccountingService();
             if (asc.delAccounting(ids))
             {
                 return(FinanceResultData.getFinanceResultData().success(200, null, "成功"));
             }
             else
             {
                 return(FinanceResultData.getFinanceResultData().fail(500, null, "失败"));
             }
         }
         catch (InvalidOperationException ex)
         {
             //身份验证不通过
             return(FinanceResultData.getFinanceResultData().fail(401, null, ex.Message));
         }
         catch (Exception ex)
         {
             //未知的错误
             return(FinanceResultData.getFinanceResultData().fail(500, null, "未知的错误"));
         }
     }
     else
     {
         return(FinanceResultData.getFinanceResultData().fail(500, null, "失败"));
     }
 }
Ejemplo n.º 2
0
        private void LoadChartOfAccountComboBox()
        {
            var listchartOfAccount = AccountingService.GetAllChartOfAccount();

            //var listchartOfAccountDto = new List<ChartOfAccountDto>();

            var listchartOfAccountDto = new List <string>();

            listchartOfAccountDto.Insert(0, "");

            foreach (var item in listchartOfAccount)
            {
                //var chartOfAccountDto = new ChartOfAccountDto();
                //chartOfAccountDto.ID = item.CompanyId;
                //chartOfAccountDto.AccountCode = item.AccountCode;
                //chartOfAccountDto.AccountName = item.AccountName;
                //chartOfAccountDto.AccountTypeID = item.AccountType;
                //chartOfAccountDto.AccountType = cboAccountType.Items[item.AccountType].ToString();
                //chartOfAccountDto.SumFrom = item.SumFrom;
                //chartOfAccountDto.TaxCode = item.TaxCode;
                //listchartOfAccountDto.Add(chartOfAccountDto);

                listchartOfAccountDto.Add(item.AccountCode.ToString() + " | " + item.AccountName);
            }

            //grid.ItemsSource = listchartOfAccountDto;

            cboAccount.ItemsSource = listchartOfAccountDto;
        }
Ejemplo n.º 3
0
 public HomeController()
 {
     //_accountingService = new AccountingService();
     _unitOfWork        = new UnitOfWork();
     _logService        = new LogService(_unitOfWork);
     _accountingService = new AccountingService(_unitOfWork);
 }
        public void GetPaymentFor_ResultNotExistsInCache_FetchesTheResultFromDatabaseAndAddsToCache()
        {
            // arrange
            PaymentInfo expected = new PaymentInfo()
            {
                OrderID = 200
            };
            Mock <ObjectCache>            mockCache = new Mock <ObjectCache>();
            Mock <IPaymentInfoRepository> mockRepo  = new Mock <IPaymentInfoRepository>();

            mockRepo.Setup(r => r.GetPayment(It.Is <int>(p => p == 200))).Returns(expected);
            AccountingService sut = new AccountingService(mockRepo.Object, null, mockCache.Object);

            // act
            PaymentInfo actual = sut.GetPaymentFor(200);

            // assert
            Assert.AreEqual(expected, actual);
            mockCache.Verify(
                c => c.Set(
                    It.Is <string>(k => k.Equals("paymentFor200")),
                    It.Is <PaymentInfo>(p => p.OrderID == 200),
                    It.IsAny <CacheItemPolicy>(),
                    null),
                Times.Once());
        }
Ejemplo n.º 5
0
 public string getList2(string financePageJson, int classId, string code)
 {
     if (financePageJson != "")
     {
         FinancePage <AccountingItem> financePage = new FinancePage <AccountingItem>();
         financePage = FinanceJson.getFinanceJson().toObject <FinancePage <AccountingItem> >(financePageJson);
         try
         {
             asc         = new AccountingService();
             financePage = asc.getList2(financePage, classId, code);
             return(FinanceResultData.getFinanceResultData().success(200, financePage, "成功"));
         }
         catch (InvalidOperationException ex)
         {
             //身份验证不通过
             return(FinanceResultData.getFinanceResultData().fail(401, null, ex.Message));
         }
         catch (Exception ex)
         {
             //未知的错误
             return(FinanceResultData.getFinanceResultData().fail(500, null, "未知的错误"));
         }
     }
     else
     {
         return(FinanceResultData.getFinanceResultData().fail(500, null, "失败"));
     }
 }
Ejemplo n.º 6
0
        private bool SaveData()
        {
            if (!ValidateData())
            {
                return(false);
            }

            var accountingYear = AccountingYearBuilder();

            try
            {
                if (_addNewMode)
                {
                    AccountingService.AddAccountingYear(accountingYear);
                }
                else
                {
                    AccountingService.UpdateAccountingYear(accountingYear);
                }

                LoadAccountingYearData();

                ClearFields();
            }
            catch (Exception ex)
            {
                //LoggerHelper.Write(TraceEventType.Error, "Error in  SaveData in Accounting year setup. " + ex,
                //    new[] { Constants.LOGGING_CATEGORY_EXCEPTION });
                //MessageBox.Show("Oops!! Try again later.", "Error in  Processing");
                throw ex;
            }

            return(true);
        }
        private bool Save()
        {
            if (!IsValidData())
            {
                return(false);
            }

            var vouchers = GetVouchers();

            bool isAdded;

            if (_isNewRecord)
            {
                isAdded = AccountingService.AddUnpostedVoucher(vouchers);
            }
            else
            {
                isAdded = AccountingService.UpdateUnpostedVoucher(vouchers);
            }

            ClearFields();

            _isNewRecord = true;
            InitGrid();

            return(isAdded);
        }
Ejemplo n.º 8
0
 public string getListOfGrade(int classId, int grade, int code)
 {
     if (classId != 0 && grade != 0)
     {
         try
         {
             List <Accounting> accountingList = new List <Accounting>();
             asc            = new AccountingService();
             accountingList = asc.getList(classId, grade, code);
             if (accountingList != null)
             {
                 return(FinanceResultData.getFinanceResultData().success(200, accountingList, "成功"));
             }
             else
             {
                 return(FinanceResultData.getFinanceResultData().fail(500, null, "失败"));
             }
         }
         catch (InvalidOperationException ex)
         {
             //身份验证不通过
             return(FinanceResultData.getFinanceResultData().fail(401, null, ex.Message));
         }
         catch (Exception ex)
         {
             //未知的错误
             return(FinanceResultData.getFinanceResultData().fail(500, null, "未知的错误"));
         }
     }
     else
     {
         return(FinanceResultData.getFinanceResultData().fail(500, null, "失败"));
     }
 }
Ejemplo n.º 9
0
 public AccountingController()
 {
     _accService      = new AccountingService();
     _customerService = new CustomerService();
     _hardwareService = new HardwareService();
     _softwareService = new SoftwareService();
 }
        private bool Save()
        {
            if (!IsValidData())
            {
                return(false);
            }

            var template = GetTemplate();

            bool isAdded;

            if (_isNewRecord)
            {
                isAdded = AccountingService.AddVoucherTemplate(template);
            }
            else
            {
                isAdded = AccountingService.UpdateVoucherTemplate(template);
            }

            ClearFields();

            _isNewRecord = true;
            InitGrid();

            return(isAdded);
        }
Ejemplo n.º 11
0
        private void LoadAccountingTransactionData()
        {
            var listTransactionPreview = new List <TransactionPreview>();

            var transactionData = AccountingService.GetPrePostingTransaction(ShatedData.ApplicationState.SelectedAccountingYearId, ShatedData.ApplicationState.SelectedCompanyId);

            var transactionGroupData = transactionData.GroupBy(e => e.AccountCode);

            foreach (var groupItem in transactionGroupData)
            {
                var accountCode     = groupItem.Key;
                var listTransaction = groupItem.ToList();

                var transaction = listTransaction.First();

                var transactionPreviewItem = new TransactionPreview {
                    AccountName = transaction.AccountName, BeforeTransactionBalance = transaction.BalanceBefore,
                    Debit       = transaction.DebitAmount, Credit = transaction.CreditAmount, TotalDebitCredit = transaction.TotalDebitCredit, AfterTransactionBalance = transaction.BalanceBefore + transaction.DebitAmount - transaction.CreditAmount
                };
                transactionPreviewItem.ItemDetail = listTransaction;

                listTransactionPreview.Add(transactionPreviewItem);
                //var transactionPreviewItemDetail= new List<AccountingTransactionPrePostingDto>();
                // foreach (var transactionItem in listTransaction)
                // {

                // }
            }
            grid.ItemsSource = listTransactionPreview;
        }
        private bool DeleteData()
        {
            if (_selectedAccountCode == -1)
            {
                return(false);
            }

            var dialogResult = MessageBox.Show("Delete this Account", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (dialogResult != MessageBoxResult.Yes)
            {
                return(false);
            }
            try
            {
                if (AccountingService.DeleteAccount(new tChartOfAccount {
                    CompanyId = ShatedData.ApplicationState.SelectedCompanyId, AccountCode = _selectedAccountCode
                }) == 0)
                {
                    return(false);
                }

                _selectedAccountCode = -1;

                LoadChartOfAccount();

                ClearFields();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 13
0
        private bool Save()
        {
            if (!IsValidData())
            {
                return(false);
            }

            var tax = GetTax();

            bool isAdded;

            if (_isNewRecord)
            {
                isAdded = AccountingService.AddTax(tax);
            }
            else
            {
                isAdded = AccountingService.UpdateTax(tax);
            }

            ClearFields();

            _isNewRecord = true;
            InitGrid();

            return(isAdded);
        }
Ejemplo n.º 14
0
        private void LoadAccountingYearData()
        {
            grid.ItemsSource = null;

            var listAccountingYear = AccountingService.GetAllAccountingYears();

            grid.ItemsSource = listAccountingYear;
        }
        private void InitGrid()
        {
            _tVoucherTemplates = AccountingService.GetAllVoucherTemplates();

            GenerateCombo();

            grid.ItemsSource = _tVoucherTemplates;
        }
Ejemplo n.º 16
0
 public HomeController()
 {
     if (dataInit == null)
     {
         dataInit = this.GetMoneyUsageData();
     }
     if (_accountingService == null)
     {
         _accountingService = new AccountingService();
     }
 }
        public static void AddAccountingClient(this IServiceCollection services, IConfiguration configuration)
        {
            var url    = configuration["RestClients:AccountingService"];
            var client = new RestClient(url)
            {
                ThrowOnAnyError = true
            };
            var accountingService = new AccountingService(client);

            services.AddSingleton <IAccountingService>(accountingService);
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            var config     = new LoggingConfiguration();
            var logconsole = new ConsoleTarget("logconsole");

            config.AddRule(LogLevel.Trace, LogLevel.Fatal, logconsole);
            LogManager.Configuration = config;

            var accounting    = new AccountingService().WithLogging();
            var clientService = new ClientService(accounting).WithLogging();

            Test(clientService);
        }
Ejemplo n.º 19
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //TODO: dirty work here , use DI
            IAnalyzeExcelService analyzeExcelService = new AnalyzeShopeeExcelSevice();
            IStockService        stockService        = new StockServiceService();
            IShippmentService    shippmentService    = new ShippmentServiceService();
            ICreateSaleService   createSaleService   = new CreateSaleService();
            IAccountingService   accountingService   = new AccountingService();

            Application.Run(new MainForm(new ShopeeController(
                                             analyzeExcelService, stockService, shippmentService, createSaleService, accountingService)));
        }
Ejemplo n.º 20
0
        private void GenerateCurrencyCombo()
        {
            var currencies = AccountingService.GetAllCurrencies() as List <tCurrency>;

            if (currencies != null)
            {
                var source = currencies.Select(a => new OfficeFinancial.Common.ComboBoxItem {
                    Key = a.Code, Value = a.Code
                }).ToList();

                cboCurrency.DisplayMemberPath = "Value";
                cboCurrency.SelectedValuePath = "Key";
                cboCurrency.ItemsSource       = source;
            }
        }
        private void GenerateCombo()
        {
            var accounts = (List <tChartOfAccount>)AccountingService.GetAllChartOfAccount();
            var source   = accounts.Select(a => new OfficeFinancial.Common.ComboBoxItem {
                Key = a.AccountCode.ToString(), Value = a.AccountCode + " | " + a.AccountName
            }).ToList();

            //source.Insert(0,null);

            cboCreditAccount.DisplayMemberPath = "Value";
            cboCreditAccount.SelectedValuePath = "Key";
            cboCreditAccount.ItemsSource       = source;

            cboDebitAccount.DisplayMemberPath = "Value";
            cboDebitAccount.SelectedValuePath = "Key";
            cboDebitAccount.ItemsSource       = source;
        }
Ejemplo n.º 22
0
 private void TxtShortCodeLostFocus(object sender, RoutedEventArgs e)
 {
     try
     {
         var template = AccountingService.GetlVoucherTemplateByCode(txtShortCode.Text,
                                                                    ApplicationState.SelectedCompanyId);
         if (template != null)
         {
             cboDebitAccount.SelectedValue  = template.DebitAccountCode;
             cboCreditAccount.SelectedValue = template.CreditAccountCode;
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "System Message", MessageBoxButton.OK,
                         MessageBoxImage.Error);
     }
 }
        public void GetPaymentFor_ResultExistsInCache_ReturnsThePaymentResult()
        {
            // arrange
            PaymentInfo expected = new PaymentInfo()
            {
                OrderID = 10
            };
            Mock <ObjectCache> mockCache = new Mock <ObjectCache>();

            mockCache.SetupGet(c => c["paymentFor10"]).Returns(expected);
            AccountingService sut = new AccountingService(null, null, mockCache.Object);

            // act
            PaymentInfo actual = sut.GetPaymentFor(10);

            // assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 24
0
 public string balanceCheck()
 {
     try
     {
         asc = new AccountingService();
         return(FinanceResultData.getFinanceResultData().success(200, asc.balanceCheck(), "成功"));
     }
     catch (InvalidOperationException ex)
     {
         //身份验证不通过
         return(FinanceResultData.getFinanceResultData().fail(401, null, ex.Message));
     }
     catch (Exception ex)
     {
         //未知的错误
         return(FinanceResultData.getFinanceResultData().fail(500, null, "未知的错误"));
     }
 }
        public void ProcessPayment_GivenANewPayment_ProcessesAndAddsThePaymentToDatabase()
        {
            // arrange
            Mock <IPaymentInfoRepository> mockRepo = new Mock <IPaymentInfoRepository>();
            PaymentInfo payment = new PaymentInfo()
            {
                OrderID = 10
            };
            AccountingService sut = new AccountingService(mockRepo.Object, null, null);

            // act
            sut.ProcessPayment(payment);

            // assert
            mockRepo.Verify(
                r => r.AddPayment(It.Is <PaymentInfo>(
                                      p => p.OrderID == 10 && p.ReceivedDate != DateTime.MinValue && p.IsReceived == true)),
                Times.Once());
        }
Ejemplo n.º 26
0
 public string updAccounting(string itemJson)
 {
     if (itemJson != "")
     {
         AccountingItem accountingItem = new AccountingItem();
         accountingItem = FinanceJson.getFinanceJson().toObject <AccountingItem>(itemJson);
         if (accountingItem != null)
         {
             try
             {
                 asc            = new AccountingService();
                 accountingItem = asc.updAccounting(accountingItem);
                 if (accountingItem != null)
                 {
                     return(FinanceResultData.getFinanceResultData().success(200, accountingItem, "成功"));
                 }
                 else
                 {
                     return(FinanceResultData.getFinanceResultData().fail(500, null, "失败"));
                 }
             }
             catch (InvalidOperationException ex)
             {
                 //身份验证不通过
                 return(FinanceResultData.getFinanceResultData().fail(401, null, ex.Message));
             }
             catch (Exception ex)
             {
                 //未知的错误
                 return(FinanceResultData.getFinanceResultData().fail(500, null, "未知的错误"));
             }
         }
         else
         {
             return(FinanceResultData.getFinanceResultData().fail(500, null, "失败"));
         }
     }
     else
     {
         return(FinanceResultData.getFinanceResultData().fail(500, null, "失败"));
     }
 }
Ejemplo n.º 27
0
        public AccountController()
            : this(Startup.UserManagerFactory(), Startup.OAuthOptions.AccessTokenFormat)
        {
            var account = CloudConfiguration.GetStorageAccount("DataConnectionString");

            this._accountingService = new AccountingService(
                new AzureRepository <AzureAccount, Account>(account),
                new AzureRepository <AzureCurrencyType, CurrencyType>(account),
                new AzureRepository <AzureAccountBalance, AccountBalance>(account),
                new AzureRepository <AzureAccountLogin, AccountLogin>(account),
                new AzureRepository <AzureAccountSetAccounts, AccountSetAccounts>(account),
                new AccountsFactory(
                    new AzureRepository <AzureAccount, Account>(account),
                    new AzureRepository <AzureCurrencyType, CurrencyType>(account),
                    new AzureRepository <AzureAccountBalance, AccountBalance>(account),
                    new AzureRepository <AzureAccountLogin, AccountLogin>(account),
                    new AzureRepository <AzureAccountSet, AccountSet>(account),
                    new AzureRepository <AzureAccountSetAccounts, AccountSetAccounts>(account),
                    new AzureScopeableUnitOfWorkFactory()));
        }
Ejemplo n.º 28
0
        public void TestGetNPV()
        {
            // arrange
            double        investmentAmount = -500;
            double        interestRate     = 10;
            List <double> cashFlow         = new List <double> {
                570, 585, 599
            };
            var cashFlowArray = cashFlow.ToArray();

            cashFlow.Insert(0, investmentAmount);
            AccountingService svc = new AccountingService();

            // act
            var method1Result = svc.CalculateNPV(cashFlow, interestRate);
            var builtInMethod = Financial.NPV(interestRate / 100, ref cashFlowArray) + investmentAmount;

            //assert
            Assert.AreEqual(builtInMethod, method1Result);
        }
        public ChartOfAccount()
        {
            InitializeComponent();

            try
            {
                _listTaxSetup = AccountingService.GetAllTaxes();

                LoadAccountTypeCombo();
                LoadTaxCombo();
                LoadChartOfAccount();

                ClearFields();

                _addNewMode = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "System Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 30
0
 public string newAccounting(string itemJson)
 {
     if (itemJson == "")
     {
         return(FinanceResultData.getFinanceResultData().fail(500, null, "无参数"));
     }
     else
     {
         Accounting accounting = FinanceJson.getFinanceJson().toObject <Accounting>(itemJson);
         if (accounting != null)
         {
             try
             {
                 asc = new AccountingService();
                 if (asc.newAccounting(accounting))
                 {
                     return(FinanceResultData.getFinanceResultData().success(200, null, "添加成功"));
                 }
                 else
                 {
                     return(FinanceResultData.getFinanceResultData().fail(500, null, "失败"));
                 }
             }
             catch (InvalidOperationException ex)
             {
                 //身份验证不通过
                 return(FinanceResultData.getFinanceResultData().fail(401, null, ex.Message));
             }
             catch (Exception ex)
             {
                 //未知的错误
                 return(FinanceResultData.getFinanceResultData().fail(500, null, "未知的错误"));
             }
         }
         else
         {
             return(FinanceResultData.getFinanceResultData().fail(500, null, "失败"));
         }
     }
 }