private IEnumerable <JournalVoucher> GetJournalPurposesFromXmlFile()
        {
            var filePath = GetTempJournalVoucherXmlFilePath();
            List <JournalVoucher> purposes = new List <JournalVoucher>();
            var xmlData = XDocument.Load(filePath).Element("PurposeList")?.Elements();

            if (xmlData != null)
            {
                foreach (XElement element in xmlData)
                {
                    JournalVoucher aPurpose = new JournalVoucher();
                    var            elementFirstAttribute = element.FirstAttribute.Value;
                    aPurpose.Serial = elementFirstAttribute;
                    var elementValue = element.Elements();
                    var xElements    = elementValue as XElement[] ?? elementValue.ToArray();
                    aPurpose.PurposeCode   = xElements[0].Value;
                    aPurpose.Amounts       = Convert.ToDecimal(xElements[1].Value);
                    aPurpose.PurposeName   = xElements[2].Value;
                    aPurpose.Remarks       = xElements[3].Value;
                    aPurpose.DebitOrCredit = xElements[4].Value;
                    aPurpose.VoucherDate   = Convert.ToDateTime(xElements[5].Value);
                    purposes.Add(aPurpose);
                }
            }
            return(purposes);
        }
Пример #2
0
        public ActionResult Create()
        {
            JournalVoucher journalvoucher = new JournalVoucher();

            journalvoucher.VoucherNo         = "JV-";
            journalvoucher.VoucherDate       = DateTime.Now;
            journalvoucher.Narration         = "";
            journalvoucher.DebitTotalAmount  = 0.00M;
            journalvoucher.CreditTotalAmount = 0.00M;
            journalvoucher.DiffTotalAmount   = 0.00M;
            journalvoucher.Flag = false;
            db.JournalVouchers.Add(journalvoucher);
            db.SaveChanges();
            journalvoucher.VoucherNo       = "JV-" + journalvoucher.JournalVoucherID.ToString("D" + 6);
            db.Entry(journalvoucher).State = EntityState.Modified;
            db.SaveChanges();

            JournalVoucherDetail journalvoucherdetail = new JournalVoucherDetail();

            journalvoucherdetail.JournalVoucherID = journalvoucher.JournalVoucherID;
            journalvoucherdetail.AccountHeadID    = 1;
            journalvoucherdetail.DebitCreditID    = 1;
            journalvoucherdetail.Amount           = 0.00M;
            journalvoucherdetail.Remarks          = "";
            db.JournalVoucherDetails.Add(journalvoucherdetail);
            db.SaveChanges();
            Session["Create"] = "1";
            return(RedirectToAction("Edit", new { id = journalvoucher.JournalVoucherID }));
        }
Пример #3
0
        private void Find(int docNum)
        {
            try
            {
                CancelledLabel.Visibility = Visibility.Collapsed;

                _currentItems = JournalVoucher.WhereDocumentNumberIs(docNum);
                _currentItems.CollectionChanged += CurrentItemsCollectionChanged;

                foreach (JournalVoucher currentItem in _currentItems)
                {
                    currentItem.PropertyChanged += CurrentItemOnPropertyChanged;
                }
                _voucherNumber = docNum;

                RefreshDisplay();

                DataContext  = _currentItems;
                _hasModified = false;
            }
            catch (Exception exception)
            {
                MessageWindow.ShowAlertMessage(exception.Message);
            }
        }
Пример #4
0
        private void btnCancelled_Click(object sender, RoutedEventArgs e)
        {
            if (!CanModify)
            {
                MessageWindow.AlertRecordIsLocked();
                return;
            }

            if (MessageWindow.ConfirmCancelVoucher() != MessageBoxResult.Yes)
            {
                return;
            }

            JournalVoucher.DeleteAll(_voucherNumber);

            var cancelledJournalVoucher = new JournalVoucher
            {
                MemberCode   = "CANCEL",
                MemberName   = "CANCELLED",
                AccountCode  = "CANCEL",
                AccountTitle = "CANCELLED",
                Debit        = 0m,
                Credit       = 0m,
                VoucherDate  = _voucherDate,
                VoucherNo    = _voucherNumber,
                VoucherType  = _voucherType
            };

            cancelledJournalVoucher.Create();
            Find(_voucherNumber);
        }
