コード例 #1
0
        public TblVoucherMaster AddVoucherMaster(ERPContext context, TblInvoiceMasterReturn invoiceReturn, TblBranch branch, decimal?voucherTypeId, string paymentType)
        {
            try
            {
                var _voucherMaster = new TblVoucherMaster
                {
                    BranchCode        = invoiceReturn.BranchCode,
                    BranchName        = branch.BranchName,
                    VoucherDate       = invoiceReturn.InvoiceDate,
                    VoucherTypeIdMain = voucherTypeId,
                    VoucherTypeIdSub  = 35,
                    VoucherNo         = invoiceReturn.InvoiceReturnNo,
                    Amount            = invoiceReturn.GrandTotal,
                    PaymentType       = paymentType,//accountLedger.CrOrD
                    Narration         = "Sales Invoice Return",
                    ServerDate        = DateTime.Now,
                    UserId            = invoiceReturn.UserId,
                    UserName          = invoiceReturn.UserName,
                    EmployeeId        = -1
                };

                context.TblVoucherMaster.Add(_voucherMaster);
                if (context.SaveChanges() > 0)
                {
                    return(_voucherMaster);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
ファイル: InvoiceHelper.cs プロジェクト: lulzzz/CoreERPGit
        public TblVoucherMaster AddVoucherMaster(ERPContext context, TblInvoiceMaster invoice, TblBranch branch, decimal?voucherTypeId, string paymentType)
        {
            try
            {
                //using (ERPContext context = new ERPContext())
                //{
                var _voucherMaster = new TblVoucherMaster();
                _voucherMaster.BranchCode        = invoice.BranchCode;
                _voucherMaster.BranchName        = branch.BranchName;
                _voucherMaster.VoucherDate       = invoice.InvoiceDate;
                _voucherMaster.VoucherTypeIdMain = voucherTypeId;
                _voucherMaster.VoucherTypeIdSub  = 35;
                _voucherMaster.VoucherNo         = invoice.InvoiceNo;
                _voucherMaster.Amount            = invoice.GrandTotal;
                _voucherMaster.PaymentType       = paymentType;//accountLedger.CrOrD
                _voucherMaster.Narration         = "Sales Invoice";
                _voucherMaster.ServerDate        = DateTime.Now;
                _voucherMaster.UserId            = invoice.UserId;
                _voucherMaster.UserName          = invoice.UserName;
                _voucherMaster.EmployeeId        = -1;

                context.TblVoucherMaster.Add(_voucherMaster);
                if (context.SaveChanges() > 0)
                {
                    return(_voucherMaster);
                }
                #region comment
                //var _voucherMaster = new TblVoucherMaster();
                //_voucherMaster.BranchCode = invoice.BranchCode;
                //_voucherMaster.BranchName = _branch.BranchName;
                //_voucherMaster.VoucherDate = invoice.InvoiceDate;
                //_voucherMaster.VoucherTypeIdMain = _vouchertType.VoucherTypeId;
                //_voucherMaster.VoucherTypeIdSub = 35;
                //_voucherMaster.VoucherNo = invoice.InvoiceNo;
                //_voucherMaster.Amount  = invoice.GrandTotal;
                //_voucherMaster.PaymentType = _accountLedger.CrOrDr;
                //_voucherMaster.Narration = "Sales Invoice";
                //_voucherMaster.ServerDate = DateTime.Now;
                //_voucherMaster.UserId = invoice.UserId;
                //_voucherMaster.UserName = invoice.UserName;
                //_voucherMaster.EmployeeId = -1;

                //repo.TblVoucherMaster.Add(_voucherMaster);
                //if(!(repo.SaveChanges() > 0))
                //{
                //    dbTransaction.Rollback();
                //    return false;
                //}
                #endregion

                return(null);
                // }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public TblVoucherMaster AddVoucherMaster(ERPContext context, TblCashPaymentMaster cashPaymentMaster, TblBranch branch, decimal?voucherTypeId, string paymentType)
        {
            try
            {
                decimal shifId = Convert.ToDecimal(new UserManagmentHelper().GetShiftId(cashPaymentMaster.UserId ?? 0, null));
                //using (ERPContext context = new ERPContext())
                //{
                var _voucherMaster = new TblVoucherMaster
                {
                    BranchCode        = cashPaymentMaster.BranchCode,
                    BranchName        = branch.BranchName,
                    VoucherDate       = cashPaymentMaster.CashPaymentDate,
                    VoucherTypeIdMain = voucherTypeId,
                    VoucherTypeIdSub  = 37,
                    VoucherNo         = cashPaymentMaster.VoucherNo,
                    Amount            = cashPaymentMaster.TotalAmount,
                    PaymentType       = "Cash",
                    Narration         = "Cash Receipt",
                    ServerDate        = DateTime.Now,
                    UserId            = cashPaymentMaster.UserId,
                    UserName          = cashPaymentMaster.UserName,
                    EmployeeId        = -1,
                    ShiftId           = shifId
                };

                context.TblVoucherMaster.Add(_voucherMaster);
                if (context.SaveChanges() > 0)
                {
                    return(_voucherMaster);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
ファイル: PurchasesHelper.cs プロジェクト: lulzzz/CoreERPGit
        private TblVoucherDetail AddVoucherDetails(ERPContext context, TblPurchaseInvoice invoice, TblBranch _branch, TblVoucherMaster _voucherMaster, TblAccountLedger _accountLedger, decimal?productRate, bool isFromInvoiceDetials = true)
        {
            try
            {
                //using(ERPContext context=new ERPContext())
                //{
                var _voucherDetail = new TblVoucherDetail();
                _voucherDetail.VoucherMasterId   = _voucherMaster.VoucherMasterId;
                _voucherDetail.VoucherDetailDate = _voucherMaster.VoucherDate;
                _voucherDetail.BranchId          = _branch.BranchId;
                _voucherDetail.BranchCode        = invoice.BranchCode;
                _voucherDetail.BranchName        = invoice.BranchName;
                if (isFromInvoiceDetials)
                {
                    _voucherDetail.FromLedgerId   = invoice.LedgerId;
                    _voucherDetail.FromLedgerCode = invoice.LedgerCode;
                    _voucherDetail.FromLedgerName = invoice.LedgerName;
                }
                //To ledger  clarifiaction on selecion of product

                _voucherDetail.ToLedgerId      = _accountLedger.LedgerId;
                _voucherDetail.ToLedgerCode    = _accountLedger.LedgerCode;
                _voucherDetail.ToLedgerName    = _accountLedger.LedgerName;
                _voucherDetail.Amount          = productRate;
                _voucherDetail.TransactionType = _accountLedger.CrOrDr;
                _voucherDetail.CostCenter      = _accountLedger.BranchCode;
                _voucherDetail.ServerDate      = DateTime.Now;
                _voucherDetail.Narration       = $"Sales Invoice {_accountLedger.LedgerName} A /c: {_voucherDetail.TransactionType}";

                context.TblVoucherDetail.Add(_voucherDetail);
                if (context.SaveChanges() > 0)
                {
                    return(_voucherDetail);
                }

                #region comment
                //var _voucherDetail = new TblVoucherDetail();
                //_voucherDetail.VoucherMasterId = _voucherMaster.VoucherMasterId;
                //_voucherDetail.VoucherDetailDate = _voucherMaster.VoucherDate;
                //_voucherDetail.BranchId = _branch.BranchId;
                //_voucherDetail.BranchCode = invoice.BranchCode;
                //_voucherDetail.BranchName = invoice.BranchName;
                //_voucherDetail.FromLedgerId = invoice.LedgerId;
                //_voucherDetail.FromLedgerCode = invoice.LedgerCode;
                //_voucherDetail.FromLedgerName = invoice.LedgerName;
                ////To ledger  clarifiaction on selecion of product
                //_voucherDetail.ToLedgerId = _accountLedger.LedgerId;
                //_voucherDetail.ToLedgerCode = _accountLedger.LedgerCode;
                //_voucherDetail.ToLedgerName = _accountLedger.LedgerName;
                //_voucherDetail.Amount = invdtl.Rate;
                //_voucherDetail.TransactionType = _accountLedger.CrOrDr;
                //_voucherDetail.CostCenter = _accountLedger.BranchCode;
                //_voucherDetail.ServerDate = DateTime.Now;
                //_voucherDetail.Narration = "Sales Invoice Product group A/c:" + _voucherDetail.TransactionType;

                //repo.TblVoucherDetail.Add(_voucherDetail);
                //repo.SaveChanges();
                #endregion
                return(null);
                // }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        public TblVoucherDetail AddVoucherDetails(ERPContext context, TblBankReceiptMaster bankReceiptMaster, TblBranch _branch, TblVoucherMaster _voucherMaster, TblAccountLedger _accountLedger, decimal?productRate, decimal?ledgerId, string ledgerCode, bool isFromCashDetials = true)
        {
            try
            {
                var _voucherDetail = new TblVoucherDetail();
                var ledgerName     = GetAccountLedgerList().Where(al => al.LedgerCode == ledgerCode).FirstOrDefault();
                _voucherDetail.VoucherMasterId   = _voucherMaster.VoucherMasterId;
                _voucherDetail.VoucherDetailDate = _voucherMaster.VoucherDate;
                _voucherDetail.BranchId          = _branch.BranchId;
                _voucherDetail.BranchCode        = bankReceiptMaster.BranchCode;
                _voucherDetail.BranchName        = bankReceiptMaster.BranchName;
                if (isFromCashDetials == true)
                {
                    _voucherDetail.FromLedgerId    = bankReceiptMaster.BankLedgerId;
                    _voucherDetail.FromLedgerCode  = bankReceiptMaster.BankLedgerCode;
                    _voucherDetail.FromLedgerName  = bankReceiptMaster.BankLedgerName;
                    _voucherDetail.ToLedgerId      = ledgerName.LedgerId;
                    _voucherDetail.ToLedgerCode    = ledgerCode;
                    _voucherDetail.ToLedgerName    = ledgerName.LedgerName;
                    _voucherDetail.Amount          = productRate;
                    _voucherDetail.TransactionType = "Debit";
                    _voucherDetail.CostCenter      = bankReceiptMaster.BranchCode;
                    _voucherDetail.ServerDate      = DateTime.Now;
                    _voucherDetail.Narration       = "Bank Receipt Detail";
                }
                //To ledger  clarifiaction on selecion of product
                else
                {
                    _voucherDetail.FromLedgerId    = ledgerName.LedgerId;
                    _voucherDetail.FromLedgerCode  = ledgerCode;
                    _voucherDetail.FromLedgerName  = ledgerName.LedgerName;
                    _voucherDetail.ToLedgerId      = bankReceiptMaster.BankLedgerId;
                    _voucherDetail.ToLedgerCode    = bankReceiptMaster.BankLedgerCode;
                    _voucherDetail.ToLedgerName    = bankReceiptMaster.BankLedgerName;
                    _voucherDetail.Amount          = productRate;
                    _voucherDetail.TransactionType = "Credit";
                    _voucherDetail.CostCenter      = bankReceiptMaster.BranchCode;
                    _voucherDetail.ServerDate      = DateTime.Now;
                    _voucherDetail.Narration       = "Bank Receipt Detail";
                }

                context.TblVoucherDetail.Add(_voucherDetail);
                if (context.SaveChanges() > 0)
                {
                    return(_voucherDetail);
                }

                #region comment
                //var _voucherDetail = new TblVoucherDetail();
                //_voucherDetail.VoucherMasterId = _voucherMaster.VoucherMasterId;
                //_voucherDetail.VoucherDetailDate = _voucherMaster.VoucherDate;
                //_voucherDetail.BranchId = _branch.BranchId;
                //_voucherDetail.BranchCode = invoice.BranchCode;
                //_voucherDetail.BranchName = invoice.BranchName;
                //_voucherDetail.FromLedgerId = invoice.LedgerId;
                //_voucherDetail.FromLedgerCode = invoice.LedgerCode;
                //_voucherDetail.FromLedgerName = invoice.LedgerName;
                ////To ledger  clarifiaction on selecion of product
                //_voucherDetail.ToLedgerId = _accountLedger.LedgerId;
                //_voucherDetail.ToLedgerCode = _accountLedger.LedgerCode;
                //_voucherDetail.ToLedgerName = _accountLedger.LedgerName;
                //_voucherDetail.Amount = invdtl.Rate;
                //_voucherDetail.TransactionType = _accountLedger.CrOrDr;
                //_voucherDetail.CostCenter = _accountLedger.BranchCode;
                //_voucherDetail.ServerDate = DateTime.Now;
                //_voucherDetail.Narration = "Sales Invoice Product group A/c:" + _voucherDetail.TransactionType;

                //repo.TblVoucherDetail.Add(_voucherDetail);
                //repo.SaveChanges();
                #endregion
                return(null);
                // }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #6
0
        public bool RegisterBill(TblOilConversionMaster oilcnvsmaster, List <TblOilConversionDetails> oilcnvsmasterDetails)
        {
            try
            {
                //invoice.IsSalesReturned = false;
                //invoice.IsManualEntry = false;
                using (Repository <TblOilConversionMaster> repo = new Repository <TblOilConversionMaster>())
                {
                    //add voucher typedetails
                    var user    = repo.TblUser.Where(x => x.UserName == oilcnvsmaster.UserName).FirstOrDefault();
                    var shift   = repo.TblShift.Where(x => x.UserId == user.UserId).FirstOrDefault();
                    var _branch = GetBranches(oilcnvsmaster.BranchCode).ToArray().FirstOrDefault();
                    TblVoucherMaster vchrmastr = new TblVoucherMaster();
                    vchrmastr.BranchCode        = _branch.BranchCode;
                    vchrmastr.BranchName        = _branch.BranchName;
                    vchrmastr.VoucherDate       = DateTime.Now;
                    vchrmastr.VoucherTypeIdMain = oilcnvsmaster.VoucherTypeId;
                    vchrmastr.VoucherTypeIdSub  = oilcnvsmaster.VoucherTypeId;
                    vchrmastr.Narration         = oilcnvsmaster.Narration;
                    vchrmastr.ServerDate        = DateTime.Now;
                    vchrmastr.ShiftId           = shift.ShiftId;
                    vchrmastr.UserId            = user.UserId;
                    vchrmastr.UserName          = oilcnvsmaster.UserName;
                    vchrmastr.EmployeeId        = -1;

                    oilcnvsmaster.BranchCode         = _branch.BranchCode;
                    oilcnvsmaster.BranchName         = _branch.BranchName;
                    oilcnvsmaster.BranchId           = _branch.BranchId;
                    oilcnvsmaster.ServerDate         = DateTime.Now;
                    oilcnvsmaster.OilConversionDate  = oilcnvsmaster.OilConversionDate;
                    oilcnvsmaster.OilConversionVchNo = oilcnvsmaster.OilConversionVchNo;
                    oilcnvsmaster.VoucherTypeId      = oilcnvsmaster.VoucherTypeId;
                    oilcnvsmaster.ShiftId            = shift.ShiftId;
                    oilcnvsmaster.UserId             = user.UserId;
                    oilcnvsmaster.UserName           = oilcnvsmaster.UserName;
                    oilcnvsmaster.EmployeeId         = -1;
                    oilcnvsmaster.Narration          = oilcnvsmaster.Narration;
                    repo.TblVoucherMaster.Add(vchrmastr);
                    repo.TblOilConversionMaster.Add(oilcnvsmaster);
                    repo.SaveChanges();
                    foreach (var oilconversions in oilcnvsmasterDetails)
                    {
                        var _product = new InvoiceHelper().GetProducts(oilconversions.ProductCode).FirstOrDefault();

                        var oilcnvsmmstrid = GetOilConversionslist(oilcnvsmaster.OilConversionVchNo).FirstOrDefault();
                        #region StockIssueDetails
                        oilconversions.OilConversionMasterId    = oilcnvsmmstrid.OilConversionMasterId;
                        oilconversions.OilConversionMasterId    = oilconversions.OilConversionMasterId;
                        oilconversions.OilConversionDetailsDate = DateTime.Now;
                        oilconversions.ServerDateTime           = DateTime.Now;
                        oilconversions.ProductId   = _product.ProductId;
                        oilconversions.ProductCode = oilconversions.ProductCode;
                        oilconversions.ProductName = oilconversions.ProductName;
                        oilconversions.HsnNo       = oilconversions.HsnNo;
                        oilconversions.Rate        = oilconversions.Rate;
                        oilconversions.Qty         = oilconversions.Qty;
                        oilconversions.BatchNo     = oilconversions.BatchNo;
                        oilconversions.UnitId      = Convert.ToDecimal(_product.UnitId);
                        oilconversions.UnitName    = oilconversions.UnitName;
                        oilconversions.DamageQty   = oilconversions.DamageQty;
                        oilconversions.NewQty      = oilconversions.NewQty;
                        oilconversions.GrossAmount = oilconversions.GrossAmount;
                        repo.TblOilConversionDetails.Add(oilconversions);
                        repo.SaveChanges();
                        #endregion
                        {
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #7
0
        public TblVoucherDetail AddVoucherDetails(ERPContext context, TblJournalVoucherMaster journalVoucherMaster, TblBranch _branch, TblVoucherMaster _voucherMaster, TblAccountLedger _accountLedger, decimal?productRate, decimal?ledgerId, string ledgerCode, bool isFromCashDetials = true)
        {
            try
            {
                var _voucherDetail = new TblVoucherDetail();
                var ledgerName     = GetAccountLedgerList().Where(al => al.LedgerCode == ledgerCode).FirstOrDefault();
                _voucherDetail.VoucherMasterId   = _voucherMaster.VoucherMasterId;
                _voucherDetail.VoucherDetailDate = _voucherMaster.VoucherDate;
                _voucherDetail.BranchId          = _branch.BranchId;
                _voucherDetail.BranchCode        = journalVoucherMaster.BranchCode;
                _voucherDetail.BranchName        = journalVoucherMaster.BranchName;
                if (isFromCashDetials == true)
                {
                    _voucherDetail.FromLedgerId    = journalVoucherMaster.FromLedgerId;
                    _voucherDetail.FromLedgerCode  = journalVoucherMaster.FromLedgerCode;
                    _voucherDetail.FromLedgerName  = journalVoucherMaster.FromLedgerName;
                    _voucherDetail.ToLedgerId      = ledgerName.LedgerId;
                    _voucherDetail.ToLedgerCode    = ledgerCode;
                    _voucherDetail.ToLedgerName    = ledgerName.LedgerName;
                    _voucherDetail.Amount          = productRate;
                    _voucherDetail.TransactionType = "Debit";
                    _voucherDetail.CostCenter      = journalVoucherMaster.BranchCode;
                    _voucherDetail.ServerDate      = DateTime.Now;
                    _voucherDetail.Narration       = "Journal Voucher";
                }
                //To ledger  clarifiaction on selecion of product
                else
                {
                    _voucherDetail.FromLedgerId    = ledgerName.LedgerId;
                    _voucherDetail.FromLedgerCode  = ledgerCode;
                    _voucherDetail.FromLedgerName  = ledgerName.LedgerName;
                    _voucherDetail.ToLedgerId      = journalVoucherMaster.FromLedgerId;
                    _voucherDetail.ToLedgerCode    = journalVoucherMaster.FromLedgerCode;
                    _voucherDetail.ToLedgerName    = journalVoucherMaster.FromLedgerName;
                    _voucherDetail.Amount          = productRate;
                    _voucherDetail.TransactionType = "Credit";
                    _voucherDetail.CostCenter      = journalVoucherMaster.BranchCode;
                    _voucherDetail.ServerDate      = DateTime.Now;
                    _voucherDetail.Narration       = "Journal Voucher";
                }

                context.TblVoucherDetail.Add(_voucherDetail);
                if (context.SaveChanges() > 0)
                {
                    return(_voucherDetail);
                }


                return(null);
                // }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #8
0
        public TblVoucherDetail AddVoucherDetails(ERPContext context, TblInvoiceMasterReturn invoiceReturn, TblBranch _branch, TblVoucherMaster _voucherMaster, TblAccountLedger _accountLedger, decimal?productRate, bool isFromInvoiceDetials = true)
        {
            try
            {
                //using(ERPContext context=new ERPContext())
                //{
                var _voucherDetail = new TblVoucherDetail
                {
                    VoucherMasterId   = _voucherMaster.VoucherMasterId,
                    VoucherDetailDate = _voucherMaster.VoucherDate,
                    BranchId          = _branch.BranchId,
                    BranchCode        = invoiceReturn.BranchCode,
                    BranchName        = invoiceReturn.BranchName
                };
                if (isFromInvoiceDetials)
                {
                    _voucherDetail.FromLedgerId   = invoiceReturn.LedgerId;
                    _voucherDetail.FromLedgerCode = invoiceReturn.LedgerCode;
                    _voucherDetail.FromLedgerName = invoiceReturn.LedgerName;
                }
                //To ledger  clarifiaction on selecion of product

                _voucherDetail.ToLedgerId      = _accountLedger.LedgerId;
                _voucherDetail.ToLedgerCode    = _accountLedger.LedgerCode;
                _voucherDetail.ToLedgerName    = _accountLedger.LedgerName;
                _voucherDetail.Amount          = productRate;
                _voucherDetail.TransactionType = _accountLedger.CrOrDr;
                _voucherDetail.CostCenter      = _accountLedger.BranchCode;
                _voucherDetail.ServerDate      = DateTime.Now;
                _voucherDetail.Narration       = $"Sales Invoice {_accountLedger.LedgerName} A /c: {_voucherDetail.TransactionType}";

                context.TblVoucherDetail.Add(_voucherDetail);
                if (context.SaveChanges() > 0)
                {
                    return(_voucherDetail);
                }


                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }