Example #1
0
        public ActionResult Create(GLAccountViewModel model)
        {
            ViewData["Branches"]     = context.Branches.ToList();
            ViewData["GLCategories"] = context.GLCategories.ToList();
            if (ModelState.IsValid)
            {
                GLAccount glAccount = new GLAccount();
                glAccount.AccNo      = Helper.GenerateGLAccNo(model.GLCategoryID);
                glAccount.Name       = model.Name;
                glAccount.Balance    = model.Balance;
                glAccount.Branch     = context.Branches.Find(model.BranchID);
                glAccount.GLCategory = context.GLCategories.Find(model.GLCategoryID);

                context.GLAccounts.Add(glAccount);
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
 static public bool DeleteGLAccount(GLAccount tempGL)
 {
     if (tempGL == null)
     {
         return(false);
     }
     if (MessageBox.Show("Delete Account " + tempGL.ToString() + "?", "Confirm Delete", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         if (new DataLayer.Repostiory().Remove(tempGL.ActIndx) == -1)
         {
             MessageBox.Show(tempGL.ToString() + " Deleted.");
             return(true);
         }
         else
         {
             MessageBox.Show("Deletion failed. Check GL Transactions for any activity against this account.\n\nAccounts used in GL Transactions cannot be deleted.");
         }
     }
     return(false);
 }
Example #3
0
        public async Task CreateOrUpdate_Update_Success(
            GLAccount pGLAccountInput,
            GLAccount pGLAccountResult,
            [Frozen] IBlue10AsyncClient pBlue10AsyncCLient,
            GLAccountService pGLAccountService)
        {
            // Setup services
            pBlue10AsyncCLient.EditGLAccountAsync(Arg.Any <GLAccount>()).Returns(pGLAccountResult);

            // Test
            var fResult = await pGLAccountService.CreateOrUpdate(pGLAccountInput);

            // Validate
            pBlue10AsyncCLient.Received(1);
            await pBlue10AsyncCLient.Received().EditGLAccountAsync(Arg.Is <GLAccount>(x => x.Equals(pGLAccountInput)));

            fResult.Should().BeOfType <BaseResultModel <GLAccount> >();
            fResult.ErrorMessage.Should().BeNull();
            fResult.Object.Should().Be(pGLAccountResult);
        }
        public HttpResponseMessage CreateGLAccount(GLAccountDto glAccountDto)
        {
            ValidationChecks(glAccountDto);
            if (!errorMessage.Equals(""))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage));
            }
            var generalLedgerAccount = new GLAccount
            {
                GlCategoriesId = glAccountDto.CategoriesId,
                BranchId       = glAccountDto.BranchId,
                Name           = glAccountDto.Name,
                Code           = getCode(glAccountDto.CategoriesId)
            };

            //Mapper.Map(generalLedgerCategoryViewModel, generalLedgerCategory);
            _context.GlAccounts.Add(generalLedgerAccount);
            _context.SaveChanges();
            return(Request.CreateResponse(HttpStatusCode.OK, "GL Account Created Successfully"));
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["user"] == null)
            {
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                if (!new UserSecurity().CheckFormPermission((int)Global.formSecurity.ViewGLAccount, Request.Cookies["user"]["Permission"].ToString()))
                {
                    Response.Redirect("~/Finance_Module/UnAuthorized.aspx");
                }
            }
            if (Convert.ToInt32(Request.QueryString["GlAccountID"].ToString()) > 0)
            {
                GLAccount glaccount = new GLAccount();
                glaccount.get(Convert.ToInt32(Request.QueryString["GlAccountID"].ToString()));
                if (Convert.ToInt32(glaccount.ParentAcctID.ToString()) != 0)
                {
                    GLAccount glaccount2 = new GLAccount();
                    glaccount2.get(Convert.ToInt32(glaccount.ParentAcctID.ToString()));
                    lblParentGL.Text = glaccount2.Name.ToString();
                }
                else
                {
                    lblParentGL.Text = "";
                }
                lblAccountName.Text = glaccount.Name.ToString();
                lblAcctStatus.Text  = glaccount.Status.ToString();
                lblBalance.Text     = glaccount.Balance.ToString();

                lblacctcode.Text          = glaccount.AcctCode.ToString();
                lblDesc.Text              = glaccount.Description.ToString();
                ddlAcctType.SelectedValue = glaccount.AcctType.ToString();
                ASPxGridView1.DataSource  = glaccount.getList(glaccount.ID);
                ASPxGridView1.DataBind();

                ASPxGridView2.DataSource = glaccount.getAcctTransactions(glaccount.ID);
                ASPxGridView2.DataBind();
            }
        }
