Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
        public TblAccountLedgerTransactions AddAccountLedgerTransactions(ERPContext context, TblVoucherDetail _voucherDetail, DateTime?invoiceDate)
        {
            try
            {
                //using(ERPContext context=new ERPContext())
                //{
                var _accountLedgerTransactions = new TblAccountLedgerTransactions
                {
                    VoucherDetailId = _voucherDetail.VoucherDetailId,
                    LedgerId        = _voucherDetail.ToLedgerId,
                    LedgerCode      = _voucherDetail.ToLedgerCode,
                    LedgerName      = _voucherDetail.ToLedgerName,
                    BranchId        = _voucherDetail.BranchId,
                    BranchCode      = _voucherDetail.BranchCode,
                    BranchName      = _voucherDetail.BranchName,
                    TransactionDate = invoiceDate,
                    TransactionType = _voucherDetail.TransactionType,
                    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;
            }
        }