示例#1
0
        public TblVoucherDetail AddVoucherDetails(ERPContext context, TblCashPaymentMaster cashPaymentMaster, 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        = cashPaymentMaster.BranchCode;
                _voucherDetail.BranchName        = cashPaymentMaster.BranchName;

                if (isFromCashDetials == true)
                {
                    _voucherDetail.FromLedgerId    = cashPaymentMaster.FromLedgerId;
                    _voucherDetail.FromLedgerCode  = cashPaymentMaster.FromLedgerCode;
                    _voucherDetail.FromLedgerName  = cashPaymentMaster.FromLedgerName;
                    _voucherDetail.ToLedgerId      = ledgerId;
                    _voucherDetail.ToLedgerCode    = ledgerCode;
                    _voucherDetail.ToLedgerName    = ledgerName.LedgerName;
                    _voucherDetail.Amount          = productRate;
                    _voucherDetail.TransactionType = "Debit";
                    _voucherDetail.CostCenter      = _branch.BranchCode;
                    _voucherDetail.ServerDate      = DateTime.Now;
                    _voucherDetail.Narration       = "Cash Payment";
                }
                else
                {
                    _voucherDetail.FromLedgerId    = ledgerId;
                    _voucherDetail.FromLedgerCode  = ledgerCode;
                    _voucherDetail.FromLedgerName  = ledgerName.LedgerName;
                    _voucherDetail.ToLedgerId      = cashPaymentMaster.FromLedgerId;
                    _voucherDetail.ToLedgerCode    = cashPaymentMaster.FromLedgerCode;
                    _voucherDetail.ToLedgerName    = cashPaymentMaster.FromLedgerName;
                    _voucherDetail.Amount          = productRate;
                    _voucherDetail.TransactionType = "Credit";
                    _voucherDetail.CostCenter      = _branch.BranchCode;
                    _voucherDetail.ServerDate      = DateTime.Now;
                    _voucherDetail.Narration       = "Cash Payment";
                }


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


                return(null);
                // }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
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;
            }
        }
示例#3
0
        private TblAccountLedgerTransactions AddAccountLedgerTransactions(ERPContext context, TblVoucherDetail _voucherDetail, DateTime?invoiceDate)
        {
            try
            {
                //using(ERPContext context=new ERPContext())
                //{
                var _accountLedgerTransactions = new TblAccountLedgerTransactions();
                _accountLedgerTransactions.VoucherDetailId = _voucherDetail.VoucherDetailId;
                _accountLedgerTransactions.LedgerId        = _voucherDetail.ToLedgerId;
                _accountLedgerTransactions.LedgerCode      = _voucherDetail.ToLedgerCode;
                _accountLedgerTransactions.LedgerName      = _voucherDetail.ToLedgerName;
                _accountLedgerTransactions.BranchId        = _voucherDetail.BranchId;
                _accountLedgerTransactions.BranchCode      = _voucherDetail.BranchCode;
                _accountLedgerTransactions.BranchName      = _voucherDetail.BranchName;
                _accountLedgerTransactions.TransactionDate = invoiceDate;
                _accountLedgerTransactions.TransactionType = _voucherDetail.TransactionType;
                _accountLedgerTransactions.VoucherAmount   = _voucherDetail.Amount;

                if (_accountLedgerTransactions.TransactionType.Equals("dedit", StringComparison.OrdinalIgnoreCase))
                {
                    _accountLedgerTransactions.DebitAmount  = _accountLedgerTransactions.VoucherAmount;
                    _accountLedgerTransactions.CreditAmount = Convert.ToDecimal("0.00");
                }
                else if (_accountLedgerTransactions.TransactionType.Equals("credit", StringComparison.OrdinalIgnoreCase))
                {
                    _accountLedgerTransactions.CreditAmount = _accountLedgerTransactions.VoucherAmount;
                    _accountLedgerTransactions.DebitAmount  = Convert.ToDecimal("0.00");
                }

                context.TblAccountLedgerTransactions.Add(_accountLedgerTransactions);
                if (context.SaveChanges() > 0)
                {
                    return(_accountLedgerTransactions);
                }


                return(null);
                //  }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#4
0
        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 TblAccountLedgerTransactions AddAccountLedgerTransactions(ERPContext context, TblBankReceiptMaster bankReceiptMaster, TblVoucherDetail _voucherDetail, DateTime?invoiceDate, bool isdebit = true)
        {
            try
            {
                var _accountLedgerTransactions = new TblAccountLedgerTransactions
                {
                    BranchId        = _voucherDetail.BranchId,
                    BranchCode      = _voucherDetail.BranchCode,
                    BranchName      = _voucherDetail.BranchName,
                    TransactionDate = invoiceDate,
                    // _accountLedgerTransactions.TransactionType = _voucherDetail.TransactionType;
                    VoucherAmount = _voucherDetail.Amount
                };
                if (isdebit == true)
                {
                    _accountLedgerTransactions.VoucherDetailId = _voucherDetail.VoucherDetailId;
                    _accountLedgerTransactions.LedgerId        = _voucherDetail.ToLedgerId;
                    _accountLedgerTransactions.LedgerCode      = _voucherDetail.ToLedgerCode;
                    _accountLedgerTransactions.LedgerName      = _voucherDetail.ToLedgerName;
                    _accountLedgerTransactions.TransactionType = _voucherDetail.TransactionType;
                    _accountLedgerTransactions.DebitAmount     = _accountLedgerTransactions.VoucherAmount;
                    _accountLedgerTransactions.CreditAmount    = Convert.ToDecimal("0.00");
                }
                else
                {
                    _accountLedgerTransactions.VoucherDetailId = _voucherDetail.VoucherDetailId;
                    _accountLedgerTransactions.LedgerId        = bankReceiptMaster.BankLedgerId;
                    _accountLedgerTransactions.LedgerCode      = bankReceiptMaster.BankLedgerCode;
                    _accountLedgerTransactions.LedgerName      = bankReceiptMaster.BankLedgerName;
                    _accountLedgerTransactions.TransactionType = "Credit";
                    _accountLedgerTransactions.CreditAmount    = _accountLedgerTransactions.VoucherAmount;
                    _accountLedgerTransactions.DebitAmount     = Convert.ToDecimal("0.00");
                }


                context.TblAccountLedgerTransactions.Add(_accountLedgerTransactions);
                if (context.SaveChanges() > 0)
                {
                    return(_accountLedgerTransactions);
                }


                return(null);
                //  }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#6
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;
            }
        }