Example #6
0
        // GET: GLAccount/Edit/5
        public ActionResult Edit(int?id)
        {
            ViewData["Branches"]     = context.Branches.ToList();
            ViewData["GLCategories"] = context.GLCategories.ToList();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GLAccount glAccount = context.GLAccounts.Find(id);

            if (glAccount == null)
            {
                return(HttpNotFound());
            }

            GLAccountViewModel model = new GLAccountViewModel();

            model.Name     = glAccount.Name;
            model.BranchID = glAccount.Branch.ID;

            return(View(model));
        }
        private void BtSave_Click(object sender, RoutedEventArgs e)
        {
            GLAccount tempGL;

            GLAccounts = repo.GetAll();
            GLAccount findGL = GLAccounts.FirstOrDefault(i => i.ActNmbr == tbActNmbr.Text);
            bool      isNew  = false;

            if (tbActDscr.Text.Trim() == "" || tbActNmbr.Text.Trim() == "")
            {
                MessageBox.Show("Account Number and Account Descriptions are required fields.");
                return;
            }
            if (findGL == null)
            {
                tempGL = new GLAccount();
                isNew  = true;
            }
            else
            {
                tempGL = findGL;
            }
            tempGL.ActNmbr    = tbActNmbr.Text;
            tempGL.ActDscr    = tbActDscr.Text;
            tempGL.IsActive   = (bool)ckIsActive.IsChecked;
            tempGL.CanPstDrct = (bool)ckCanDirPst.IsChecked;
            tempGL.HasDRBal   = (bool)ckHasDRBal.IsChecked;
            tempGL            = repo.Save(tempGL);
            if (isNew)
            {
                GLAccounts.Add(repo.Save(tempGL));
                count++;
            }
            index = GLAccounts.IndexOf(tempGL);
            MessageBox.Show("Account Saved.");
            DataContext = repo.Find(tempGL.ActNmbr);
        }
Example #8
0
 public bool DeleteGLAccount(GLAccount pGLAccount) => mBlue10Async.DeleteGLAccountAsync(pGLAccount).Sync();
Example #9
0
 public GLAccount EditGLAccount(GLAccount pGLAccount) => mBlue10Async.EditGLAccountAsync(pGLAccount).Sync();
Example #10
0
 public GLAccount AddGLAccount(GLAccount pGLAccount) => mBlue10Async.AddGLAccountAsync(pGLAccount).Sync();
        private bool IsAssetOrExpense(GLAccount glAccount)
        {
            var a = glAccount.GLCategory.CategoryType;

            return(a == GLCategoryType.Asset || a == GLCategoryType.Expense);
        }
Example #12
0
        public Get_ChartGLAccounts(string companyName)
        {
            const string clientId     = "b4b7919a-f51c-4272-9576-dbcccffb8764";
            const string clientSecret = "eWfc7W7BQXYZ";

            //This can be any url as long as it is identical to the callback url you specified for your app in the App Center.
            var callbackUrl = new Uri("http://websocketclient.local");

            var connector = new Connector(clientId, clientSecret, callbackUrl);
            var client    = new ExactOnlineClient(connector.EndPoint, connector.GetAccessToken);


            using (SpreadsheetDocument document = SpreadsheetDocument.Open(@"E:\робочий стіл 2016\Gob Progect\exactonline-api-dotnet-client-master11\exactonline-api-dotnet-client-master\src\ConsoleApplication\Excel\1 Chart of Accounts revised.xlsx", false))
            {
                // open the document read-only

                SharedStringTable sharedStringTable = document.WorkbookPart.SharedStringTablePart.SharedStringTable;
                string            cellValue         = null;

                WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.WorksheetParts.Where(x => x.Uri.OriginalString.Contains("sheet1")).Single();

                foreach (SheetData sheetData in worksheetPart.Worksheet.Elements <SheetData>())
                {
                    if (sheetData.HasChildren)
                    {
                        foreach (Row row in sheetData.Elements <Row>())
                        {
                            foreach (Cell cell in row.Elements <Cell>())
                            {
                                cellValue = cell.InnerText;

                                if (cell.DataType != null && cell.DataType == CellValues.SharedString)
                                {
                                    Console.WriteLine("cell val: " + sharedStringTable.ElementAt(Int32.Parse(cellValue)).InnerText);
                                }
                                else
                                {
                                    Console.WriteLine("else: " + cellValue);
                                }
                            }
                        }
                    }
                }
                document.Close();
            }



            try
            {
                //GLAccount document = new GLAccount
                //{
                //    Code = "1001",
                //    Description = "Stock",
                //    TypeDescription = "Current Assets",
                //    BalanceSide = "D",
                //    BalanceType = "B",
                //    Type = 32
                //};

                //bool createdClient = client.For<GLAccount>().Insert(ref document);

                //GLAccount document1 = new GLAccount
                //{
                //    Code = "1220",
                //    Description = "Bank Deposit A/C 19057399",
                //    TypeDescription = "Current Assets",
                //    BalanceSide = "D",
                //    BalanceType = "B",
                //    Type = 12
                //};

                //bool createdClient1 = client.For<GLAccount>().Insert(ref document1);


                //GLAccount document2 = new GLAccount
                //{
                //    Code = "1250",
                //    Description = "Credit Card Account 0793 Paul",
                //    TypeDescription = "Current Assets"
                //};

                //bool createdClient2 = client.For<GLAccount>().Insert(ref document2);

                GLAccount document4 = new GLAccount
                {
                    Code            = "1260",
                    Description     = "Pauls Cash Expenses",
                    TypeDescription = "Current Liabilities"
                };

                bool createdClient4 = client.For <GLAccount>().Insert(ref document4);

                GLAccount document5 = new GLAccount
                {
                    Code            = "2210",
                    Description     = "PAYE/PRSI Payable",
                    TypeDescription = "Current Liabilities"
                };

                bool createdClient5 = client.For <GLAccount>().Insert(ref document5);
            }
            catch (Exception ex)
            {
                Console.WriteLine("SDO Generated the Following Error: \n\n" + ex.Message, "Error!");
            }
        }