Пример #5
0
        private JournalVoucher GetJournalVoucher()
        {
            //double debit = _massVoucher.JVDebitOrCredit.Equals("debit", StringComparison.OrdinalIgnoreCase)
            //                   ? _massVoucher.Amount
            //                   : 0;
            //double credit = _massVoucher.JVDebitOrCredit.Equals("credit", StringComparison.OrdinalIgnoreCase)
            //                   ? _massVoucher.Amount
            //                   : 0;
            JournalVoucher journalVoucher = new JournalVoucher(_recordRepository, _fixedAssetRepository)
            {
                ProjectHead     = _projectHead,
                Date            = _massVoucher.VoucherDate,
                Narration       = _massVoucher.Narration,
                Tag             = _massVoucher.Tag,
                VoucherSerialNo = _massVoucher.VoucherSerialNo,
                Link            = _massVoucher.LinkedVoucherNo,
                VoucherType     = _massVoucher.VoucherType,
                JVDebitOrCredit = _massVoucher.JVDebitOrCredit,
                IsActive        = true
            };

            journalVoucher.SetAmount(_massVoucher.Amount);
            if (_massVoucher.IsFixedAsset)
            {
                journalVoucher.IsFixedAsset = true;
                journalVoucher.FixedAsset   = GetFixedAsset();
            }
            return(journalVoucher);
        }
Пример #6
0
        private Result PostCashOnHand()
        {
            // post cash on hand credit side
            var member      = Nfmb.FindByCode(_accountDetail.MemberCode);
            var accountCode = GlobalSettings.CodeOfCashOnHand;

            if (string.IsNullOrWhiteSpace(accountCode))
            {
                return(new Result(false, GenerateCodeOfAccountNotSetMessage("Cash on Hand")));
            }
            var account = Account.FindByCode(accountCode);
            var amount  = _accountDetail.EndingBalance +
                          _accountDetail.TimeDepositDetails.CalculateInterestEarned(_voucherDocument.VoucherDate) -
                          _accountDetail.TimeDepositDetails.CalculateServiceFee(_voucherDocument.VoucherDate);
            var cv = new JournalVoucher
            {
                MemberCode    = member.MemberCode,
                MemberName    = member.MemberName,
                AccountCode   = account.AccountCode,
                AccountTitle  = account.AccountTitle,
                Credit        = amount,
                VoucherDate   = _voucherDocument.VoucherDate,
                VoucherNo     = _voucherDocument.VoucherNo,
                Explanation   = "Withdrawal of Time Deposit",
                AmountInWords = Converter.AmountToWords(amount),
            };

            var postResult = cv.Create();

            if (!postResult.Success)
            {
                Rollback();
            }
            return(postResult);
        }
Пример #7
0
        private Result PostServiceFee()
        {
            // post service fee credit side
            var member      = Nfmb.FindByCode(_accountDetail.MemberCode);
            var accountCode = GlobalSettings.CodeOfServiceFee;

            if (string.IsNullOrWhiteSpace(accountCode))
            {
                return(new Result(false, GenerateCodeOfAccountNotSetMessage("Service Fee")));
            }
            var account = Account.FindByCode(accountCode);
            var jv      = new JournalVoucher
            {
                MemberCode   = member.MemberCode,
                MemberName   = member.MemberName,
                AccountCode  = account.AccountCode,
                AccountTitle = account.AccountTitle,
                Credit       = _accountDetail.TimeDepositDetails.CalculateServiceFee(_voucherDocument.VoucherDate),
                VoucherDate  = _voucherDocument.VoucherDate,
                VoucherNo    = _voucherDocument.VoucherNo,
            };

            var postResult = jv.Create();

            if (!postResult.Success)
            {
                Rollback();
            }
            return(postResult);
        }
Пример #8
0
        private void metroTile3_Click_1(object sender, EventArgs e)
        {
            this.Hide();
            JournalVoucher JvObj = new JournalVoucher();

            JvObj.Show();
        }
