示例#1
0
        public static string SaveTransfer(CashBankTransferVm currVm)
        {
            string result = "true";
            //create cash In object


            CashInVm cashIn = new CashInVm();

            cashIn.CashType      = "cashin";
            cashIn.CreateBy      = CurrentUserId;
            cashIn.CreateDate    = DateTime.Now;
            cashIn.CurrencyId    = currVm.CurrentCurrencyId;
            cashIn.Notes         = currVm.Notes;
            cashIn.PaymentTermId = currVm.IsCashToBank ? (byte)PaymentTermEnum.CashToBank : (byte)PaymentTermEnum.BankToCash;
            cashIn.ReceiptAmount = currVm.CurrentAmount;
            cashIn.ReceiptDate   = DateTime.Now;

            var bankAcc = BankHelper.GetBankAccountInfo(currVm.BankAccId);

            cashIn.BankId    = bankAcc.BankId;
            cashIn.BankAccId = bankAcc.BankAccId;

            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    int cashInReceiptId, cashOutReceiptId;
                    CashHelper.AddEditCashReceipt(cashIn, out cashInReceiptId, false);
                    cashIn.CashType      = "cashout";
                    cashIn.CurrencyId    = currVm.CurrentCurrencyId;
                    cashIn.ReceiptAmount = currVm.CurrentAmount;
                    cashIn.ReceiptId     = 0;
                    cashIn.ReceiptCode   = "";
                    cashIn.BankId        = null;
                    cashIn.BankAccId     = null;
                    CashOutHelper.AddEditCashReceipt(cashIn, out cashOutReceiptId, false);

                    AddReceiptToTransTableTransfer(currVm, cashInReceiptId, cashOutReceiptId);

                    transaction.Complete();
                }
                catch (DbEntityValidationException e)
                {
                    result = "false " + e.Message;
                }
                catch (Exception e)
                {
                    result = "false " + e.Message;
                }
            }


            return(result);
        }
示例#2
0
        /// <summary>
        /// Add Bank Account to The Accounting chart
        /// </summary>
        /// <param name="bankId">Bank Id .. optional .. if 0 .. will get it in code</param>
        /// <param name="bankAccountId">Bank Account Id</param>
        /// <returns>The Accounting chart Account Number</returns>
        public static string AddBankAccountToChart(int bankId, int bankAccountId)
        {
            string debitAccId;
            string parentAccountId = ((int)AccountingChartEnum.CashInBanks).ToString();

            if (bankId == 0)
            {
                AccountingEntities db = new AccountingEntities();
                bankId = db.BankAccounts.Where(x => x.BankAccId == bankAccountId).FirstOrDefault().BankId;
            }

            BankVm        bankInfo    = BankHelper.GetBankInfo(bankId);
            BankAccountVm bankAccount = bankInfo.BankAccounts.Where(x => x.BankAccId == bankAccountId).FirstOrDefault();
            string        accNameEn   = bankAccount.AccountName + " (" + bankAccount.AccountNumber + ")";

            //Add new accountId to the chart
            debitAccId = AccountingChartHelper
                         .AddAccountToChart(accNameEn, accNameEn, parentAccountId);

            AccountingChartHelper.AddAccountIdToObj(debitAccId, "BankAccount", bankAccountId, "BankAccId");

            return(debitAccId);
        }