Example #13
0
 public bool DeleteGLAccount(GLAccount pGLAccount) =>
 SyncHelper.RunAsyncAsSync(() =>
                           DeleteItem($"{GLACCOUNTS}/{pGLAccount.Id}"));
        protected async Task HandleValidSubmit()
        {
            UserName = await _sessionStorageService.GetItemAsync <string>("UserName");

            CompanyId = await _sessionStorageService.GetItemAsync <string>("CompanyId");

            bool _rev;
            bool _exp;
            bool _cshacc;
            bool _outvat;


            if (glAccountView.revenue == "N")
            {
                _rev = false;
            }
            else
            {
                _rev = true;
            }


            if (glAccountView.expense == "N")
            {
                _exp = false;
            }
            else
            {
                _exp = true;
            }


            if (glAccountView.cashAccount == "N")
            {
                _cshacc = false;
            }
            else
            {
                _cshacc = true;
            }


            if (glAccountView.outputVatAccount == "N")
            {
                _outvat = false;
            }
            else
            {
                _outvat = true;
            }


            if (string.IsNullOrEmpty(accountId))
            {
                //var data = await appDBContext.GLAccounts.ToListAsync();
                //.Select(a => new { id = a.id, company = a.company, lastName = a.lastName, firstName = a.firstName, middleName = a.middleName, contactNumber = a.contactNumber, emailAddress = a.emailAddress })

                int maxRow = appDBContext.GLAccounts
                             .Where(a => a.companyId.Equals(CompanyId) && a.deleted.Equals(false))
                             .Max(a => a.rowOrder);
                int _maxRow;
                if (maxRow == null)
                {
                    _maxRow = 1;
                }
                else
                {
                    _maxRow = maxRow + 1;
                }

                GLAccount gl = new GLAccount()
                {
                    accountId        = Guid.NewGuid(),
                    createDate       = DateTime.Now,
                    createdBy        = UserName,
                    companyId        = CompanyId,
                    accountCode      = glAccountView.accountCode,
                    accountDesc      = glAccountView.accountDesc,
                    balance          = 0,
                    revenue          = _rev,
                    expense          = _exp,
                    cashAccount      = false,
                    rowOrder         = _maxRow,
                    outputVatAccount = _outvat
                };


                appDBContext.GLAccounts.Add(gl);
                await appDBContext.SaveChangesAsync();
            }

            else
            {
                var data = await appDBContext.GLAccounts
                           //.Select(a => new { id = a.id, company = a.company, lastName = a.lastName, firstName = a.firstName, middleName = a.middleName, contactNumber = a.contactNumber, emailAddress = a.emailAddress })
                           .Include(a => a.company)
                           .Where(r => r.accountId.Equals(Guid.Parse(accountId)) && r.companyId.Equals(CompanyId) && r.deleted.Equals(false)).FirstOrDefaultAsync();


                data.updateDate       = DateTime.Now;
                data.updatedBy        = UserName;
                data.accountCode      = glAccountView.accountCode;
                data.accountDesc      = glAccountView.accountDesc;
                data.balance          = glAccountView.balance;
                data.revenue          = _rev;
                data.expense          = _exp;
                data.outputVatAccount = _outvat;
                //data.cashAccount = _cshacc;
                //data.rowOrder = _maxRow;

                appDBContext.GLAccounts.Update(data);
                await appDBContext.SaveChangesAsync();
            }



            StateHasChanged();

            NavigateToList();
        }
 public CurrentAccountConfig()
 {
     CustomerCurrentAccount
         = new GLAccount();
 }
Example #16
0
 public AccountPostingBalanceClient(AccountPostingBalance accPostingbal, GLAccount account)
 {
     accPostingBalance = accPostingbal;
     glAccount         = account;
 }
Example #17
0
 public Task <bool> DeleteGLAccountAsync(GLAccount pGLAccount) =>
 DeleteItem($"{GLACCOUNTS}/{pGLAccount.Id}");