Пример #9
0
        public void Process()
        {
            var transactionDate = MainController.LoggedUser.TransactionDate;
            var previousYear    = transactionDate.Year - 1;

            var montlyEndBalances = GetMontlyEndBalance(previousYear, ShareCapitalCode);

            if (!montlyEndBalances.Any())
            {
                MessageWindow.ShowAlertMessage(string.Format("No transactions were found having account {0}.",
                                                             _shareCapitalAccount.AccountTitle));
                return;
            }

            // total monthly average
            var filteredMonthlyEndBalances = (from meb in montlyEndBalances
                                              where meb.Average >= _maintainingBalance
                                              select meb).ToList();

            var totalMonthlyAverage = filteredMonthlyEndBalances.Sum(item => item.Average);

            // rate
            var rate = AmountAllocated / totalMonthlyAverage;

            foreach (var item in filteredMonthlyEndBalances)
            {
                if (item.Average <= 0)
                {
                    continue;
                }
                var jvCredit = new JournalVoucher
                {
                    MemberCode   = item.MemberCode,
                    MemberName   = item.MemberName,
                    AccountCode  = _shareCapitalAccount.AccountCode,
                    AccountTitle = _shareCapitalAccount.AccountTitle,
                    Credit       = item.Average * rate,
                    VoucherDate  = transactionDate,
                    VoucherNo    = JournalVoucherNumber,
                    IsPosted     = true
                };
                jvCredit.Create();
            }

            var jvDebit = new JournalVoucher
            {
                MemberCode   = _cooperative.MemberCode,
                MemberName   = _cooperative.MemberName,
                AccountCode  = _interestOnShareCapitalAccount.AccountCode,
                AccountTitle = _interestOnShareCapitalAccount.AccountTitle,
                Debit        = _amountAllocated,
                VoucherDate  = transactionDate,
                VoucherNo    = JournalVoucherNumber,
                IsPosted     = true,
                Explanation  = "Posting Dividend Distribution"
            };

            jvDebit.Create();
        }
Пример #10
0
        public ActionResult JournalDetails(int id)
        {
            JournalVoucher        journal  = _iAccountsManager.GetJournalVoucherById(id);
            List <JournalDetails> vouchers = _iAccountsManager.GetJournalVoucherDetailsById(id);

            ViewBag.JournalDetails = vouchers;
            return(View(journal));
        }
Пример #11
0
        public int SaveJournalVoucher(JournalVoucher aJournal, List <JournalVoucher> journals)
        {
            int    maxSl   = GetMaxJournalVoucherNoOfCurrentYear();
            string refCode = _iCommonManager.GetAllSubReferenceAccounts().ToList()
                             .Find(n => n.Id == Convert.ToInt32(ReferenceType.JournalVoucher)).Code;

            aJournal.VoucherRef = DateTime.Now.Year.ToString().Substring(2, 2) + refCode + (maxSl + 1);
            aJournal.VoucherNo  = maxSl + 1;
            return(_iAccountGateway.SaveJournalVoucher(aJournal, journals));
        }
Пример #12
0
        public ActionResult ApproveJournalVoucher(FormCollection collection)
        {
            int            voucherId      = Convert.ToInt32(collection["JournalVoucherIdToApprove"]);
            JournalVoucher aVoucher       = _iAccountsManager.GetJournalVoucherById(voucherId);
            var            anUser         = (ViewUser)Session["user"];
            var            voucherDetails = _iAccountsManager.GetJournalVoucherDetailsById(voucherId).ToList();
            bool           result         = _iAccountsManager.ApproveJournalVoucher(aVoucher, voucherDetails, anUser.UserId);

            return(result ? RedirectToAction("ViewJournal") : RedirectToAction("JournalDetails", "Account", aVoucher));
        }
Пример #13
0
        public PostJournalVoucherView(DateTime postingDate)
        {
            InitializeComponent();

            _viewModel             = new JournalVoucher();
            _viewModel.VoucherNo   = Voucher.LastDocumentNo(VoucherTypes.JV) + 1;
            _viewModel.VoucherDate = postingDate;

            DataContext = _viewModel;

            btnPost.Click += btnPost_Click;
        }
Пример #14
0
        public ActionResult JournalVoucher(FormCollection collection)
        {
            var paymentTypes = _iCommonManager.GetAllPaymentTypes().ToList();

            try
            {
                JournalVoucher aJournal        = new JournalVoucher();
                var            purposeName     = collection["PurposeName"];
                var            purposeCode     = collection["PurposeCode"];
                var            remarks         = collection["Remarks"];
                var            amount          = Convert.ToDecimal(collection["Amount"]);
                var            transactionType = collection["TransactionType"];
                var            date            = Convert.ToDateTime(collection["Date"]);
                aJournal.DebitOrCredit = transactionType;
                if (transactionType.Equals("Cr"))
                {
                    aJournal.Amounts = amount * -1;
                }
                else
                {
                    aJournal.Amounts = amount;
                }

                aJournal.PurposeName = purposeName;
                aJournal.PurposeCode = purposeCode;
                aJournal.VoucherDate = date;
                aJournal.Remarks     = remarks;
                List <JournalVoucher> journals = (List <JournalVoucher>)Session["Journals"];
                if (journals != null)
                {
                    journals.Add(aJournal);
                }
                else
                {
                    journals = new List <JournalVoucher> {
                        aJournal
                    };
                    Session["Journals"] = journals;
                    ViewBag.Payments    = journals;
                }


                ViewBag.PaymentTypes = paymentTypes;
                return(View());
            }
            catch (Exception exception)
            {
                TempData["Error"]    = exception.Message + "<br>System Error :" + exception?.InnerException?.Message;
                ViewBag.PaymentTypes = paymentTypes;
                return(View());
            }
        }
