public IPChequeDetail AgentBulkPaymentFloatingCheque(int Cheid)
        {
            IPChequeDetail Obj = new IPChequeDetail();

            try
            {
                using (SqlConnection connection = DataAccess.CreateConnection())
                {
                    SqlCommand command = DataAccess.CreateCommand(connection);

                    DataAccess.CreateStoredprocedure(command, "GetAgentBulkPaymentFloatingCheque_SP");
                    DataAccess.AddInParameter(command, "@Cheid", SqlDbType.Int, Cheid);

                    SqlDataReader reader = DataAccess.ExecuteReader(command);
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            Obj.AccountNo = reader["AccountNo"] is DBNull ? string.Empty : Convert.ToString(reader["AccountNo"]);
                            Obj.Amount    = reader["Amount"] is DBNull ? 0 : Convert.ToDouble(reader["Amount"]);
                            //Obj.BankNames = reader["BankNames"] is DBNull ? 0 : (BankName)reader["BankNames"];
                            Obj.SortCode      = reader["SortCode"] is DBNull ? string.Empty : Convert.ToString(reader["SortCode"]);
                            Obj.SysCreateDate = reader["LedgerDate"] is DBNull ? DateTime.MinValue : Convert.ToDateTime(reader["LedgerDate"]);
                            Obj.Remarks       = reader["Remarks"] is DBNull ? string.Empty : Convert.ToString(reader["Remarks"]);
                        }
                    }
                    reader.Close();
                    return(Obj);
                }
            }
            catch (Exception ex)
            {
                return(Obj);
            }
        }
Пример #2
0
        private void chequeTransaction(ChequeDetails model)
        {
            IPChequeDetail ipcObj = new IPChequeDetail();

            ipcObj.AccountNo         = model.AccountNo;
            ipcObj.Amount            = model.Amount;
            ipcObj.ApplicationUserId = User.Identity.GetUserId();
            ipcObj.BankNames         = model.BankNames;
            ipcObj.ChequeNo          = model.ChequeNo;
            ipcObj.GeneralLedgerId   = null;
            ipcObj.InvoiceId         = null;
            ipcObj.InvoicePaymentId  = null;
            ipcObj.OtherInvoiceId    = model.InvoiceId;
            ipcObj.Remarks           = model.Remarks;
            ipcObj.SortCode          = model.SortCode;
            ipcObj.SysCreateDate     = DateTime.Now;
            ipcObj.Status            = ChequeStatus.Floating;
            ipcObj.BulkPayment       = false;
            db.IPChequeDetails.Add(ipcObj);
            db.SaveChanges();

            OtherInvoiceLog ilObj = new OtherInvoiceLog();

            ilObj.ApplicationUserId = ipcObj.ApplicationUserId;
            ilObj.OtherInvoiceId    = model.InvoiceId;
            ilObj.Remarks           = "Cheque Payment Received - " + model.Remarks;
            ilObj.SysDateTime       = ipcObj.SysCreateDate;
            db.OtherInvoiceLogs.Add(ilObj);
            db.SaveChanges();
        }
