private void LoadMatrix(string lStrYear, string lStrPeriod, string lStrNo, string NameServer, string NameDB, string Login, string Password) { AccountsDAO lObjAccount = new AccountsDAO(); this.UIAPIRawForm.DataSources.DataTables.Item("DTMatrix") .ExecuteQuery(lObjAccount.GetAccts(lStrYear, lStrPeriod, lStrNo, NameServer, NameDB, Login, Password)); mObjMtx.Columns.Item("clICD").DataBind.Bind("DTMatrix", "ICDNOM"); mObjMtx.Columns.Item("cAIMPO").DataBind.Bind("DTMatrix", "AIMPO"); mObjMtx.Columns.Item("cNIVEL").DataBind.Bind("DTMatrix", "NIVEL"); mObjMtx.Columns.Item("cCUE").DataBind.Bind("DTMatrix", "CUE"); //mObjMtx.Columns.Item("cCUE").DataBind.Bind("DTMatrix", "ACONC"); //mObjMtx.Columns.Item("cCUE").DataBind.Bind("DTMatrix", "ATRAB"); mObjMtx.Columns.Item("cCC").DataBind.Bind("DTMatrix", "CC"); mObjMtx.Columns.Item("cPROY").DataBind.Bind("DTMatrix", "PROY"); mObjMtx.Columns.Item("cAcc1").DataBind.Bind("DTMatrix", "CUENTA1"); mObjMtx.Columns.Item("cNNOM").DataBind.Bind("DTMatrix", "NNOM"); mObjMtx.Columns.Item("cNRFC").DataBind.Bind("DTMatrix", "NRFC"); mObjDT = this.UIAPIRawForm.DataSources.DataTables.Item("DTMatrix"); mObjMtx.LoadFromDataSource(); mObjMtx.AutoResizeColumns(); CalculateTotal(); }
public ActionResult AccountHead(string term) { int branchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); if (!String.IsNullOrEmpty(term)) { List <AcHeadSelectAllVM> AccountHeadList = new List <AcHeadSelectAllVM>(); AccountHeadList = AccountsDAO.GetAcHeadSelectAll(branchID).Where(c => c.AcHead.ToLower().Contains(term.ToLower())).OrderBy(x => x.AcHead).ToList();; //List<AcHeadSelectAll_Result> AccountHeadList = new List<AcHeadSelectAll_Result>(); //AccountHeadList =db.AcHeadSelectAll(branchID).Where(c => c.AcHead.ToLower().Contains(term.ToLower())).OrderBy(x => x.AcHead).ToList(); return(Json(AccountHeadList, JsonRequestBehavior.AllowGet)); //List<AcHeadSelectAll_Result> AccountHeadList = new List<AcHeadSelectAll_Result>(); //AccountHeadList = MM.AcHeadSelectAll(Common.ParseInt(Session["CurrentBranchID"].ToString()), term); } else { List <AcHeadSelectAllVM> AccountHeadList = new List <AcHeadSelectAllVM>(); AccountHeadList = AccountsDAO.GetAcHeadSelectAll(branchID); //List<AcHeadSelectAll_Result> AccountHeadList = new List<AcHeadSelectAll_Result>(); //AccountHeadList = db.AcHeadSelectAll(branchID).ToList(); return(Json(AccountHeadList, JsonRequestBehavior.AllowGet)); } }
public bool SaveAccountDetailCopy(List <AccountDetail> saveData) { using (DbContextTransaction transaction = Context.Database.BeginTransaction()) { try { AccountsDAO.DeleteAccountDetailByCompany(); foreach (AccountDetail data in saveData) { switch (data.Status) { // Add new case ModifyMode.Insert: this.AccountsDAO.InsertAccountDetail(data); break; } } transaction.Commit(); return(true); } catch (Exception ex) { transaction.Rollback(); BSLog.Logger.Error(ex.Message); return(false); } } }
public string GetAccounts() { int branchID = 5; // Convert.ToInt32(Session["CurrentBranchID"].ToString()); List <AcHeadSelectAllVM> AccountHeadList = new List <AcHeadSelectAllVM>(); AccountHeadList = AccountsDAO.GetAcHeadSelectAll(branchID).ToList(); return(Newtonsoft.Json.JsonConvert.SerializeObject(AccountHeadList));// IEnumerable<AcHeadSelectAllVM>AccountHeadList; }
public ActionResult DeleteDebitNote(int id) { //int k = 0; if (id != 0) { string result = AccountsDAO.DeleteDebiteNote(id); TempData["SuccessMsg"] = result; } return(RedirectToAction("Index", "DebitNote")); }
public ActionResult CostAccountHead(string term) { int branchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); if (!String.IsNullOrEmpty(term.Trim())) { List <AcHeadSelectAllVM> AccountHeadList = new List <AcHeadSelectAllVM>(); AccountHeadList = AccountsDAO.GetAcHeadSelectAllByCategory(branchID, "EXPENSE").Where(c => c.AcHead.ToLower().Contains(term.ToLower())).OrderBy(x => x.AcHead).ToList();; return(Json(AccountHeadList, JsonRequestBehavior.AllowGet)); } else { List <AcHeadSelectAllVM> AccountHeadList = new List <AcHeadSelectAllVM>(); AccountHeadList = AccountsDAO.GetAcHeadSelectAllByCategory(branchID, "EXPENSE"); return(Json(AccountHeadList, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(int id = 0) { //List<Invoices> lst = new List<Invoices>(); //ViewBag.Supplier = db.SupplierMasters.OrderBy(x => x.SupplierName).ToList(); //ViewBag.AcHead = db.AcHeads.OrderBy(x => x.AcHead1).ToList(); //ViewBag.Invoice = lst; //return View(); int fyearid = Convert.ToInt32(Session["fyearid"].ToString()); ViewBag.Supplier = db.SupplierMasters.OrderBy(x => x.SupplierName).ToList(); ViewBag.AcHead = db.AcHeads.OrderBy(x => x.AcHead1).ToList(); if (id == 0) { ViewBag.Title = "DEBIT NOTE/SUPPLIER JOURNAL"; DebitNoteVM vm = new DebitNoteVM(); vm.DebitNoteNo = AccountsDAO.GetMaxDebiteNoteNo(fyearid); vm.Date = CommanFunctions.GetLastDayofMonth().Date; vm.AcHeadID = 337; vm.TransType = ""; //vm.AmountType = "1"; //vm.AcDetailAmountType = "0"; List <DebitNoteDetailVM> list = new List <DebitNoteDetailVM>(); vm.Details = list; Session["DebitNoteDetail"] = list; return(View(vm)); } else { ViewBag.Title = "DEBIT NOTE/SUPPLIER JOURNAL - Modify"; DebitNoteVM vm = new DebitNoteVM(); var v = db.DebitNotes.Find(id); vm.DebitNoteId = v.DebitNoteID; vm.Date = v.DebitNoteDate; vm.AcJournalID = Convert.ToInt32(v.AcJournalID); vm.DebitNoteNo = v.DebitNoteNo; vm.SupplierID = Convert.ToInt32(v.SupplierID); vm.AcHeadID = Convert.ToInt32(v.AcHeadID); vm.Amount = Convert.ToDecimal(v.Amount); vm.InvoiceType = v.InvoiceType; vm.Remarks = v.Remarks; vm.TransType = v.TransType; vm.InvoiceID = Convert.ToInt32(v.InvoiceID); if (v.RecPayID != null && v.RecPayID != 0) { vm.RecPayID = Convert.ToInt32(v.RecPayID); } else { vm.RecPayID = 0; } var detaillist = (from c in db.DebitNoteDetails join d in db.AcHeads on c.AcHeadID equals d.AcHeadID where c.DebitNoteID == v.DebitNoteID select new DebitNoteDetailVM { AcHeadID = c.AcHeadID, AcHeadName = d.AcHead1, Amount = c.Amount, Remarks = c.Remarks }).ToList(); vm.Details = detaillist; Session["DebitNoteDetail"] = detaillist; SetTradeInvoiceOfSupplier(vm.SupplierID, 0, vm.DebitNoteId, vm.TransType); List <CustomerTradeReceiptVM> lst = (List <CustomerTradeReceiptVM>)Session["SupplierInvoice"]; if (v.TransType == "DN") { if (v.InvoiceType == "TR") { var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "TR").FirstOrDefault(); //var invoice = db.SupplierInvoices.Find(vm.InvoiceID); if (invoice != null) { vm.InvoiceNo = invoice.InvoiceNo; vm.InvoiceDate = invoice.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount); vm.AmountPaid = Convert.ToDecimal(invoice.AmountReceived); } } else if (v.InvoiceType == "OP") { var invoice1 = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "OP").FirstOrDefault(); //var invoice1 = db.AcOPInvoiceDetails.Where(cc => cc.AcOPInvoiceDetailID == vm.InvoiceID).FirstOrDefault(); if (invoice1 != null) { vm.InvoiceNo = invoice1.InvoiceNo; vm.InvoiceDate = invoice1.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice1.InvoiceAmount); vm.AmountPaid = Convert.ToDecimal(invoice1.AmountReceived); } } } else if (v.RecPayID != null && v.RecPayID != 0 && v.TransType == "SJ") { vm.InvoiceID = Convert.ToInt32(v.RecPayID); vm.InvoiceType = v.InvoiceType; vm.ForInvoice = true; if (v.InvoiceType == "TR") { var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "TR").FirstOrDefault(); if (invoice != null) { vm.InvoiceNo = invoice.InvoiceNo; vm.InvoiceDate = invoice.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount); vm.AmountPaid = Convert.ToDecimal(invoice.AmountReceived); } } else if (v.InvoiceType == "OP") { var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "OP").FirstOrDefault(); vm.InvoiceNo = invoice.InvoiceNo; vm.InvoiceDate = invoice.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount); vm.AmountPaid = Convert.ToDecimal(invoice.AmountReceived); } } else { vm.ForInvoice = false; } //SetTradeInvoiceOfCustomer(vm.CustomerID, 0, vm.CreditNoteID); vm.Date = Convert.ToDateTime(v.DebitNoteDate); return(View(vm)); } }
public ActionResult Create(DebitNoteVM v) { var userid = Convert.ToInt32(Session["UserID"]); int BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); AcJournalMaster ajm = new AcJournalMaster(); int fyearid = Convert.ToInt32(Session["fyearid"].ToString()); if (v.DebitNoteId > 0) { ajm = db.AcJournalMasters.Find(v.AcJournalID); var ajmd = db.AcJournalDetails.Where(cc => cc.AcJournalID == v.AcJournalID).ToList(); db.AcJournalDetails.RemoveRange(ajmd); db.AcJournalMasters.Remove(ajm); db.SaveChanges(); v.AcJournalID = 0; } if (v.AcJournalID == 0) { int acjm = 0; acjm = (from c in db.AcJournalMasters orderby c.AcJournalID descending select c.AcJournalID).FirstOrDefault(); ajm.AcJournalID = acjm + 1; ajm.AcCompanyID = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); ajm.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); ajm.AcFinancialYearID = fyearid; ajm.PaymentType = 1; var customer = db.SupplierMasters.Find(v.SupplierID).SupplierName; ajm.Remarks = v.Remarks; // + " DN: for " + customer + " invoice : " + v.InvoiceNo; ajm.StatusDelete = false; ajm.VoucherNo = AccountsDAO.GetMaxVoucherNo(v.TransType, fyearid); ajm.TransDate = v.Date; ajm.TransType = 1; ajm.VoucherType = v.TransType; db.AcJournalMasters.Add(ajm); db.SaveChanges(); } AcJournalDetail a = new AcJournalDetail(); a = db.AcJournalDetails.Where(cc => cc.AcJournalID == ajm.AcJournalID && cc.Amount > 0).FirstOrDefault(); if (a == null) { a = new AcJournalDetail(); a.AcJournalDetailID = 0; } if (a.AcJournalDetailID == 0) { int maxacj = (from c in db.AcJournalDetails orderby c.AcJournalDetailID descending select c.AcJournalDetailID).FirstOrDefault(); a.AcJournalDetailID = maxacj + 1; a.AcJournalID = ajm.AcJournalID; //var customercon = db.AcHeads.Where(cc => cc.AcHead1 == "Supplier Control A/c ( Cr)").FirstOrDefault(); a.AcHeadID = 337; //customercon.AcHeadID; ; } a.Amount = v.Amount; a.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); a.Remarks = v.Remarks; if (a.ID == 0) { db.AcJournalDetails.Add(a); db.SaveChanges(); } else { db.Entry(a).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } foreach (var detail in v.Details) { AcJournalDetail b = new AcJournalDetail(); b = db.AcJournalDetails.Where(cc => cc.AcJournalID == ajm.AcJournalID && cc.Amount < 0).FirstOrDefault(); if (b == null) { b = new AcJournalDetail(); b.AcJournalDetailID = 0; } if (b.AcJournalDetailID == 0) { int maxacj = 0; maxacj = (from c in db.AcJournalDetails orderby c.AcJournalDetailID descending select c.AcJournalDetailID).FirstOrDefault(); b.AcJournalDetailID = maxacj + 1; b.AcJournalID = ajm.AcJournalID; } b.AcHeadID = v.AcHeadID; if (v.TransType == "DN") { b.Amount = -1 * detail.Amount; } else { b.Amount = detail.Amount; } b.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); b.Remarks = detail.Remarks; if (b.ID == 0) { db.AcJournalDetails.Add(b); db.SaveChanges(); } else { db.Entry(b).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } DebitNote d = new DebitNote(); if (v.DebitNoteId == 0) { int maxid = 0; var data = (from c in db.DebitNotes orderby c.DebitNoteID descending select c).FirstOrDefault(); if (data == null) { maxid = 1; } else { maxid = data.DebitNoteID + 1; } d.CreatedBy = userid; d.CreatedDate = CommanFunctions.GetCurrentDateTime(); d.DebitNoteID = maxid; d.DebitNoteNo = AccountsDAO.GetMaxDebiteNoteNo(fyearid); } else { d = db.DebitNotes.Find(v.DebitNoteId); var det = db.DebitNoteDetails.Where(cc => cc.DebitNoteID == v.DebitNoteId).ToList(); if (det != null) { db.DebitNoteDetails.RemoveRange(det); db.SaveChanges(); } } d.InvoiceType = v.InvoiceType; d.TransType = v.TransType; if (v.InvoiceID != 0) { if (v.TransType == "DN") { d.InvoiceID = v.InvoiceID; } else { d.RecPayID = v.InvoiceID; } } else { d.InvoiceID = 0; } d.DebitNoteDate = v.Date; d.Amount = v.Amount; d.AcJournalID = ajm.AcJournalID; d.FYearID = Convert.ToInt32(Session["fyearid"].ToString()); d.AcCompanyID = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); d.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); d.AcHeadID = 527;; d.SupplierID = v.SupplierID; d.ModifiedBy = userid; d.ModifiedDate = CommanFunctions.GetCurrentDateTime(); d.Remarks = v.Remarks; //d.IsShipping = true; if (v.DebitNoteId == 0) { db.DebitNotes.Add(d); db.SaveChanges(); TempData["SuccessMsg"] = "Successfully Added Debit Note"; } else { db.Entry(d).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); TempData["SuccessMsg"] = "Successfully Updated Debit Note"; } foreach (var detail in v.Details) { DebitNoteDetail det = new DebitNoteDetail(); det.AcHeadID = detail.AcHeadID; det.Amount = detail.Amount; det.Remarks = detail.Remarks; det.DebitNoteID = d.DebitNoteID; db.DebitNoteDetails.Add(det); db.SaveChanges(); } return(RedirectToAction("Index", "DebitNote")); }
private void btnExtrae_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; mListObjLogin = new List <LoginDTO>(); if (btnExtrae.Caption == "Nueva Captura") { NewSearch(); return; } if (btnExtrae.Caption == "Buscar Nómina") { bool Result = Check_txts(); if (Result) { Enabled_txt(false, "btnCarga"); Enabled_btn(true, "btnCarga"); string lStrYear = txtYear.Value; string lStrPeriod = cmbPeriod.Value; string lStrNo = txtNo.Value; try { this.UIAPIRawForm.Freeze(true); LoginDTO lObjLogin = GetSetupLogin().FirstOrDefault(x => x.Code == int.Parse(cmbPeriod.Value)); if (lObjLogin != null) { Application.SBO_Application.StatusBar.SetText("Buscando información... Porfavor espere", SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); List <int> lLstEmpId = new List <int>(); EmployeesDAO lObjEmp = new EmployeesDAO(); btnExtrae.Caption = "Nueva Captura"; List <Nomina> lLstNomina = new List <Nomina>(); AccountsDAO lObjAccount = new AccountsDAO(); gLstNomina = new List <Nomina>(); gLstNomina = lObjAccount.GetAccounts(lStrYear, lStrPeriod, lStrNo, lObjLogin.NameServer, lObjLogin.NameDB, lObjLogin.Login, lObjLogin.Password); //lObjEmpItem if (gLstNomina.Count > 0) { lLstNomina.AddRange(gLstNomina); } else { Application.SBO_Application.StatusBar.SetText("Sin registros para mostrar", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } ConvertListIntoDataTable(lLstNomina); Grid0.DataTable = this.UIAPIRawForm.DataSources.DataTables.Item("DT_0"); Grid0.AutoResizeColumns(); } else { Application.SBO_Application.StatusBar.SetText("No se puedo establecer la conexión con el Servidor de Nómina", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } catch (Exception ex) { Application.SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } finally { this.UIAPIRawForm.Freeze(false); } } else { Application.SBO_Application.StatusBar.SetText("No hay datos capturados para extraer. Favor de primero capturar datos", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } }
private void btnCarga_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; mListObjLogin = new List <LoginDTO>(); AccountsDAO lObjAccounts = null; string lStrCtaPuente = ""; bool lBolResult = Check_txts(); if (lBolResult && gLstNomina.Count > 0) { //Tipo de Cambio USD if (!CheckCurrencyRate()) { Application.SBO_Application.StatusBar.SetText("Proceso Cancelado. Actualice el tipo de cambio USD.", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); return; } try { this.UIAPIRawForm.Freeze(true); mObjJournalEntries = (SAPbobsCOM.JournalEntries)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries); mListObjLogin = GetSetupLogin(); LoginDTO lObjLoginDTO = mListObjLogin.FirstOrDefault(x => x.Code == int.Parse(lStrValueCmb)); lStrCtaPuente = lObjLoginDTO.AccountingAccount; if (lObjLoginDTO != null) { //Existe Cuentas string lStrResult = string.Empty; string lStrYear = txtYear.Value; string lStrPeriod = cmbPeriod.Value; string lStrNo = txtNo.Value; Application.SBO_Application.StatusBar.SetText("Procesando cuentas contables... Porfavor espere", SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); lObjAccounts = new AccountsDAO(); var lVarGroupAcc = from p in gLstNomina group p by p.CUENTA into grouped select grouped; lStrResult = lObjAccounts.CheckAccounts(lVarGroupAcc); if (lStrResult != string.Empty) { Application.SBO_Application.StatusBar.SetText("Proceso Cancelado. Actualice las cuentas." + lStrResult, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); return; } Application.SBO_Application.StatusBar.SetText("Procesando centros de costos... Porfavor espere", SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); //Existe Centro de Costos lStrResult = string.Empty; lObjAccounts = new AccountsDAO(); var lVarGpCC = from p in gLstNomina group p by p.CUENTA2 into grouped select grouped; lStrResult = lObjAccounts.CheckCostingCode(lVarGpCC); if (lStrResult != string.Empty) { Application.SBO_Application.StatusBar.SetText("Proceso Cancelado. Actualice los Centros de Costo." + lStrResult, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); return; } mDoubleImpoDedu = 0.0; mDoubleImpoPerc = 0.0; //Obtener Clave de SAP en empleados List <EmployeesDTO> lLstEmployeesDTO = mObjEmployeesDAO.GetEmployeeID(); var lObjQuery = from nom in gLstNomina join emp in lLstEmployeesDTO on nom.ATRAB equals emp.IdEmpSAP select new { nom, emp }; List <string> lLstMissingEmp = new List <string>(); foreach (var lObjQItem in lObjQuery) { if (lObjQItem.emp.IdEmpNomina == null) { lLstMissingEmp.Add(lObjQItem.emp.FullName); } lObjQItem.nom.ATRAB = (int?)lObjQItem.emp.IdEmpNomina; } if (lLstMissingEmp.Count > 0) { string lStrMissingEmp = string.Empty; foreach (var lObjEmpItem in lLstMissingEmp.Distinct().ToList()) { lStrMissingEmp += lObjEmpItem + ", "; } Application.SBO_Application.MessageBox("Para continuar, registre en SAP los siguientes empleados: " + lStrMissingEmp); NewSearch(); return; } mObjJournalEntries = PopulateJournalEntries(); //encabezado mObjJournalEntries = PopulateDetails(mObjJournalEntries, gLstNomina, lStrCtaPuente); //lineas int lIntRespJournal = mObjJournalEntries.Add(); if (lIntRespJournal == 0) { NewSearch(); Application.SBO_Application.MessageBox("Proceso terminado. Se cargo con exito el asiento contable"); Application.SBO_Application.StatusBar.SetText("Proceso terminado. Se cargo con exito el asiento contable", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success); } else { int lIntError = 0; string lStrError = string.Empty; string xdxd = DIApplication.Company.GetLastErrorDescription(); DIApplication.Company.GetLastError(out lIntError, out lStrError); Application.SBO_Application.StatusBar.SetText("Proceso Cancelado. Error al cargar el asiento contable " + lStrError, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } } else { Application.SBO_Application.StatusBar.SetText("No se puedo establecer la conexión con el Servidor de Nómina", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } catch (Exception ex) { Application.SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } finally { this.UIAPIRawForm.Freeze(false); MemoryUtility.ReleaseComObject(mObjJournalEntries); //btnCarga.Item.Enabled = false; } } else { Application.SBO_Application.StatusBar.SetText("No hay datos a importar. Favor de primero Buscar Nómina", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } }
public ActionResult Create(int id = 0) { int fyearid = Convert.ToInt32(Session["fyearid"].ToString()); //ViewBag.customer = db.CustomerMasters.Where(d => d.CustomerType == "CR").OrderBy(x => x.CustomerName).ToList(); ViewBag.achead = db.AcHeads.ToList(); if (id == 0) { ViewBag.Title = "CREDIT NOTE/CUSTOMER JOURNAL"; CreditNoteVM vm = new CreditNoteVM(); vm.CreditNoteNo = AccountsDAO.GetMaxCreditNoteNo(fyearid); vm.Date = CommanFunctions.GetLastDayofMonth().Date; vm.TransType = ""; vm.AcHeadID = 52; //Customer control account vm.AmountType = "0"; vm.AcDetailAmountType = "1"; List <CreditNoteDetailVM> list = new List <CreditNoteDetailVM>(); vm.Details = list; Session["CreditNoteDetail"] = list; return(View(vm)); } else { ViewBag.Title = "CREDIT NOTE/CUSTOMER JOURNAL - Modify"; CreditNoteVM vm = new CreditNoteVM(); var v = db.CreditNotes.Find(id); vm.CreditNoteID = v.CreditNoteID; vm.CreditNoteNo = v.CreditNoteNo; vm.Date = Convert.ToDateTime(v.CreditNoteDate); vm.AcJournalID = Convert.ToInt32(v.AcJournalID); vm.CustomerID = Convert.ToInt32(v.CustomerID); var customer = db.CustomerMasters.Find(v.CustomerID).CustomerName; if (customer != null) { vm.CustomerName = customer; } vm.AcHeadID = Convert.ToInt32(v.AcHeadID); vm.Amount = Convert.ToDecimal(v.Amount); vm.Description = v.Description; vm.TransType = v.TransType; if (v.RecPayID != null && v.RecPayID != 0) { vm.RecPayID = Convert.ToInt32(v.RecPayID); } else { vm.RecPayID = 0; } var detaillist = (from c in db.CreditNoteDetails join d in db.AcHeads on c.AcHeadID equals d.AcHeadID where c.CreditNoteID == v.CreditNoteID select new CreditNoteDetailVM { AcHeadID = c.AcHeadID, AcHeadName = d.AcHead1, Amount = c.Amount, Remarks = c.Remarks }).ToList(); vm.Details = detaillist; Session["CreditNoteDetail"] = detaillist; if (v.InvoiceID != null && v.InvoiceID != 0 && v.TransType == "CN") { vm.InvoiceID = Convert.ToInt32(v.InvoiceID); vm.InvoiceType = v.InvoiceType; vm.ForInvoice = true; SetTradeInvoiceOfCustomer(vm.CustomerID, 0, vm.CreditNoteID, vm.TransType); List <CustomerTradeReceiptVM> lst = (List <CustomerTradeReceiptVM>)Session["CustomerInvoice"]; if (v.InvoiceType == "TR") { var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "TR").FirstOrDefault(); if (invoice != null) { vm.InvoiceNo = invoice.InvoiceNo; vm.InvoiceDate = invoice.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount); vm.ReceivedAmount = Convert.ToDecimal(invoice.AmountReceived); } } else if (v.InvoiceType == "OP") { //var invoice1 = db.AcOPInvoiceDetails.Where(cc=>cc.AcOPInvoiceDetailID ==vm.InvoiceID).FirstOrDefault(); //if (invoice1 != null) //{ // vm.InvoiceNo = invoice1.InvoiceNo; // vm.InvoiceDate = Convert.ToDateTime(invoice1.InvoiceDate).ToString("dd/MM/yyyy"); // vm.InvoiceAmount = Convert.ToDecimal(invoice1.Amount); //} var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "OP").FirstOrDefault(); vm.InvoiceNo = invoice.InvoiceNo; vm.InvoiceDate = invoice.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount); vm.ReceivedAmount = Convert.ToDecimal(invoice.AmountReceived); } } else if (v.RecPayID != null && v.RecPayID != 0 && v.TransType == "CJ") { vm.InvoiceID = Convert.ToInt32(v.RecPayID); vm.InvoiceType = v.InvoiceType; vm.ForInvoice = true; SetTradeInvoiceOfCustomer(vm.CustomerID, 0, vm.CreditNoteID, vm.TransType); List <CustomerTradeReceiptVM> lst = (List <CustomerTradeReceiptVM>)Session["CustomerInvoice"]; if (v.InvoiceType == "TR") { var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "TR").FirstOrDefault(); if (invoice != null) { vm.InvoiceNo = invoice.InvoiceNo; vm.InvoiceDate = invoice.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount); vm.ReceivedAmount = Convert.ToDecimal(invoice.AmountReceived); } } else if (v.InvoiceType == "OP") { var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "OP").FirstOrDefault(); vm.InvoiceNo = invoice.InvoiceNo; vm.InvoiceDate = invoice.DateTime; vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount); vm.ReceivedAmount = Convert.ToDecimal(invoice.AmountReceived); } } else { vm.ForInvoice = false; } vm.Date = Convert.ToDateTime(v.CreditNoteDate); //vm. return(View(vm)); } }
public ActionResult Create(int id = 0) { int FyearId = Convert.ToInt32(Session["fyearid"]); CustomerRcieptVM cust = new CustomerRcieptVM(); cust.CustomerRcieptChildVM = new List <CustomerRcieptChildVM>(); List <CurrencyMaster> Currencys = new List <CurrencyMaster>(); Currencys = MM.GetCurrency(); ViewBag.Currency = new SelectList(Currencys, "CurrencyID", "CurrencyName"); if (Session["UserID"] != null) { var branchid = Convert.ToInt32(Session["CurrentBranchID"]); if (id > 0) { ViewBag.Title = "COD Receipt - Modify"; cust = RP.GetRecPayByRecpayID(id); var acheadforcash = (from c in db.AcHeads join g in db.AcGroups on c.AcGroupID equals g.AcGroupID where g.AcGroup1 == "Cash" select new { AcHeadID = c.AcHeadID, AcHead = c.AcHead1 }).ToList(); var acheadforbank = (from c in db.AcHeads join g in db.AcGroups on c.AcGroupID equals g.AcGroupID where g.AcGroup1 == "Bank" select new { AcHeadID = c.AcHeadID, AcHead = c.AcHead1 }).ToList(); ViewBag.achead = acheadforcash; ViewBag.acheadbank = acheadforbank; cust.recPayDetail = db.RecPayDetails.Where(item => item.RecPayID == id).ToList(); int fyearid = Convert.ToInt32(Session["fyearid"].ToString()); var salesinvoice = new List <CustomerTradeReceiptVM>(); salesinvoice = ReceiptDAO.GetCODPending(fyearid, id); Session["CODAWBList"] = salesinvoice; cust.CustomerRcieptChildVM = new List <CustomerRcieptChildVM>(); foreach (var item in cust.recPayDetail) { if (item.InScanID > 0) { if (salesinvoice.Count > 0) { CustomerTradeReceiptVM sales = salesinvoice.Where(cc => cc.InScanID == Convert.ToInt32(item.InScanID)).FirstOrDefault(); decimal invoicetotal = Convert.ToDecimal(sales.InvoiceAmount); decimal received = Convert.ToDecimal(sales.AmountReceived); var allrecpay = (from d in db.RecPayDetails where d.InScanID == item.InScanID select d).ToList(); var totamtpaid = allrecpay.Sum(d => d.Amount) * -1; var totadjust = allrecpay.Sum(d => d.AdjustmentAmount); var customerinvoice = new CustomerRcieptChildVM(); customerinvoice.InvoiceType = "D"; var inscan = db.InScanMasters.Find(item.InScanID); if (inscan != null) { customerinvoice.InScanID = inscan.InScanID; customerinvoice.ConsignmentNo = inscan.ConsignmentNo; customerinvoice.strDate = Convert.ToDateTime(inscan.TransactionDate).ToString("dd/MM/yyyy"); } customerinvoice.AmountToBeRecieved = invoicetotal; customerinvoice.AmountToBePaid = received; customerinvoice.Amount = Convert.ToDecimal(item.Amount) * -1; customerinvoice.Balance = invoicetotal - received; customerinvoice.RecPayDetailID = item.RecPayDetailID; customerinvoice.RecPayID = Convert.ToInt32(item.RecPayID); customerinvoice.AdjustmentAmount = 0; cust.CustomerRcieptChildVM.Add(customerinvoice); } } } Session["AWBAllocation"] = cust.AWBAllocation; } else { ViewBag.Title = "COD Receipt - Create"; var codcust = db.CustomerMasters.Where(cc => cc.CustomerName == "Cod Customer").FirstOrDefault(); var acheadforcash = (from c in db.AcHeads join g in db.AcGroups on c.AcGroupID equals g.AcGroupID where g.AcGroup1 == "Cash" select new { AcHeadID = c.AcHeadID, AcHead = c.AcHead1 }).ToList(); var acheadforbank = (from c in db.AcHeads join g in db.AcGroups on c.AcGroupID equals g.AcGroupID where g.AcGroup1 == "Bank" select new { AcHeadID = c.AcHeadID, AcHead = c.AcHead1 }).ToList(); ViewBag.achead = acheadforcash; ViewBag.acheadbank = acheadforbank; DateTime pFromDate = AccountsDAO.CheckParamDate(DateTime.Now, FyearId).Date; cust.RecPayDate = pFromDate; cust.RecPayID = 0; cust.CustomerID = codcust.CustomerID; cust.DocumentNo = ReceiptDAO.SP_GetMaxCODID(); cust.CurrencyId = Convert.ToInt32(Session["CurrencyId"].ToString()); var salesinvoice = new List <CustomerTradeReceiptVM>(); if (codcust != null) { int fyearid = Convert.ToInt32(Session["fyearid"].ToString()); salesinvoice = ReceiptDAO.GetCODPending(fyearid, 0); Session["CODAWBList"] = salesinvoice; } } } else { return(RedirectToAction("Login", "Login")); } var StaffNotes = (from d in db.StaffNotes where d.PageTypeId == 2 orderby d.NotesId descending select d).ToList(); var users = (from d in db.UserRegistrations select d).ToList(); var staffnotemodel = new List <StaffNoteModel>(); foreach (var item in StaffNotes) { var model = new StaffNoteModel(); model.id = item.NotesId; model.employeeid = item.EmployeeId; //model.jobid = item.JobId; model.TaskDetails = item.Notes; model.Datetime = item.EntryDate; model.EmpName = users.Where(d => d.UserID == item.EmployeeId).FirstOrDefault().UserName; staffnotemodel.Add(model); } ViewBag.StaffNoteModel = staffnotemodel; var customerdetails = (from d in db.CustomerMasters where d.CustomerID == cust.CustomerID && d.CustomerType == "CS" select d).FirstOrDefault(); if (customerdetails == null) { customerdetails = new CustomerMaster(); } ViewBag.CustomerDetail = customerdetails; var CustomerNotification = (from d in db.CustomerNotifications where d.RecPayID == id && d.PageTypeId == 2 orderby d.NotificationId descending select d).ToList(); var customernotification = new List <CustomerNotificationModel>(); foreach (var item in CustomerNotification) { var model = new CustomerNotificationModel(); model.id = item.NotificationId; model.employeeid = item.UserId; model.jobid = item.RecPayID; model.Message = item.MessageText; model.Datetime = item.EntryDate; model.IsEmail = item.NotifyByEmail; model.IsSms = item.NotifyBySMS; model.IsWhatsapp = item.NotifyByWhatsApp; model.EmpName = users.Where(d => d.UserID == item.UserId).FirstOrDefault().UserName; customernotification.Add(model); } cust.AWBAllocation = new List <ReceiptAllocationDetailVM>(); ViewBag.CustomerNotification = customernotification; return(View(cust)); }