Example #18
0
    public int save(DateTime AEDate)
    {
        int res = validate();

        if (res == 0)
        {
            SqlParameter[] param = new SqlParameter[5];
            param[0] = DataAccess.AddParamter("@LastModifiedDate", DateTime.Now, SqlDbType.DateTime, 50);
            param[1] = DataAccess.AddParamter("@Creationdate", AEDate, SqlDbType.DateTime, 50);
            param[2] = DataAccess.AddParamter("@OperatorID", _operatorID, SqlDbType.Int, 50);
            param[3] = DataAccess.AddParamter("@Description", _description, SqlDbType.NVarChar, 500);

            param[4] = DataAccess.AddParamter("@Amount", _amount, SqlDbType.Decimal, 50);


            string sql = "insert into Fin_JournalEntry(CreationDate,LastModifiedDate,OperatorID,Amount,Description) values (@Creationdate,@LastModifiedDate,@OperatorID,@Amount,@Description)";
            DataAccess.ExecuteSQLNonQuery(sql, param);
            //get last id
            sql = "select max(id)as lastID from Fin_JournalEntry";
            DataTable dt = DataAccess.ExecuteSQLQuery(sql);
            if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
            {
                _id = int.Parse(dt.Rows[0]["lastID"].ToString());
                SqlParameter[] param2 = new SqlParameter[9];
                decimal        dpAmt, crAmt;
                dpAmt = 0;
                crAmt = 0;

                for (int i = 0; i < _journalEntryRows.Rows.Count; i++)
                {
                    decimal.TryParse(_journalEntryRows.Rows[i]["Depit"].ToString(), out dpAmt);
                    decimal.TryParse(_journalEntryRows.Rows[i]["Credit"].ToString(), out crAmt);
                    param2[0] = DataAccess.AddParamter("@LastModifiedDate", DateTime.Now, SqlDbType.DateTime, 50);
                    param2[1] = DataAccess.AddParamter("@Creationdate", DateTime.Now, SqlDbType.DateTime, 50);
                    param2[2] = DataAccess.AddParamter("@OperatorID", _operatorID, SqlDbType.Int, 50);
                    param2[3] = DataAccess.AddParamter("@GLAccountID", _journalEntryRows.Rows[i]["GLAccountID"], SqlDbType.Int, 50);
                    //CreditAmount
                    param2[4] = DataAccess.AddParamter("@CreditAmount", crAmt, SqlDbType.Decimal, 50);
                    param2[5] = DataAccess.AddParamter("@DepitAmount", dpAmt, SqlDbType.Decimal, 50);

                    param2[6] = DataAccess.AddParamter("@JournalEntryID", _id, SqlDbType.Int, 50);
                    param2[7] = DataAccess.AddParamter("@Memo", _journalEntryRows.Rows[i]["Memo"], SqlDbType.NVarChar, 500);

                    param2[8] = DataAccess.AddParamter("@AcctBalance", new GLAccount().getAcctBalance(Convert.ToInt32(_journalEntryRows.Rows[i]["GLAccountID"].ToString())), SqlDbType.Decimal, 50);
                    sql       = "insert into Fin_JournalEntryRows(CreationDate,LastModifiedDate,OperatorID,GLAccountID,CreditAmount,DepitAmount,JournalEntryID,Memo,AcctBalance) VALUES (@CreationDate,@LastModifiedDate,@OperatorID,@GLAccountID,@CreditAmount,@DepitAmount,@JournalEntryID,@Memo,@AcctBalance)";
                    DataAccess.ExecuteSQLNonQuery(sql, param2);
                    //post the JE to update the acount balance
                    int acctID = Convert.ToInt32(_journalEntryRows.Rows[i]["GLAccountID"].ToString());
                    if (int.Parse(_journalEntryRows.Rows[i]["AcctType"].ToString()) == 0) // GL Account
                    {
                        GLAccount gl = new GLAccount();
                        gl.get(acctID);

                        //1--> asset     --> depit
                        //2--> liability --> credit
                        //3--> equity    --> credit
                        //4--> income    --> credit
                        //5--> expense   --> depit


                        if (gl.AcctType == 1 || gl.AcctType == 5)//depit acount (asset and expenses)
                        {
                            if (dpAmt > 0)
                            {
                                gl.increaseAcctBalanc(dpAmt, gl.ID);
                            }
                            else if (crAmt > 0)
                            {
                                gl.decreaseAcctBalanc(crAmt, gl.ID);
                            }
                        }
                        else //credit acount (equity,liablity, income)
                        {
                            if (dpAmt > 0)
                            {
                                gl.decreaseAcctBalanc(dpAmt, gl.ID);
                            }
                            else if (crAmt > 0)
                            {
                                gl.increaseAcctBalanc(crAmt, gl.ID);
                            }
                        }
                    }
                    else
                    {
                        //bank account
                        if (dpAmt > 0)
                        {
                            new Bank().decreaseAcctBalanc(dpAmt, acctID);
                        }
                        else if (crAmt > 0)
                        {
                            new Bank().increaseAcctBalanc(crAmt, acctID);
                        }
                    }
                }
                return(_id);
            }
        }

        return(res);
    }