Пример #15
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                if (LoanLookUpProcess.clsLoanLookUpMember.frmPass == "Journal")
                {
                    JournalVoucher jv = new JournalVoucher();

                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.GetType() == typeof(JournalVoucher))
                        {
                            //===============================================================================
                            //                      If form is already open
                            //===============================================================================
                            form.Activate();
                            jv = (JournalVoucher)Application.OpenForms["JournalVoucher"];

                            jv.txtLoanNumber.Text = dataGridView1.SelectedRows[0].Cells["Loan_No"].Value.ToString();
                            jv.txtLoanType.Text   = dataGridView1.SelectedRows[0].Cells["Loan_Type"].Value.ToString();
                        }
                    }

                    jv.txtLoanNumber.Text = dataGridView1.SelectedRows[0].Cells["Loan_No"].Value.ToString();
                    jv.txtLoanType.Text   = dataGridView1.SelectedRows[0].Cells["Loan_Type"].Value.ToString();
                    this.Close();
                }
                else if (LoanLookUpProcess.clsLoanLookUpMember.frmPass == "Disbursement")
                {
                    DisbursementVoucher cv = new DisbursementVoucher();

                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.GetType() == typeof(DisbursementVoucher))
                        {
                            //===============================================================================
                            //                      If form is already open
                            //===============================================================================
                            form.Activate();
                            cv = (DisbursementVoucher)Application.OpenForms["DisbursementVoucher"];

                            cv.txtLoanNo.Text   = dataGridView1.SelectedRows[0].Cells["Loan_No"].Value.ToString();
                            cv.txtLoanType.Text = dataGridView1.SelectedRows[0].Cells["Loan_Type"].Value.ToString();
                        }
                    }

                    cv.txtLoanNo.Text   = dataGridView1.SelectedRows[0].Cells["Loan_No"].Value.ToString();
                    cv.txtLoanType.Text = dataGridView1.SelectedRows[0].Cells["Loan_Type"].Value.ToString();
                    this.Close();
                }
            }
        }
 public JournalVoucherViewModel(JournalVoucher entity)
 {
     this.CompanyId      = entity.CompanyId;
     this.ConversionRate = entity.ConversionRate;
     this.CurrencyId     = entity.CurrencyId;
     this.Description    = entity.Description;
     this.DocumentNo     = entity.DocumentNo;
     this.GLDate         = entity.GLDate;
     this.Id             = entity.Id;
     this.JournalName    = entity.JournalName;
     //this.JournalVoucherDetail = entity.JournalVoucherDetail.Select(x => new JournalVoucherDetailModel(x)).ToList();
     this.PeriodId = entity.PeriodId;
     this.SOBId    = entity.SOBId;
 }
 public JournalVoucherViewModel(JournalVoucher entity)
 {
     this.CompanyId = entity.CompanyId;
     this.ConversionRate = entity.ConversionRate;
     this.CurrencyId = entity.CurrencyId;
     this.Description = entity.Description;
     this.DocumentNo = entity.DocumentNo;
     this.GLDate = entity.GLDate;
     this.Id = entity.Id;
     this.JournalName = entity.JournalName;
     //this.JournalVoucherDetail = entity.JournalVoucherDetail.Select(x => new JournalVoucherDetailModel(x)).ToList();
     this.PeriodId = entity.PeriodId;
     this.SOBId = entity.SOBId;
 }
        public ActionResult insertJournalVoucher([FromBody] JournalVoucher voucher)
        {
            JObject RequestBody = JObject.FromObject(voucher);
            string  json        = RequestBody.ToString();

            //JArray a = JArray.Parse(json);

            XmlDocument doc1 = JsonConvert.DeserializeXmlNode(json, "root");
            string      xml  = doc1.InnerXml;

            var result = journal.insertJorunalVoucher(xml);

            return(Ok(result));
        }