Пример #3
0
 public ActionResult ChequeRealize(int inv, string Name, int cheid)
 {
     try
     {
         if (inv < 1 || string.IsNullOrEmpty(Name) || cheid < 1)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         else
         {
             IPChequeDetail chequeObj = db.IPChequeDetails.Find(cheid);
             Invoice        invObj    = db.Invoices.Find(inv);
             if (chequeObj != null && invObj != null)
             {
                 ChequeRealizeViewModel Obj = new ChequeRealizeViewModel();
                 Obj.AccountNo        = chequeObj.AccountNo;
                 Obj.Agents           = invObj.Agents;
                 Obj.Amount           = chequeObj.Amount;
                 Obj.BankName         = BankHelper.getBankName(chequeObj.BankNames.ToString());
                 Obj.BankNames        = chequeObj.BankNames;
                 Obj.ChequeNo         = chequeObj.ChequeNo;
                 Obj.InvoiceId        = inv;
                 Obj.IPChequeDetailId = cheid;
                 Obj.Remarks          = chequeObj.Remarks;
                 Obj.SortCode         = chequeObj.SortCode;
                 return(View(Obj));
             }
             else
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #4
0
        public ActionResult ChequeRealize(ChequeRealizeViewModel model)
        {
            if (ModelState.IsValid)
            {
                int           GeneralLedgerHeadId = (int)db.BankAccountLedgerHeads.Find(1).GeneralLedgerHeadId;
                GeneralLedger glObj = new GeneralLedger {
                    Amount = model.Amount, ApplicationUserId = User.Identity.GetUserId(), GeneralLedgerHeadId = GeneralLedgerHeadId, Notes = model.RealizationRemarks + " - " + model.Remarks + " - " + "Cheque Realization", PaymentMethods = PaymentMethod.Cheque, StatementTypes = TransactionType.Income, SysDateTime = DateTime.Now, GeneralLedgerType = LedgerType.Credit
                };
                db.GeneralLedgers.Add(glObj);
                db.SaveChanges();

                Agent agent = db.Agents.Find(model.Agents.Id);
                agent.Balance         = (agent.Balance - model.Amount);
                db.Entry(agent).State = EntityState.Modified;
                db.SaveChanges();

                AgentLedger alObj = new AgentLedger {
                    AgentId = model.Agents.Id, AgentLedgerHeadId = 3, Amount = model.Amount, ApplicationUserId = glObj.ApplicationUserId, Balance = agent.Balance, Remarks = glObj.Notes, SystemDate = glObj.SysDateTime
                };
                db.AgentLedgers.Add(alObj);
                db.SaveChanges();

                BankAccount baObj = db.BankAccounts.Find(model.BankAccountId);
                baObj.Balance         = (baObj.Balance + model.Amount);
                db.Entry(baObj).State = EntityState.Modified;
                db.SaveChanges();

                BankAccountLedger bclObj = new BankAccountLedger {
                    Amount = model.Amount, ApplicationUserId = glObj.ApplicationUserId, Balance = baObj.Balance, BankAccountId = model.BankAccountId, BankAccountLedgerHeadId = 1, LedgerTypes = LedgerType.Credit, Notes = glObj.Notes, PaymentMethods = PaymentMethod.Cheque, RelationId = null, SysDateTime = glObj.SysDateTime
                };
                db.BankAccountLedgers.Add(bclObj);
                db.SaveChanges();

                InvoicePayment ipObj = new InvoicePayment {
                    Amount = model.Amount, ApplicationUserId = glObj.ApplicationUserId, GeneralLedgerId = glObj.Id, InvoiceId = model.InvoiceId, PaymentMethods = PaymentMethod.Cheque, Remarks = model.RealizationRemarks + " - " + model.Remarks + " - " + "Cheque Realization", SysDateTime = glObj.SysDateTime, AgentLedgerId = alObj.Id, BankAccountLedgerId = bclObj.Id
                };
                db.InvoicePayments.Add(ipObj);
                db.SaveChanges();

                InvoiceLog ilObj = new InvoiceLog {
                    ApplicationUserId = glObj.ApplicationUserId, InvoiceId = model.InvoiceId, Remarks = "Payment Received by Cheque Transaction - Realization", SysDateTime = glObj.SysDateTime
                };
                db.InvoiceLogs.Add(ilObj);
                db.SaveChanges();

                IPChequeDetail ipchObj = db.IPChequeDetails.Find(model.IPChequeDetailId);
                ipchObj.GeneralLedgerId  = glObj.Id;
                ipchObj.InvoicePaymentId = ipObj.Id;
                ipchObj.BulkPayment      = false;
                ipchObj.Status           = ChequeStatus.Passed;
                db.Entry(ipchObj).State  = EntityState.Modified;
                db.SaveChanges();

                bclObj.RelationId       = ipchObj.Id;
                db.Entry(ipchObj).State = EntityState.Modified;
                db.SaveChanges();
                FlashMessage.Confirmation("Floating Cheque Realized");
                return(RedirectToAction("FloatingCheque", "Accounting"));
            }
            else
            {
                return(RedirectToAction("FloatingCheque", "Accounting"));
            }
        }