Example #19
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            //string name = "MyName";
            //DomainObject1 theObject = ObjectSpace.FindObject<DomainObject1>(CriteriaOperator.Parse("Name=?", name));
            //if(theObject == null) {
            //    theObject = ObjectSpace.CreateObject<DomainObject1>();
            //    theObject.Name = name;
            //}
            Employee sampleUser = ObjectSpace.FindObject <Employee>(new BinaryOperator("UserName", "User"));

            if (sampleUser == null)
            {
                sampleUser           = ObjectSpace.CreateObject <Employee>();
                sampleUser.UserName  = "******";
                sampleUser.FirstName = "Sample";
                sampleUser.LastName  = "User";
                sampleUser.SetPassword("");
            }
            EmployeeRole defaultRole = CreateDefaultRole();

            sampleUser.EmployeeRoles.Add(defaultRole);

            Employee userAdmin = ObjectSpace.FindObject <Employee>(new BinaryOperator("UserName", "Admin"));

            if (userAdmin == null)
            {
                userAdmin           = ObjectSpace.CreateObject <Employee>();
                userAdmin.UserName  = "******";
                userAdmin.FirstName = "Super";
                userAdmin.LastName  = "Admin";
                // Set a password if the standard authentication type is used
                userAdmin.SetPassword("");
            }
            // If a role with the Administrators name doesn't exist in the database, create this role
            EmployeeRole adminRole = ObjectSpace.FindObject <EmployeeRole>(new BinaryOperator("Name", "Administrators"));

            if (adminRole == null)
            {
                adminRole      = ObjectSpace.CreateObject <EmployeeRole>();
                adminRole.Name = "Administrators";
            }
            adminRole.IsAdministrative = true;
            userAdmin.EmployeeRoles.Add(adminRole);
            ObjectSpace.CommitChanges(); //This line persists created object(s).


            XmlDocument glDocument = new XmlDocument();

            glDocument.LoadXml(GetInitialData("GLAccount.xml"));
            XmlElement  xelRoot  = glDocument.DocumentElement;
            XmlNodeList xnlNodes = xelRoot.SelectNodes("/data-set/record");

            foreach (XmlNode xndNode in xnlNodes)
            {
                GLAccount glAccount = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["Account"].InnerText));
                if (glAccount == null)
                {
                    glAccount = ObjectSpace.CreateObject <GLAccount>();
                    glAccount.AccountNumber    = xndNode["Account"].InnerText;
                    glAccount.AccountName      = xndNode["Name"].InnerText;
                    glAccount.AccountType      = (GLACcountType)Convert.ToInt16(xndNode["Type"].InnerText);
                    glAccount.RetainedEarnings = Convert.ToBoolean(xndNode["RetainedEarnings"].InnerText);

                    glAccount.Save();
                }
            }

            glDocument.LoadXml(GetInitialData("Currency.xml"));
            xelRoot  = glDocument.DocumentElement;
            xnlNodes = xelRoot.SelectNodes("/data-set/record");
            foreach (XmlNode xndNode in xnlNodes)
            {
                Currency currency = ObjectSpace.FindObject <Currency>(new BinaryOperator("CurrencyCode", xndNode["CurrencyCode"].InnerText));
                if (currency == null)
                {
                    currency = ObjectSpace.CreateObject <Currency>();
                    currency.CurrencyCode       = xndNode["CurrencyCode"].InnerText;
                    currency.Name               = xndNode["Name"].InnerText;
                    currency.ExchangeRate       = Convert.ToDecimal(xndNode["ExchangeRate"].InnerText);
                    currency.AccountsPayable    = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["AccountsPayable"].InnerText));
                    currency.APDiscounts        = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["APDiscounts"].InnerText));
                    currency.AccountsReceivable = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["AccountsReceivable"].InnerText));
                    currency.ARDiscounts        = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["ARDiscounts"].InnerText));
                    currency.DefaultARWriteOffs = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["DefaultARWriteOffs"].InnerText));
                    currency.GainLossOnExchange = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["GainLossOnExchange"].InnerText));

                    currency.Save();
                }
            }

            glDocument.LoadXml(GetInitialData("Bank.xml"));
            xelRoot  = glDocument.DocumentElement;
            xnlNodes = xelRoot.SelectNodes("/data-set/record");
            foreach (XmlNode xndNode in xnlNodes)
            {
                Bank bank = ObjectSpace.FindObject <Bank>(new BinaryOperator("Name", xndNode["Name"].InnerText));
                if (bank == null)
                {
                    bank           = ObjectSpace.CreateObject <Bank>();
                    bank.Name      = xndNode["Name"].InnerText;
                    bank.GLAccount = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["GLAccount"].InnerText));
                    bank.Currency  = ObjectSpace.FindObject <Currency>(new BinaryOperator("CurrencyCode", xndNode["CurrencyCode"].InnerText));

                    bank.Save();
                }
            }

            glDocument.LoadXml(GetInitialData("Warehouse.xml"));
            xelRoot  = glDocument.DocumentElement;
            xnlNodes = xelRoot.SelectNodes("/data-set/record");
            foreach (XmlNode xndNode in xnlNodes)
            {
                Warehouse warehouse = ObjectSpace.FindObject <Warehouse>(new BinaryOperator("Name", xndNode["Name"].InnerText));
                if (warehouse == null)
                {
                    warehouse      = ObjectSpace.CreateObject <Warehouse>();
                    warehouse.Name = xndNode["Name"].InnerText;

                    warehouse.Save();
                }
            }

            glDocument.LoadXml(GetInitialData("ItemType.xml"));
            xelRoot  = glDocument.DocumentElement;
            xnlNodes = xelRoot.SelectNodes("/data-set/record");
            foreach (XmlNode xndNode in xnlNodes)
            {
                ItemType itemType = ObjectSpace.FindObject <ItemType>(new BinaryOperator("Name", xndNode["Name"].InnerText));
                if (itemType == null)
                {
                    itemType               = ObjectSpace.CreateObject <ItemType>();
                    itemType.Name          = xndNode["Name"].InnerText;
                    itemType.Inventory     = Convert.ToBoolean(xndNode["Inventory"].InnerText);
                    itemType.CostingMethod = (CostingMethod)Convert.ToInt16(xndNode["CostingMethod"].InnerText);

                    itemType.Save();
                }
            }

            if (ObjectSpace.GetObjectsCount(typeof(SystemSetting), null) == 0)
            {
                SystemSetting systemSetting = ObjectSpace.CreateObject <SystemSetting>();
                systemSetting.CompanyName            = "Aturable Solution";
                systemSetting.SalesNumber            = 1001;
                systemSetting.PurchaseOrderNumber    = 1001;
                systemSetting.InvoiceNumber          = 1001;
                systemSetting.InventoryReceiptNumber = 1001;
                systemSetting.Sales           = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", "4000"));
                systemSetting.CostofGoodsSold = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", "5000"));
                systemSetting.Inventory       = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", "1200"));
                systemSetting.DefaultCurrency = ObjectSpace.FindObject <Currency>(new BinaryOperator("CurrencyCode", "IDR"));

                systemSetting.Save();
                ObjectSpace.CommitChanges();
            }

            glDocument.LoadXml(GetInitialData("Vendor.xml"));
            xelRoot  = glDocument.DocumentElement;
            xnlNodes = xelRoot.SelectNodes("/data-set/record");
            foreach (XmlNode xndNode in xnlNodes)
            {
                Vendor vendor = ObjectSpace.FindObject <Vendor>(new BinaryOperator("Name", xndNode["Name"].InnerText));
                if (vendor == null)
                {
                    vendor                    = ObjectSpace.CreateObject <Vendor>();
                    vendor.Name               = xndNode["Name"].InnerText;
                    vendor.DiscountPercent    = Convert.ToDecimal(xndNode["DiscountPercent"].InnerText);
                    vendor.DiscountDays       = Convert.ToInt16(xndNode["DiscountDays"].InnerText);
                    vendor.Currency           = ObjectSpace.GetObjectByKey <Currency>(xndNode["Currency"].InnerText);
                    vendor.DefaultDueDays     = Convert.ToInt16(xndNode["DefaultDueDays"].InnerText);
                    vendor.DefaultDescription = xndNode["DefaultDescription"].InnerText;

                    vendor.Save();
                }
            }

            glDocument.LoadXml(GetInitialData("Items.xml"));
            xelRoot  = glDocument.DocumentElement;
            xnlNodes = xelRoot.SelectNodes("/data-set/record");
            foreach (XmlNode xndNode in xnlNodes)
            {
                Item item = ObjectSpace.FindObject <Item>(new BinaryOperator("ItemNumber", xndNode["ItemNumber"].InnerText));
                if (item == null)
                {
                    item                 = ObjectSpace.CreateObject <Item>();
                    item.Name            = xndNode["Name"].InnerText;
                    item.ItemNumber      = xndNode["ItemNumber"].InnerText;
                    item.Sales           = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["Sales"].InnerText));
                    item.CostofGoodsSold = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["CostofGoodsSold"].InnerText));
                    item.Inventory       = ObjectSpace.FindObject <GLAccount>(new BinaryOperator("AccountNumber", xndNode["Inventory"].InnerText));
                    item.Sold            = Convert.ToBoolean(xndNode["Sold"].InnerText);
                    item.Purchased       = Convert.ToBoolean(xndNode["Purchased"].InnerText);
                    item.Type            = ObjectSpace.FindObject <ItemType>(new BinaryOperator("Name", xndNode["Type"].InnerText));
                    item.Save();
                }
            }
            ObjectSpace.CommitChanges();
            glDocument.LoadXml(GetInitialData("VendorItem.xml"));
            xelRoot  = glDocument.DocumentElement;
            xnlNodes = xelRoot.SelectNodes("/data-set/record");
            foreach (XmlNode xndNode in xnlNodes)
            {
                VendorItem item = ObjectSpace.FindObject <VendorItem>(new BinaryOperator("Description", xndNode["Description"].InnerText));
                if (item == null)
                {
                    item                    = ObjectSpace.CreateObject <VendorItem>();
                    item.Item               = ObjectSpace.GetObjectByKey <Item>(xndNode["ItemNumber"].InnerText);
                    item.Vendor             = ObjectSpace.FindObject <Vendor>(CriteriaOperator.Parse("Name=?", xndNode["Vendor"].InnerText));
                    item.VendorItemNumber   = xndNode["VendorItemNumber"].InnerText;
                    item.VendorItemQuantity = Convert.ToInt16(xndNode["VendorItemQuantity"].InnerText);
                    item.Description        = xndNode["Description"].InnerText;
                    item.Cost               = Convert.ToDecimal(xndNode["Cost"].InnerText);

                    item.Save();
                }
            }

            ObjectSpace.CommitChanges();
        }