Пример #19
0
        private void PostAPInvoiceAcction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            int invCount = 0;

            foreach (APInvoice invoice in View.SelectedObjects)
            {
                invCount += 1;
                SystemSetting setting = ObjectSpace.FindObject <SystemSetting>(null);

                JournalVoucher journalVoucher = ObjectSpace.CreateObject <JournalVoucher>();
                journalVoucher.VoucherDate = DateTime.Now;
                journalVoucher.PeriodMonth = invoice.PeriodMonth;
                journalVoucher.PeriodYear  = invoice.PeriodYear;
                journalVoucher.Source      = BusinessObjects.ETC.Enums.JournalVoucherSource.APInvoice;
                journalVoucher.Description = string.Format("AP Invoice {0} - {1}", invoice.InvoiceNumber, invoice.Vendor.Name);

                JournalEntry entryAP = ObjectSpace.CreateObject <JournalEntry>();
                entryAP.Account = ObjectSpace.GetObjectByKey <GLAccount>(invoice.Vendor.Currency.AccountsPayable.AccountNumber);
                entryAP.Amount  = invoice.Amount * -1;
                journalVoucher.Entries.Add(entryAP);
                decimal TotalAmount = 0;
                foreach (APInvoiceItem item in invoice.Items)
                {
                    JournalEntry entry = ObjectSpace.CreateObject <JournalEntry>();
                    entry.Account = ObjectSpace.GetObjectByKey <GLAccount>(item.GLAccount.AccountNumber);
                    if (invoice.Vendor.Currency.ExchangeRate > 0)
                    {
                        entry.Amount = item.Amount * invoice.Vendor.Currency.ExchangeRate;
                    }
                    else
                    {
                        entry.Amount = item.Amount;
                    }
                    TotalAmount += entry.Amount;

                    journalVoucher.Entries.Add(entry);
                }
                if (setting.DefaultCurrency != invoice.Vendor.Currency)
                {
                    JournalEntry entry = ObjectSpace.CreateObject <JournalEntry>();
                    entry.Account = ObjectSpace.GetObjectByKey <GLAccount>(invoice.Vendor.Currency.GainLossOnExchange.AccountNumber);
                    entry.Amount  = ((invoice.Amount * invoice.Vendor.Currency.ExchangeRate) - invoice.Amount) * -1;

                    journalVoucher.Entries.Add(entry);
                }
                invoice.Posted = true;
            }
            ObjectSpace.CommitChanges();
            Application.ShowViewStrategy.ShowMessage(string.Format("{0} invoice was created, please check AP Invoice to adjust the invoices and post the invoices to Journal Vouchers", invCount), InformationType.Success, 5000, InformationPosition.Bottom);
        }
        public PostInterestOnSavingsDepositView(InterestOnSavingsDepositViewModel viewModel)
        {
            InitializeComponent();

            _viewModel = viewModel;

            _journalVoucher             = new JournalVoucher();
            _journalVoucher.VoucherNo   = Voucher.LastDocumentNo(VoucherTypes.JV) + 1;
            _journalVoucher.VoucherDate = GlobalSettings.DateOfOpenTransaction;

            DataContext = _journalVoucher;

            btnPost.Click += btnPost_Click;
        }
        public ActionResult JournalVoucher(FormCollection collection)
        {
            try
            {
                var aJournal        = new JournalVoucher();
                var purposeName     = collection["PurposeName"];
                var purposeCode     = collection["PurposeCode"];
                var remarks         = collection["Remarks"];
                var amount          = Convert.ToDecimal(collection["Amount"]);
                var transactionType = collection["TransactionType"];
                var date            = Convert.ToDateTime(collection["Date"]);
                aJournal.DebitOrCredit = transactionType;
                if (transactionType.Equals("Cr"))
                {
                    aJournal.Amounts = amount * -1;
                }
                else
                {
                    aJournal.Amounts = amount;
                }

                aJournal.PurposeName = purposeName;
                aJournal.PurposeCode = purposeCode;
                aJournal.VoucherDate = date;
                aJournal.Remarks     = remarks;

                var filePath    = GetTempJournalVoucherXmlFilePath();
                var id          = aJournal.PurposeCode + "_" + Guid.NewGuid();
                var xmlDocument = XDocument.Load(filePath);
                xmlDocument.Element("PurposeList")?.Add(
                    new XElement("Purpose", new XAttribute("Id", id),
                                 new XElement("PurposeCode", aJournal.PurposeCode),
                                 new XElement("Amounts", aJournal.Amounts),
                                 new XElement("PurposeName", aJournal.PurposeName),
                                 new XElement("Remarks", aJournal.Remarks),
                                 new XElement("DebitOrCredit", aJournal.DebitOrCredit),
                                 new XElement("Date", aJournal.VoucherDate)

                                 ));
                xmlDocument.Save(filePath);
                return(View());
            }
            catch (Exception exception)
            {
                TempData["Error"] = exception.Message + "<br>System Error :" + exception?.InnerException?.Message;
                Log.WriteErrorLog(exception);
                return(PartialView("_ErrorPartial", exception));
            }
        }
