Beispiel #1
0
        public static Boolean AccountingTxnSync(AccountingTxnSyncVM txnSyncVM, AccountingDbContext accountingDb)
        {
            using (var dbContextTransaction = accountingDb.Database.BeginTransaction())
            {
                try
                {
                    foreach (var s in txnSyncVM.billingSyncs)
                    {
                        UpdateBillingSync(s, accountingDb);
                    }

                    foreach (var txn in txnSyncVM.txnModels)
                    {
                        AddTransaction(txn, accountingDb);
                    }

                    dbContextTransaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                    throw ex;
                }
            }
        }
Beispiel #2
0
        public static Boolean VoucherLedgerGroupMap(AccountingDbContext accountingdbcontext, List <VoucherLedgerGroupMapModel> voucherLedgerMapData, RbacUser currentUser)
        {
            try
            {
                if (voucherLedgerMapData != null)
                {
                    ///  VoucherLedgerGroupMapModel vouchMap = new VoucherLedgerGroupMapModel();

                    for (int i = 0; i < voucherLedgerMapData.Count; i++)
                    {
                        voucherLedgerMapData[i].CreatedOn = DateTime.Now;
                        accountingdbcontext.VoucherLedgerGroupMaps.Add(voucherLedgerMapData[i]);
                    }

                    int j = accountingdbcontext.SaveChanges();
                    return((j > 0) ? true : false);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public AccountingDbContext GetContext()
 {
     if (Context == null)
     {
         Context = new AccountingDbContext(effortFactory.CreateConnection("name=AccountingDbContext"));
     }
     return(Context);
 }
        public string Get(string reqType)
        {
            DanpheHTTPResponse <object> responseData        = new DanpheHTTPResponse <object>();
            AccountingDbContext         accountingDBContext = new AccountingDbContext(connString);
            InventoryDbContext          invDbContext        = new InventoryDbContext(connString);

            try
            {
                if (reqType == "inventory")
                {
                    var invItems = (from goodsReceipt in invDbContext.GoodsReceipts

                                    join vendor in invDbContext.Vendors on goodsReceipt.VendorId equals vendor.VendorId

                                    select new
                    {
                        goodsReceipt.GoodsReceiptID,
                        goodsReceipt.GoodsReceiptDate,
                        goodsReceipt.TotalAmount,
                        vendor.VendorName,
                        goodsReceipt.Remarks,
                        IsSelected = true,
                        GoodsReceiptItems = (from goodsReceiptItem in invDbContext.GoodsReceiptItems
                                             join invItem in invDbContext.Items on goodsReceiptItem.ItemId equals invItem.ItemId
                                             where goodsReceiptItem.GoodsReceiptId == goodsReceipt.GoodsReceiptID
                                             select new
                        {
                            goodsReceiptItem.GoodsReceiptItemId,
                            goodsReceiptItem.BatchNO,
                            goodsReceiptItem.ExpiryDate,
                            goodsReceiptItem.ReceivedQuantity,
                            goodsReceiptItem.FreeQuantity,
                            goodsReceiptItem.RejectedQuantity,
                            goodsReceiptItem.ItemRate,
                            goodsReceiptItem.VATAmount,
                            goodsReceiptItem.TotalAmount,
                            goodsReceiptItem.ItemId,
                            invItem.ItemName
                        }).ToList()
                    }).ToList();
                    responseData.Status  = "OK";
                    responseData.Results = invItems;
                }
            }


            catch (Exception ex)
            {
                string str = ex.InnerException.Message.ToString();
                responseData.Status       = "Failed";
                responseData.ErrorMessage = ex.Message;
            }
            return(DanpheJSONConvert.SerializeObject(responseData));
        }
Beispiel #5
0
 public static void AddFiscalYear(FiscalYearModel fiscal, AccountingDbContext accDbContext)
 {
     try
     {
         fiscal.CreatedOn = System.DateTime.Now;
         accDbContext.FiscalYears.Add(fiscal);
         accDbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #6
0
 //update fiscal year will update only isActive
 public static void UpdateFiscalYear(FiscalYearModel fiscal, AccountingDbContext accDbContext)
 {
     try
     {
         accDbContext.FiscalYears.Attach(fiscal);
         accDbContext.Entry(fiscal).Property(x => x.IsActive).IsModified = true;
         accDbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #7
0
 //here we are updating only IsTransferedToAcc
 public static void UpdateBillingSync(SyncBillingAccountingModel sync, AccountingDbContext accDbContext)
 {
     try
     {
         sync.IsTransferedToAcc = true;
         accDbContext.SyncBillingAccounting.Attach(sync);
         accDbContext.Entry(sync).Property(a => a.IsTransferedToAcc).IsModified = true;
         accDbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #8
0
        private static void SeedCompanies(
            AccountingDbContext accountingDb,
            out IEnumerable <Company> companies)
        {
            var address        = Address.Create("Bulgaria", "1000", "Sofia", "Alexander I", "22A");
            var customerAddres = Address.Create("Bulgaria", "1000", "Sofia", "Ivan Rilski", "15");

            var company  = Company.Create("Test Company Ltd", "160084783", "*****@*****.**", "0236659995", address, "BG160084783");
            var customer = Company.Create("Test Customer Ltd", "200325569", "*****@*****.**", "0236659995", customerAddres, "BG200325569");

            companies = new List <Company>()
            {
                company, customer
            };

            accountingDb.Set <Company>().AddRange(companies);
        }
Beispiel #9
0
        public static void AddTransaction(TransactionModel txn, AccountingDbContext accDbContext)
        {
            try
            {
                txn.CreatedOn = System.DateTime.Now;
                txn.TransactionItems.ForEach(txnItem =>
                {
                    txnItem.CreatedOn = System.DateTime.Now;
                });

                accDbContext.Transactions.Add(txn);
                accDbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string Update(/*string reqType*/)
        {
            DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>();

            AccountingDbContext accountingDBContext = new AccountingDbContext(connString);


            try
            {
                //string str = Request.Form.Keys.First<string>();
                string   str         = this.ReadPostData();
                string   reqType     = this.ReadQueryStringData("reqType");
                RbacUser currentUser = HttpContext.Session.Get <RbacUser>("currentuser");
            }
            catch (Exception ex)
            {
                responseData.Status       = "Failed";
                responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString();
            }
            return(DanpheJSONConvert.SerializeObject(responseData, true));
        }
Beispiel #11
0
 public static Boolean AddLedgerGroup(AccountingDbContext accountingdbcontext, LedgerGroupModel ledgerGroupData, RbacUser currentUser)
 {
     try
     {
         if (ledgerGroupData != null)
         {
             ledgerGroupData.CreatedOn = System.DateTime.Now;
             ledgerGroupData.CreatedBy = currentUser.UserId;
             accountingdbcontext.LedgerGroups.Add(ledgerGroupData);
             int i = accountingdbcontext.SaveChanges();
             return((i > 0) ? true : false);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public string RunScript(string script, Ledger ledger, AccountingDbContext context)
        {
            script = script + "\n\n__result = __main()\n__result";
            var en    = Python.CreateEngine();
            var scope = en.CreateScope();

            // add variable _ledger...
            var lProxy = new LedgerProxy(ledger, context);
            var mProxy = new MacroProxy(this, ledger, context);

            scope.SetVariable("_ledger", lProxy);
            scope.SetVariable("_macro", mProxy);

            var result = "";

            try
            {
                var source = en.CreateScriptSourceFromString(script, SourceCodeKind.Statements);
                source.Execute(scope);
                var resultPy = scope.GetVariable("__result");
                if (resultPy is int)
                {
                    result = ((int)resultPy).ToString();
                }
                else if (resultPy is double)
                {
                    result = ((double)resultPy).ToString("F2");
                }
                else
                {
                    result = (string)resultPy;
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }
        public string Post()
        {
            //if reqtype=employee, then use masterdbcontext.employee.add  and so on for others.

            DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>(); //type 'object' since we have variable return types

            responseData.Status = "OK";                                                   //by default status would be OK, hence assigning at the top
            AccountingDbContext accountingDBContext = new AccountingDbContext(connString);
            RbacUser            currentUser         = HttpContext.Session.Get <RbacUser>("currentuser");

            try
            {
                string str         = this.ReadPostData();
                string reqType     = this.ReadQueryStringData("reqType");
                string companyName = this.ReadQueryStringData("companyName");
            }
            catch (Exception ex)
            {
                responseData.Status       = "Failed";
                responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString();
            }

            return(DanpheJSONConvert.SerializeObject(responseData, true));
        }
Beispiel #14
0
 public DataAdapter(AccountingDbContext wasteManagementDbContext)
 {
     this.wasteManagementDbContext = wasteManagementDbContext;
 }
Beispiel #15
0
        //public static Boolean AccountClosureTransaction(AccountClosureVM closureVM, AccountingDbContext accountingDb)
        //{
        //    using (var dbContextTransaction = accountingDb.Database.BeginTransaction())
        //    {
        //        try
        //        {
        //            FiscalYearModel fy = accountingDb.FiscalYears.Where(a => a.IsActive == true).FirstOrDefault();

        //            if (fy != null)
        //            {
        //                fy.IsActive = false;
        //                UpdateFiscalYear(fy, accountingDb);
        //            }

        //            AddFiscalYear(closureVM.nextFiscalYear, accountingDb);

        //            closureVM.TnxModel.FiscalyearId = closureVM.nextFiscalYear.FiscalYearId;
        //            closureVM.TnxModel.VoucherId = 1;
        //            AddTransaction(closureVM.TnxModel, accountingDb);
        //            dbContextTransaction.Commit();
        //            return true;
        //        }
        //        catch (Exception ex)
        //        {
        //            dbContextTransaction.Rollback();
        //            throw ex;
        //        }
        //    }
        //}

        #region account closure
        //Ajay 24-10-2018
        public static bool AccountClosure(FiscalYearModel fiscalYear, AccountingDbContext accountingDBContext)
        {
            using (var dbContextTransaction = accountingDBContext.Database.BeginTransaction())
            {
                try
                {
                    //get active fiscal year and deactive it
                    FiscalYearModel fy = accountingDBContext.FiscalYears.Where(a => a.IsActive == true).FirstOrDefault();
                    if (fy != null)
                    {
                        fy.IsActive = false;
                        UpdateFiscalYear(fy, accountingDBContext);
                    }
                    //add new fiscal year
                    AddFiscalYear(fiscalYear, accountingDBContext);
                    //get active ledgers with primary group Assets or Liabialities
                    var ledgers = (from led in accountingDBContext.Ledgers
                                   join ledGrp in accountingDBContext.LedgerGroups on led.LedgerGroupId equals ledGrp.LedgerGroupId
                                   where led.IsActive == true   // && (ledGrp.PrimaryGroup == "Assets" || ledGrp.PrimaryGroup == "Liabilities")
                                   select new
                    {
                        led.LedgerId,
                        led.OpeningBalance,
                        led.DrCr,
                        ledGrp.PrimaryGroup
                    }).ToList();

                    ledgers.ForEach(ledger =>
                    {
                        LedgerBalanceHistoryModel ledgerBalanceHistory = new LedgerBalanceHistoryModel();
                        LedgerModel led = accountingDBContext.Ledgers.Where(x => x.LedgerId == ledger.LedgerId).FirstOrDefault();
                        //calculate closing balance
                        if (ledger.PrimaryGroup == "Assets" || ledger.PrimaryGroup == "Liabilities")
                        {
                            double drAmount = accountingDBContext.TransactionItems
                                              .Where(x => x.LedgerId == ledger.LedgerId && x.DrCr == true)
                                              .Select(x => x.Amount).Sum().GetValueOrDefault();
                            double crAmount = accountingDBContext.TransactionItems
                                              .Where(x => x.LedgerId == ledger.LedgerId && x.DrCr == false)
                                              .Select(x => x.Amount).Sum().GetValueOrDefault();

                            if (led.DrCr == true)
                            {
                                drAmount = drAmount + led.OpeningBalance.Value;
                            }
                            if (led.DrCr == false)
                            {
                                crAmount = crAmount + led.OpeningBalance.Value;
                            }
                            if (drAmount > crAmount)
                            {
                                ledgerBalanceHistory.ClosingDrCr    = true;
                                ledgerBalanceHistory.ClosingBalance = drAmount - crAmount;

                                led.OpeningBalance = drAmount - crAmount;
                                led.DrCr           = true;
                            }
                            if (drAmount < crAmount)
                            {
                                ledgerBalanceHistory.ClosingDrCr    = false;
                                ledgerBalanceHistory.ClosingBalance = crAmount - drAmount;

                                led.OpeningBalance = crAmount - drAmount;
                                led.DrCr           = false;
                            }
                        }


                        //adding ledgerBalanceHistory
                        ledgerBalanceHistory.FiscalYearId   = accountingDBContext.FiscalYears.Where(a => a.IsActive == true).FirstOrDefault().FiscalYearId;
                        ledgerBalanceHistory.LedgerId       = ledger.LedgerId;
                        ledgerBalanceHistory.OpeningBalance = ledger.OpeningBalance;
                        ledgerBalanceHistory.OpeningDrCr    = led.DrCr;
                        ledgerBalanceHistory.CreatedOn      = DateTime.Now;
                        ledgerBalanceHistory.CreatedBy      = fiscalYear.CreatedBy;
                        accountingDBContext.LedgerBalanceHistory.Add(ledgerBalanceHistory);
                        accountingDBContext.SaveChanges();


                        //updating ledger opening balance
                        accountingDBContext.Ledgers.Attach(led);
                        accountingDBContext.Entry(led).Property(x => x.OpeningBalance).IsModified = true;
                        accountingDBContext.Entry(led).Property(x => x.DrCr).IsModified           = true;
                        accountingDBContext.SaveChanges();
                    });



                    dbContextTransaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                    throw ex;
                }
            }
        }
 public DalUser(AccountingDbContext dbEntity) : base(dbEntity)
 {
 }
Beispiel #17
0
 public CurrenciesController(AccountingDbContext context)
 {
     _context = context;
 }
Beispiel #18
0
 public APIController(AccountingDbContext db)
 {
     _db = db;
 }
 public DalBill(AccountingDbContext dbEntity) : base(dbEntity)
 {
 }
 public BillsController(AccountingDbContext context, ILogger <BillsController> logger) : base(context, logger)
 {
 }
Beispiel #21
0
 public MacroService(AccountingDbContext context)
 {
     Context = context;
 }
 public CategoryRepository(AccountingDbContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
 public AccountCategoriesController(AccountingDbContext context)
 {
     _context = context;
 }
 public BusinessHelper(AccountingDbContext dbEntity)
 {
     _dbContext = dbEntity;
 }
Beispiel #25
0
 public BulkPaymentAppService(
     IRepository <LK_Alloc> lkAllocRepo,
     IRepository <LK_PayFor> lkPayForRepo,
     IRepository <LK_PayType> lkPayTypeRepo,
     IRepository <LK_OthersType> lkOthersTypeRepo,
     IRepository <SYS_RolesPayFor> sysRolesPayForRepo,
     IRepository <SYS_RolesPayType> sysRolesPayTypeRepo,
     IRepository <SYS_RolesOthersType> sysRolesOthersTypeRepo,
     PropertySystemDbContext contextPropertySystem,
     AccountingDbContext contextAccounting,
     TAXDbContext contextTAX,
     PersonalsNewDbContext contextPersonals,
     DemoDbContext contextEngine3,
     IRepository <TR_PaymentHeader> trPaymentHeaderRepo,
     IRepository <TR_BookingHeader> trBookingHeaderRepo,
     IRepository <TR_PaymentDetail> trPaymentDetailRepo,
     IRepository <TR_PaymentDetailAlloc> trPaymentDetailAllocRepo,
     IRepository <TR_PaymentBulk> trPaymentBulkRepo,
     IRepository <MS_Unit> msUnitRepo,
     IRepository <MS_UnitCode> msUnitCodeRepo,
     IRepository <MS_Project> msProjectRepo,
     IRepository <MS_Area> msAreaRepo,
     IRepository <MS_Category> msCategoryRepo,
     IRepository <MS_Cluster> msClusterRepo,
     IRepository <TR_BookingDetail> trBookingDetailRepo,
     IRepository <TR_BookingDetailSchedule> trBookingDetailScheduleRepo,
     IRepository <MS_Company> msCompanyRepo,
     IRepository <MS_Account> msAccountRepo,
     IInputPaymentAppService iInputPaymentAppService,
     IPSASScheduleAppService iPSASScheduleAppService
     )
 {
     _lkAllocRepo                 = lkAllocRepo;
     _lkPayForRepo                = lkPayForRepo;
     _lkPayTypeRepo               = lkPayTypeRepo;
     _lkOthersTypeRepo            = lkOthersTypeRepo;
     _sysRolesPayForRepo          = sysRolesPayForRepo;
     _sysRolesPayTypeRepo         = sysRolesPayTypeRepo;
     _sysRolesOthersTypeRepo      = sysRolesOthersTypeRepo;
     _contextPropertySystem       = contextPropertySystem;
     _contextAccounting           = contextAccounting;
     _contextTAX                  = contextTAX;
     _contextPersonals            = contextPersonals;
     _contextEngine3              = contextEngine3;
     _trPaymentHeaderRepo         = trPaymentHeaderRepo;
     _trBookingHeaderRepo         = trBookingHeaderRepo;
     _trPaymentDetailRepo         = trPaymentDetailRepo;
     _trPaymentDetailAllocRepo    = trPaymentDetailAllocRepo;
     _trPaymentBulkRepo           = trPaymentBulkRepo;
     _msUnitRepo                  = msUnitRepo;
     _msUnitCodeRepo              = msUnitCodeRepo;
     _msProjectRepo               = msProjectRepo;
     _msAreaRepo                  = msAreaRepo;
     _msCategoryRepo              = msCategoryRepo;
     _msClusterRepo               = msClusterRepo;
     _trBookingDetailRepo         = trBookingDetailRepo;
     _trBookingDetailScheduleRepo = trBookingDetailScheduleRepo;
     _msCompanyRepo               = msCompanyRepo;
     _msAccountRepo               = msAccountRepo;
     _iInputPaymentAppService     = iInputPaymentAppService;
     _iPSASScheduleAppService     = iPSASScheduleAppService;
 }
 public AccountRepository(AccountingDbContext dbContext)
     : base(dbContext)
 {
 }
 public LedgerService(AccountingDbContext context)
 {
     Context = context;
 }
 public AccountController(AccountingDbContext context, ILogger <AccountController> logger) : base(context, logger)
 {
 }
Beispiel #29
0
 public TransactionService(AccountingDbContext context)
 {
     Context = context;
 }
 public void ResetContext()
 {
     Context = null;
 }