Example #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["user"] == null)
            {
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                if (!new UserSecurity().CheckFormPermission((int)Global.formSecurity.CreateNewGLAccount, Request.Cookies["user"]["Permission"].ToString()))
                {
                    Response.Redirect("~/Finance_Module/UnAuthorized.aspx");
                }
            }
            if (!IsPostBack)
            {
                if (Request.QueryString["alert"] == "notpass")
                {
                    Response.Write("<script>alert('لم يتم الحفظ');</script>");
                }
                if (Request.QueryString["alert"] == "AccountCodeExist")
                {
                    Response.Write("<script>alert('لم يتم الحفظ كود الحساب موجود سابقاً لا يمكن تكراره من فضلك اعد المحاولة');</script>");
                }

                if (Request.QueryString.AllKeys.Contains("id"))
                {
                    if (Request.QueryString["id"].ToString() != null)
                    {
                        if (Convert.ToInt32(Request.QueryString["id"].ToString()) > 0)
                        {
                            GLAccount glaccount = new GLAccount();
                            glaccount.get(Convert.ToInt32(Request.QueryString["id"].ToString()));

                            if (Convert.ToInt32(glaccount.ParentAcctID.ToString()) != 0)
                            {
                                GLAccount glaccount2 = new GLAccount();
                                glaccount2.get(Convert.ToInt32(glaccount.ParentAcctID.ToString()));
                                ddlParentGL.SelectedValue = glaccount2.ID.ToString();
                            }
                            else
                            {
                                ddlParentGL.SelectedValue = "0";
                            }
                            txtAcctName.Text            = glaccount.Name.ToString();
                            lstAcctStatus.SelectedValue = glaccount.Status.ToString();
                            txtBalance.Text             = glaccount.Balance.ToString();
                            txtDesc.Text              = glaccount.Description.ToString();
                            txtacctcode.Text          = glaccount.AcctCode.ToString();
                            ddlAcctType.SelectedValue = glaccount.AcctType.ToString();
                            btnEdit.Visible           = true;
                            btnSave.Visible           = false;
                            lstAcctStatus.Enabled     = false;
                        }
                        else
                        {
                            if (Request.QueryString.AllKeys.Contains("parent") && Request.QueryString.AllKeys.Contains("acctType"))
                            {
                                ddlParentGL.SelectedValue = Request.QueryString["parent"].ToString();
                                ddlAcctType.SelectedValue = Request.QueryString["acctType"].ToString();
                            }
                            lstAcctStatus.Enabled = true;
                            btnEdit.Visible       = false;
                            btnSave.Visible       = true;
                        }
                    }
                }
            }
        }