Пример #22
0
        private void PostAPPaymentAction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            int invCount = 0;

            foreach (APPayment payment in View.SelectedObjects)
            {
                SystemSetting setting = ObjectSpace.FindObject <SystemSetting>(null);

                JournalVoucher journalVoucher = ObjectSpace.CreateObject <JournalVoucher>();
                journalVoucher.VoucherDate = DateTime.Now;
                journalVoucher.PeriodMonth = payment.PeriodMonth;
                journalVoucher.PeriodYear  = payment.PeriodYear;
                journalVoucher.Source      = BusinessObjects.ETC.Enums.JournalVoucherSource.APPayment;
                journalVoucher.Description = string.Format("AP Paynebt Ref. {0}", payment.Reference);

                JournalEntry entryAP = ObjectSpace.CreateObject <JournalEntry>();
                entryAP.Account = ObjectSpace.GetObjectByKey <GLAccount>(payment.Bank.GLAccount.AccountNumber);
                entryAP.Amount  = payment.Amount * -1;
                journalVoucher.Entries.Add(entryAP);

                foreach (APPaymentItem item in payment.Items)
                {
                    JournalEntry entry = ObjectSpace.CreateObject <JournalEntry>();
                    entry.Account = ObjectSpace.GetObjectByKey <GLAccount>(payment.Vendor.Currency.AccountsPayable.AccountNumber);
                    if (payment.Vendor.Currency.ExchangeRate > 0)
                    {
                        entry.Amount = item.Payment * payment.Vendor.Currency.ExchangeRate;
                    }
                    else
                    {
                        entry.Amount = item.Payment;
                    }
                    journalVoucher.Entries.Add(entry);
                }
                if (setting.DefaultCurrency != payment.Vendor.Currency)
                {
                    JournalEntry entry = ObjectSpace.CreateObject <JournalEntry>();
                    entry.Account = ObjectSpace.GetObjectByKey <GLAccount>(payment.Vendor.Currency.GainLossOnExchange.AccountNumber);
                    entry.Amount  = ((payment.Amount * payment.Vendor.Currency.ExchangeRate) - payment.Amount);

                    journalVoucher.Entries.Add(entry);
                }
                invCount      += 1;
                payment.Posted = true;
            }

            ObjectSpace.CommitChanges();
            Application.ShowViewStrategy.ShowMessage(string.Format("{0} payments was posted, please check JV Voucher to adjust the JVs and post the JVs to General Ledger", invCount), InformationType.Success, 5000, InformationPosition.Bottom);
        }
 public ActionResult JournalDetails(int id)
 {
     try
     {
         JournalVoucher        journal  = _iAccountsManager.GetJournalVoucherById(id);
         List <JournalDetails> vouchers = _iAccountsManager.GetJournalVoucherDetailsById(id);
         ViewBag.JournalDetails = vouchers;
         return(View(journal));
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         return(PartialView("_ErrorPartial", exception));
     }
 }
Пример #24
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            JournalVoucher journalvoucher = db.JournalVouchers.Find(id);

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

            return(View(journalvoucher));
        }
Пример #25
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (!CanModify)
            {
                MessageWindow.AlertRecordIsLocked();
                return;
            }

            if (MessageWindow.ConfirmDeleteVoucher() != MessageBoxResult.Yes)
            {
                return;
            }
            JournalVoucher.DeleteAll(_voucherNumber);
            Find(_voucherNumber);
        }