Example #21
0
 public GLAccount AddGLAccount(GLAccount pGLAccount) =>
 SyncHelper.RunAsyncAsSync(() =>
                           AddItem(pGLAccount, GLACCOUNTS));
Example #22
0
 public Task <GLAccount> AddGLAccountAsync(GLAccount pGLAccount) =>
 AddItem(pGLAccount, GLACCOUNTS);
 public AccountStatementList2(GLAccount Acc)
 {
     this.Acc = Acc ?? new GLAccount();
 }
Example #24
0
 public Task <GLAccount> EditGLAccountAsync(GLAccount pGLAccount) =>
 EditAndReturnItem(pGLAccount, $"{GLACCOUNTS}/{pGLAccount.Id}");
Example #25
0
        public static string PostTeller(CustomerAccount account, GLAccount till, Double amt, PostingType pType, Configuration config)
        {
            string output = "";

            switch (pType)
            {
            case PostingType.Deposit:
                CreditCustomerAccount(account, amt);
                GLPostingLogic.DebitGL(till, amt);
                output = "success";
                break;

            case PostingType.Withdrawal:

                if (account.AccountType == AccountType.Savings)
                {
                    if (account.Balance >= config.SavingsMinimumBalance + amt)
                    {
                        if (till.Balance >= amt)
                        {
                            GLPostingLogic.CreditGL(till, amt);
                            DebitCustomerAccount(account, amt);
                            output = "success";
                            account.SavingsWithdrawalCount++;
                        }
                        else
                        {
                            output = "Insufficient fund in the Till account";
                        }
                    }
                    else
                    {
                        output = "insufficient Balance in Customer's account, cannot withdraw!";
                    }
                }
                else if (account.AccountType == AccountType.Current)
                {
                    if (account.Balance >= config.CurrentMinimumBalance + amt)
                    {
                        if (till.Balance >= amt)
                        {
                            GLPostingLogic.CreditGL(till, amt);
                            DebitCustomerAccount(account, amt);
                            output = "success";

                            Double x      = (amt) / 1000;
                            Double charge = (int)x * config.CurrentCOT;
                            account.DailyCOTAccrued += charge;
                        }
                        else
                        {
                            output = "Insufficient fund in the Till account";
                        }
                    }
                    else
                    {
                        output = "insufficient Balance in Customer's account, cannot withdraw!";
                    }
                }
                else     //for loan
                {
                    output = "Please select a valid account";
                }
                break;

            //break;
            default:
                break;
            } //end switch
            return(output);
        }     //
Example #26
0
 public GLAccount EditGLAccount(GLAccount pGLAccount) =>
 SyncHelper.RunAsyncAsSync(() =>
                           EditAndReturnItem(pGLAccount, $"{GLACCOUNTS}/{pGLAccount.Id}"));
Example #27
0
        private bool IsCashAsset(GLAccount glAccount)
        {
            var a = glAccount.GLCategory.Id;

            return(a == 1);
        }