Пример #26
0
        public ActionResult DeleteConfirm(int id)
        {
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";
            JournalVoucher journalvoucher = db.JournalVouchers.Find(id);

            try
            {
                var accountjournals = db.AccountJournals.Where(a => a.VoucherNo == journalvoucher.VoucherNo).ToList();
                foreach (AccountJournal accountjournal1 in accountjournals)
                {
                    var accountjournaldetails = db.AccountJournalDetails.Where(a => a.AccountJournalID == accountjournal1.AccountJournalID).ToList();
                    foreach (AccountJournalDetail accountjournaldetail1 in accountjournaldetails)
                    {
                        db.AccountJournalDetails.Remove(accountjournaldetail1);
                    }
                    db.SaveChanges();
                    db.AccountJournals.Remove(accountjournal1);
                }
                db.SaveChanges();
            }
            catch { }
            try
            {
                var journalVoucherdetail = db.JournalVoucherDetails.Where(b => b.JournalVoucherID == id).ToList();
                foreach (JournalVoucherDetail a in journalVoucherdetail)
                {
                    var journalVoucherdetailallocation = db.JournalVoucherDetailAllocations.Where(b => b.JournalVoucherDetailID == a.JournalVoucherDetailID).ToList();
                    foreach (JournalVoucherDetailAllocation b in journalVoucherdetailallocation)
                    {
                        db.JournalVoucherDetailAllocations.Remove(b);
                        db.SaveChanges();
                    }
                    db.JournalVoucherDetails.Remove(a);
                    db.SaveChanges();
                }

                db.JournalVouchers.Remove(journalvoucher);
                db.SaveChanges();

                Session["err"] = "";
                Session["msg"] = "Deleted Successfully";
            }
            catch { }
            return(RedirectToAction("Index"));
        }
Пример #27
0
        private void RefreshDisplay()
        {
            JournalVoucher firstItem = _currentItems.FirstOrDefault();

            if (firstItem != null)
            {
                _voucherDate = firstItem.VoucherDate;
                CancelledLabel.Visibility = firstItem.MemberCode.ToUpper().Contains("CANCEL")
                                                ? Visibility.Visible
                                                : Visibility.Collapsed;
            }
            else
            {
                _voucherDate = _transactionDateUser;
            }

            bool allowEdit = CanModify;

            dgTransactionDetails.ItemsSource    = _currentItems;
            dgTransactionDetails.CanUserAddRows = allowEdit;
            dgTransactionDetails.IsReadOnly     = !allowEdit;

            txtDocNum.Text          = Convert.ToString(_voucherNumber);
            txtTransactionDate.Text = _voucherDate.ToString("MM/dd/yyyy");

            UpdateTotalDebitAndTotalCredit();

            lblRecordCount.Content = string.Format("Record Count: {0}", _currentItems.Count);

            btnSave.IsEnabled      = allowEdit;
            btnDelete.IsEnabled    = allowEdit;
            btnCancelled.IsEnabled = allowEdit;
            btnPrint.IsEnabled     = allowEdit;

            if (allowEdit)
            {
                imgLocked.Visibility   = Visibility.Collapsed;
                imgUnlocked.Visibility = Visibility.Visible;
            }
            else
            {
                imgLocked.Visibility   = Visibility.Visible;
                imgUnlocked.Visibility = Visibility.Collapsed;
            }
        }
 public ActionResult ApproveJournalVoucher(FormCollection collection)
 {
     try
     {
         int            voucherId      = Convert.ToInt32(collection["JournalVoucherIdToApprove"]);
         JournalVoucher aVoucher       = _iAccountsManager.GetJournalVoucherById(voucherId);
         var            anUser         = (ViewUser)Session["user"];
         var            voucherDetails = _iAccountsManager.GetJournalVoucherDetailsById(voucherId).ToList();
         aVoucher.Remarks = "Journal entry";
         bool result = _iAccountsManager.ApproveJournalVoucher(aVoucher, voucherDetails, anUser.UserId);
         return(result ? RedirectToAction("ViewJournal") : RedirectToAction("JournalDetails", "AccountManager", aVoucher));
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         return(PartialView("_ErrorPartial", exception));
     }
 }
Пример #29
0
        private void VoucherFormOnKeyDown(object sender, KeyEventArgs e)
        {
            if (!CanModify)
            {
                return;
            }

            if (e.Key == Key.I && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                var newItem = new JournalVoucher();
                _currentItems.Add(newItem);
            }
            if (e.Key == Key.D && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                var currentItem = (JournalVoucher)dgTransactionDetails.SelectedItem;
                _currentItems.Remove(currentItem);
            }
        }
Пример #30
0
        private void button8_Click(object sender, EventArgs e)
        {
            //Hide sub menu filemaintenance
            panelProcessSub.Visible = false;

            //controls
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(JournalVoucher))
                {
                    form.Activate();
                    return;
                }
            }

            JournalVoucher frm = new JournalVoucher();

            frm.Show();
            frm.MdiParent = this;
        }
Пример #31
0
        public ActionResult DeleteDetailConfirm(int id)
        {
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";
            JournalVoucherDetail journalvoucherdetail = db.JournalVoucherDetails.Find(id);

            try
            {
                var journalVoucherdetailallocation = db.JournalVoucherDetailAllocations.Where(b => b.JournalVoucherDetailID == id).ToList();
                foreach (JournalVoucherDetailAllocation b in journalVoucherdetailallocation)
                {
                    db.JournalVoucherDetailAllocations.Remove(b);
                    db.SaveChanges();
                }
                db.JournalVoucherDetails.Remove(journalvoucherdetail);
                db.SaveChanges();
            }
            catch { }

            try
            {
                decimal debittotalamt  = 0;
                decimal credittotalamt = 0;
                debittotalamt  = db.JournalVoucherDetails.Where(u => u.JournalVoucherID == journalvoucherdetail.JournalVoucherID).Where(u => u.DebitCreditID == 1).Sum(u => (decimal)u.Amount);
                credittotalamt = db.JournalVoucherDetails.Where(u => u.JournalVoucherID == journalvoucherdetail.JournalVoucherID).Where(u => u.DebitCreditID == 2).Sum(u => (decimal)u.Amount);

                JournalVoucher journalvoucher = db.JournalVouchers.Find(journalvoucherdetail.JournalVoucherID);
                journalvoucher.DebitTotalAmount  = decimal.Round(Convert.ToDecimal(debittotalamt), 2, MidpointRounding.AwayFromZero);
                journalvoucher.CreditTotalAmount = decimal.Round(Convert.ToDecimal(credittotalamt), 2, MidpointRounding.AwayFromZero);
                journalvoucher.DiffTotalAmount   = decimal.Round(Convert.ToDecimal(debittotalamt - credittotalamt), 2, MidpointRounding.AwayFromZero);
                db.Entry(journalvoucher).State   = EntityState.Modified;
                db.SaveChanges();

                Session["err"] = "";
                Session["msg"] = "Deleted Successfully";
            }
            catch { }

            return(RedirectToAction("Edit", new { id = journalvoucherdetail.JournalVoucherID }));
        }
        private long saveJournalVoucher(JournalVoucherViewModel model)
        {
            JournalVoucher entity = new JournalVoucher();
            entity.CompanyId = AuthenticationHelper.User.CompanyId;
            entity.ConversionRate = model.ConversionRate;
            entity.CreateDate = DateTime.Now;
            entity.CurrencyId = model.CurrencyId;
            entity.Description = model.Description;
            entity.DocumentNo = model.DocumentNo;
            entity.GLDate = model.GLDate;
            entity.Id = model.Id;
            entity.JournalName = model.JournalName;
            entity.PeriodId = model.PeriodId;
            //entity.PostingFlag = codeCombinitionService.GetSingle(model.CodeCombinationId.ToString(), AuthenticationHelper.User.CompanyId).AllowedPosting;
            entity.PostingFlag = true;
            entity.SOBId = model.SOBId;
            entity.UpdateDate = DateTime.Now;

            if (entity.Id == 0)
            {
                entity.Id = Convert.ToInt32(service.Insert(entity));
            }
            else
            {
                entity.Id = Convert.ToInt32(service.Update(entity));
            }

            if (model.JournalVoucherDetail.Any())
            {
                foreach (var detail in model.JournalVoucherDetail)
                {
                    detail.HeaderId = entity.Id;

                    JournalVoucherDetail entityDetail = new JournalVoucherDetail();
                    entityDetail.AccountedCr = detail.AccountedCr;
                    entityDetail.AccountedDr = detail.AccountedDr;
                    entityDetail.CodeCombinationId = detail.CodeCombinationId;
                    entityDetail.CreateDate = DateTime.Now;
                    entityDetail.Description = detail.Description;
                    entityDetail.EnteredCr = detail.EnteredCr;
                    entityDetail.EnteredDr = detail.EnteredDr;
                    entityDetail.HeaderId = detail.HeaderId;
                    entityDetail.Id = detail.Id;
                    entityDetail.Qty = detail.Qty;
                    entityDetail.TaxRateCode = detail.TaxRateCode;
                    entityDetail.UpdateDate = DateTime.Now;

                    if (entityDetail.Id == 0)
                    {
                        entityDetail.Id = Convert.ToInt32(service.Insert(entityDetail));
                    }
                    else
                    {
                        entityDetail.Id = Convert.ToInt32(service.Update(entityDetail));
                    }
                }
            }

            return entity.Id;
        }