Example #28
0
 public async Task <bool> DeleteGLAccount(GLAccount pGLAccount)
 {
     return(await mAsyncCLient.DeleteGLAccountAsync(pGLAccount));
 }
        public bool SaveAccountDetails([FromBody] List <GLAccountDTO> data)
        {
            if (data != null && data.Count > 0)
            {
                GLEntity gLEntity = GLEntity.GetByGLEntityID(data[0].GLEntityID);

                DateTime CurrentTime = DateTime.Now;

                foreach (var account in data)
                {
                    GLAccount existingGLAccount = null;

                    if (gLEntity.GLAccounts != null && gLEntity.GLAccounts.Count > 0)
                    {
                        existingGLAccount =
                            gLEntity.GLAccounts.FirstOrDefault(x => x.GLAccountID == account.GLAccountID);
                    }

                    if (existingGLAccount == null)
                    {
                        if (account.GLAccountID > 0)
                        {
                            existingGLAccount            = GLAccount.GetByGLAccountID(account.GLAccountID);
                            existingGLAccount.GLEntityID = gLEntity.GLEntityID;
                        }
                        else
                        {
                            existingGLAccount           = GLAccount.NewGLAccount();
                            existingGLAccount.IsActive  = true;
                            existingGLAccount.CreatedBy = CurrentUserID;
                            existingGLAccount.CreatedOn = CurrentTime;
                        }

                        gLEntity.GLAccounts.Add(existingGLAccount);
                    }

                    int?        existingBankAccountID = existingGLAccount.BankAccountID;
                    BankAccount ba = null;
                    if (existingBankAccountID.HasValue && account.BankAccount == null)
                    {
                        // need to pull this as CustomCopyDTO function below will change bank account id to null
                        ba = existingGLAccount.BankAccount;
                    }

                    account.CustomCopyDTO(existingGLAccount);

                    if (!existingGLAccount.IsNew && existingGLAccount.IsDirty)
                    {
                        existingGLAccount.UpdatedBy = CurrentUserID;
                        existingGLAccount.UpdatedOn = CurrentTime;
                    }

                    if (account.BankAccount != null)
                    {
                        if (!account.BankAccountID.HasValue || account.BankAccountID < 0)
                        {
                            var bankAccount = BankAccount.NewBankAccount();
                            bankAccount.IsActive  = true;
                            bankAccount.CreatedBy = CurrentUserID;
                            bankAccount.CreatedOn = CurrentTime;
                            existingGLAccount.SetBankAccount(bankAccount);
                        }

                        if (account.BankAccount.BankAccountCards != null &&
                            account.BankAccount.BankAccountCards.Count > 0)
                        {
                            foreach (var bankCard in account.BankAccount.BankAccountCards)
                            {
                                BankAccountCard existingBankCard = null;

                                if (existingGLAccount.BankAccount.BankAccountCards != null &&
                                    existingGLAccount.BankAccount.BankAccountCards.Count > 0)
                                {
                                    existingBankCard =
                                        existingGLAccount.BankAccount.BankAccountCards.FirstOrDefault(x =>
                                                                                                      x.BankAccountCardID == bankCard.BankAccountCardID);
                                }


                                if (existingBankCard == null)
                                {
                                    existingBankCard           = BankAccountCard.NewBankAccountCard();
                                    existingBankCard.IsActive  = true;
                                    existingBankCard.CreatedBy = CurrentUserID;
                                    existingBankCard.CreatedOn = CurrentTime;
                                    existingGLAccount.BankAccount.BankAccountCards.Add(existingBankCard);
                                }

                                bankCard.CustomCopyDTO(existingBankCard);

                                if (!existingBankCard.IsNew && existingBankCard.IsDirty)
                                {
                                    existingBankCard.UpdatedBy = CurrentUserID;
                                    existingBankCard.UpdatedOn = CurrentTime;
                                }
                            }
                        }

                        account.BankAccount.CustomCopyDTO(existingGLAccount.BankAccount);

                        if (!existingGLAccount.BankAccount.IsNew &&
                            (existingGLAccount.BankAccount.IsDirty ||
                             existingGLAccount.BankAccount.IsChildDirty()))
                        {
                            existingGLAccount.IsDirty = true;
                            existingGLAccount.BankAccount.UpdatedBy = CurrentUserID;
                            existingGLAccount.BankAccount.UpdatedOn = CurrentTime;
                        }
                    }
                    else
                    {
                        if (ba != null)
                        {
                            existingGLAccount.IsDirty = true;
                            ba.IsActive  = false;
                            ba.UpdatedBy = CurrentUserID;
                            ba.UpdatedOn = CurrentTime;
                            existingGLAccount.SetBankAccount(ba, true);
                        }
                    }
                }

                if (gLEntity.IsDirty)
                {
                    gLEntity.UpdatedBy = CurrentUserID;
                    gLEntity.UpdatedOn = CurrentTime;
                }

                gLEntity.Save();

                return(true);
            }

            return(false);
        }
 private void BtLast_Click(object sender, RoutedEventArgs e)
 {
     index       = count;
     gl          = GLAccounts[index];
     DataContext = gl;
 }