Exemplo n.º 1
0
        public ETL_Voucher ExtractPaymentVoucher(Session session, Guid VoucherId, bool ExtractTransaction)
        {
            ETL_Voucher result = null;

            try
            {
                PaymentVouches voucher = session.GetObjectByKey <PaymentVouches>(VoucherId);
                if (voucher == null)
                {
                    return(null);
                }
                result           = new ETL_Voucher();
                result.Credit    = (decimal)voucher.SumOfCredit;
                result.Debit     = (decimal)voucher.SumOfDebit;
                result.IssueDate = voucher.IssuedDate;
                result.VoucherId = voucher.VouchesId;
                if (ExtractTransaction)
                {
                    ETLAccountingBO etlAccountingBO = new ETLAccountingBO();
                    result.FinancialTransactionList = new List <Accounting.TempData.ETL_Transaction>();
                    foreach (PaymentVouchesTransaction transaction in voucher.PaymentVouchesTransactions)
                    {
                        ETL_Transaction temp = new ETL_Transaction();
                        temp = etlAccountingBO.ExtractTransaction(session, transaction.TransactionId);
                        result.FinancialTransactionList.Add(temp);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(result);
        }
Exemplo n.º 2
0
        public static void UpdateSumOfCredit(Guid paymentVouchesId)
        {
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                PaymentVouches paymentVouches =
                    session.GetObjectByKey <PaymentVouches>(paymentVouchesId);
                double sumOfCredit = 0;
                foreach (var item in paymentVouches.VouchesAmounts)
                {
                    sumOfCredit += item.Credit * item.ExchangeRate;
                }
                paymentVouches.SumOfCredit = sumOfCredit;
                paymentVouches.Save();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Exemplo n.º 3
0
        private void formlayoutVoucherAmount_DataBind()
        {
            CriteriaOperator criteria = new BinaryOperator("VouchesId!Key", VoucherId);

            dsVoucherAmount.Criteria = criteria.ToString();
            formlayoutVoucherAmount.DataBind();

            PaymentVouches paymentVoucher = GetCurrentPaymentVoucher();
            VouchesAmount  vouchesAmount  = paymentVoucher.VouchesAmounts.FirstOrDefault();

            if (vouchesAmount != null)
            {
                if (vouchesAmount.CurrencyId != null)
                {
                    gridlookupCurrency.SetSelectedCurrencyByKey(vouchesAmount.CurrencyId.CurrencyId);
                }
                else
                {
                    gridlookupCurrency.ResetToDefault();
                }
                //UpdateGUIByCurrency(gridlookupCurrency.GetSelectedCurrency(session));
            }
            else
            {
                gridlookupCurrency.ResetToDefault();
                //UpdateGUIByCurrency(gridlookupCurrency.GetSelectedCurrency(session));
            }
        }
Exemplo n.º 4
0
        public bool PaymentVoucherCreating_CRUD()
        {
            ClearForm();
            //Create temp voucher
            PaymentVouches paymentVouches = paymentVouchesBO.CreateNewObject(session);

            //Update VoucherId
            VoucherId         = paymentVouches.VouchesId;
            txtIssueDate.Date = DateTime.Now;

            //Get default code
            ArtifactCodeRuleBO artifactCodeRuleBO = new ArtifactCodeRuleBO();

            txtCode.Text = artifactCodeRuleBO.GetArtifactCodeOfArtifactType(ArtifactTypeEnum.VOUCHER_PAYMENT);

            //Link to the bill
            if (BillId != Guid.Empty)
            {
                //Link bill to voucher
                LinkVoucherWithBill(session, BillId, paymentVouches);
                //Fill bill data into voucher
                FillBillDataIntoVoucher(session, BillId);
            }

            //Get default currency...
            gridlookupCurrency.ResetToDefault();
            spinExchangeRate.Number = 1;
            UpdateGUIByCurrency(gridlookupCurrency.GetSelectedCurrency(session));

            //Bind data to VoucherAllocation gridview
            gridviewVoucherAllocation_DataBind();
            return(true);
        }
Exemplo n.º 5
0
        protected void gridviewReceiptVoucherAllocation_InitNewRowWithDefaultDataEvent(Controls.GridViewVoucherAllocation.GridViewVoucherAllocation.TransactionInitRowData data)
        {
            if (VoucherId != null && !VoucherId.Equals(Guid.Empty))
            {
                data.IssuedDate  = txtIssueDate.Date;
                data.Description = txtDescription.Text;

                PaymentVouches voucher  = session.GetObjectByKey <PaymentVouches>(VoucherId);
                int            sequence = 0;
                sequence =
                    voucher.PaymentVouchesTransactions.Count(r => r.RowStatus == Constant.ROWSTATUS_ACTIVE) + 1;
                data.Code = String.Format("{0}_{1}", txtCode.Text, sequence);

                double amount = 0;
                if (voucher.SumOfCredit != 0)
                {
                    amount = voucher.SumOfCredit - voucher.PaymentVouchesTransactions.Sum(r => r.Amount);
                    if (amount < 0)
                    {
                        amount = 0;
                    }
                }
                else
                {
                    amount = (double)spinAmount.Number - voucher.PaymentVouchesTransactions.Sum(r => r.Amount);
                    if (amount < 0)
                    {
                        amount = 0;
                    }
                }
                data.Amount = amount;
            }
        }
Exemplo n.º 6
0
        public override bool CanBookEntries(Guid voucherId)
        {
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                //Get voucher
                PaymentVouches voucher = session.GetObjectByKey <PaymentVouches>(voucherId);
                if (voucher == null)
                {
                    throw new Exception("Could not found voucher");
                }
                TransactionBOBase transactionBOBase = new TransactionBOBase();
                foreach (var transaction in voucher.PaymentVouchesTransactions)
                {
                    if (transactionBOBase.CanBookingEntry(transaction.TransactionId, true) != CanBookingEntryReturnValue.BALANCED)
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Exemplo n.º 7
0
        public static void Insert(Guid tempPaymentVouchesId,
                                  string code,
                                  DateTime issuedDate,
                                  string description,
                                  string address,
                                  string payee,
                                  short rowStatus,
                                  Guid sourceOrganizationId,
                                  Guid targetOrganizationId,
                                  Guid vouchesTypeId)
        {
            UnitOfWork uow = null;

            try
            {
                uow = XpoHelper.GetNewUnitOfWork();
                //Update temp data
                PaymentVouches newPaymentVouches =
                    uow.GetObjectByKey <PaymentVouches>(tempPaymentVouchesId);
                newPaymentVouches.Code                 = code;
                newPaymentVouches.IssuedDate           = issuedDate;
                newPaymentVouches.Description          = description;
                newPaymentVouches.Address              = address;
                newPaymentVouches.RowStatus            = rowStatus;
                newPaymentVouches.SourceOrganizationId =
                    uow.GetObjectByKey <Organization>(sourceOrganizationId);
                newPaymentVouches.TargetOrganizationId =
                    uow.GetObjectByKey <Organization>(targetOrganizationId);
                newPaymentVouches.VouchesTypeId =
                    uow.GetObjectByKey <VouchesType>(vouchesTypeId);
                newPaymentVouches.Payee      = payee;
                newPaymentVouches.CreateDate = DateTime.Now;

                //Missing logic here...
                uow.CommitTransaction();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (uow != null)
                {
                    uow.Dispose();
                }
            }
        }
Exemplo n.º 8
0
        public bool PaymentVoucherLocked_CRUD()
        {
            ClearFormValidation();
            //Bind data to voucher information form
            formlayoutReceiptVoucherEditingForm_DataBind();
            //Bind data to voucher ammount form
            formlayoutVoucherAmount_DataBind();
            //Bind data to VoucherAllocation gridview
            gridviewVoucherAllocation_DataBind();

            PaymentVouches paymentVoucher = GetCurrentPaymentVoucher();

            txtCode.Text = paymentVoucher.Code;
            //spinAmount.Number = (decimal)receiptVoucher.SumOfDebit;
            return(true);
        }
Exemplo n.º 9
0
        public PaymentVouches CreateNewObject(Session session)
        {
            try
            {
                PaymentVouches paymentVouches = new PaymentVouches(session)
                {
                    VouchesId = Guid.NewGuid(),
                    RowStatus = Utility.Constant.ROWSTATUS_TEMP
                };
                paymentVouches.Save();

                ObjectBO objectBO = new ObjectBO();

                NAS.DAL.CMS.ObjectDocument.Object CMSObject = objectBO.CreateCMSObject(session,
                                                                                       DAL.CMS.ObjectDocument.ObjectTypeEnum.VOUCHER_PAYMENT);

                VoucherObject voucherObject = new VoucherObject(session)
                {
                    ObjectId  = CMSObject,
                    VoucherId = paymentVouches
                };
                voucherObject.Save();

                VoucherCustomType voucherCustomType = new VoucherCustomType(session)
                {
                    VoucherId    = paymentVouches,
                    ObjectTypeId = ObjectType.GetDefault(session, ObjectTypeEnum.VOUCHER_PAYMENT)
                };
                voucherCustomType.Save();

                return(paymentVouches);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
            }
        }
Exemplo n.º 10
0
        public void Update(Guid paymentVouchesId,
                           string code,
                           DateTime issuedDate,
                           string description,
                           string address,
                           string payee,
                           Guid sourceOrganizationId,
                           Guid targetOrganizationId,
                           double credit,
                           Guid currencyId,
                           double exchangeRate)
        {
            UnitOfWork uow = null;

            try
            {
                uow = XpoHelper.GetNewUnitOfWork();
                //Update voucher data
                PaymentVouches paymentVouches =
                    uow.GetObjectByKey <PaymentVouches>(paymentVouchesId);
                paymentVouches.Code                 = code;
                paymentVouches.IssuedDate           = issuedDate;
                paymentVouches.Description          = description;
                paymentVouches.Address              = address;
                paymentVouches.SourceOrganizationId =
                    uow.GetObjectByKey <Organization>(sourceOrganizationId);
                paymentVouches.TargetOrganizationId =
                    uow.GetObjectByKey <Organization>(targetOrganizationId);
                paymentVouches.Payee          = payee;
                paymentVouches.LastUpdateDate = paymentVouches.CreateDate;
                paymentVouches.SumOfCredit    = credit * exchangeRate;
                paymentVouches.SumOfDebit     = 0;

                VouchesAmount voucherAmount = paymentVouches.VouchesAmounts.FirstOrDefault();
                if (voucherAmount == null)
                {
                    throw new Exception("The payment voucher is invalid in inserting");
                }
                //update VoucherAmount data
                voucherAmount.Credit       = credit;
                voucherAmount.Debit        = 0;
                voucherAmount.ExchangeRate = exchangeRate;
                voucherAmount.CurrencyId   = uow.GetObjectByKey <Currency>(currencyId);

                //2014-02-18 ERP-1540 Khoa.Truong INS START
                //Update issue date for all voucher transactions
                if (paymentVouches.PaymentVouchesTransactions != null)
                {
                    foreach (var paymentVouchesTransaction in paymentVouches.PaymentVouchesTransactions)
                    {
                        paymentVouchesTransaction.IssueDate = paymentVouches.IssuedDate;
                        paymentVouchesTransaction.Save();
                    }
                }
                //2014-02-18 ERP-1540 Khoa.Truong INS END

                uow.CommitTransaction();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (uow != null)
                {
                    uow.Dispose();
                }
            }
        }
Exemplo n.º 11
0
        //public void Insert(Guid tempReceiptVouchesId,
        //                            string code,
        //                            DateTime issuedDate,
        //                            string description,
        //                            string address,
        //                            string payer,
        //                            short rowStatus,
        //                            Guid sourceOrganizationId,
        //                            Guid targetOrganizationId,
        //                            Guid vouchesTypeId)
        //{
        //    UnitOfWork uow = null;
        //    try
        //    {
        //        uow = XpoHelper.GetNewUnitOfWork();
        //        //Update temp data
        //        ReceiptVouches newReceiptVouches =
        //            uow.GetObjectByKey<ReceiptVouches>(tempReceiptVouchesId);
        //        newReceiptVouches.Code = code;
        //        newReceiptVouches.IssuedDate = issuedDate;
        //        newReceiptVouches.Description = description;
        //        newReceiptVouches.Address = address;
        //        newReceiptVouches.RowStatus = rowStatus;
        //        newReceiptVouches.SourceOrganizationId =
        //            uow.GetObjectByKey<Organization>(sourceOrganizationId);
        //        newReceiptVouches.TargetOrganizationId =
        //            uow.GetObjectByKey<Organization>(targetOrganizationId);
        //        newReceiptVouches.VouchesTypeId =
        //            uow.GetObjectByKey<VouchesType>(vouchesTypeId);

        //        newReceiptVouches.Payer = payer;

        //        newReceiptVouches.CreateDate = DateTime.Now;
        //        newReceiptVouches.LastUpdateDate = newReceiptVouches.CreateDate;

        //        //Missing logic here...
        //        uow.CommitTransaction();
        //    }
        //    catch (Exception ex)
        //    {
        //        throw;
        //    }
        //    finally
        //    {
        //        if (uow != null) uow.Dispose();
        //    }
        //}
        #endregion

        #region 2013-12-05 Khoa.Truong INS START
        public void Insert(Guid tempPaymentVouchesId,
                           string code,
                           DateTime issuedDate,
                           string description,
                           string address,
                           string payee,
                           Guid sourceOrganizationId,
                           Guid targetOrganizationId,
                           double credit,
                           Guid currencyId,
                           double exchangeRate)
        {
            UnitOfWork uow = null;

            try
            {
                uow = XpoHelper.GetNewUnitOfWork();
                //Update temp data
                PaymentVouches newPaymentVouches =
                    uow.GetObjectByKey <PaymentVouches>(tempPaymentVouchesId);
                newPaymentVouches.Code                 = code;
                newPaymentVouches.IssuedDate           = issuedDate;
                newPaymentVouches.Description          = description;
                newPaymentVouches.Address              = address;
                newPaymentVouches.RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE;
                newPaymentVouches.SourceOrganizationId =
                    uow.GetObjectByKey <Organization>(sourceOrganizationId);
                newPaymentVouches.TargetOrganizationId =
                    uow.GetObjectByKey <Organization>(targetOrganizationId);
                newPaymentVouches.Payee          = payee;
                newPaymentVouches.CreateDate     = DateTime.Now;
                newPaymentVouches.LastUpdateDate = newPaymentVouches.CreateDate;
                newPaymentVouches.SumOfCredit    = credit * exchangeRate;
                newPaymentVouches.SumOfDebit     = 0;

                //Insert data into VoucherAmount table
                NAS.DAL.Vouches.VouchesAmount voucherAmount = new VouchesAmount(uow)
                {
                    Credit       = credit,
                    Debit        = 0,
                    ExchangeRate = exchangeRate,
                    CurrencyId   = uow.GetObjectByKey <Currency>(currencyId),
                    VouchesId    = newPaymentVouches
                };

                //2014-02-18 ERP-1540 Khoa.Truong INS START
                //Update issue date for all voucher transactions
                if (newPaymentVouches.PaymentVouchesTransactions != null)
                {
                    foreach (var paymentVouchesTransaction in newPaymentVouches.PaymentVouchesTransactions)
                    {
                        paymentVouchesTransaction.IssueDate = newPaymentVouches.IssuedDate;
                        paymentVouchesTransaction.Save();
                    }
                }
                //2014-02-18 ERP-1540 Khoa.Truong INS END

                uow.CommitTransaction();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (uow != null)
                {
                    uow.Dispose();
                }
            }
        }
Exemplo n.º 12
0
        protected void popPaymentVoucherEdit_WindowCallback(object source, DevExpress.Web.ASPxPopupControl.PopupWindowCallbackArgs e)
        {
            string[]         args = e.Parameter.Split('|');
            ReceiptVouchesBO bo   = new ReceiptVouchesBO(); //ham dinh nghia ben NAS.BO

            switch (args[0])
            {
            //DND 851
            case "cbo_click":
                if (args.Length > 1)
                {
                    string textAdsress = "";
                    if (args[1].Equals(""))
                    {
                        textAdsress = "";
                    }
                    else
                    {
                        string[] org_code = args[1].ToString().Split('-');
                        org_code[0] = org_code[0].Trim();
                        textAdsress = bo.searchOrgnAdress(session, org_code[0]);
                    }

                    memoAddress.Value = textAdsress;
                    txtPayer.Focus();
                }
                break;

            //END DND 851
            case "new":
                PaymentVouches tempPaymentVouches = PaymentVouches.InitNewRow(session);
                popPaymentVoucherEdit.JSProperties["cpNewRecordId"]           = tempPaymentVouches.VouchesId.ToString();
                PrivateSession.Instance.PaymentVoucherId                      = tempPaymentVouches.VouchesId;
                dsPaymentVoucher.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.PaymentVoucherId.ToString();
                dsVouchersAmount.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.PaymentVoucherId.ToString();
                ClearForm();
                txtCode.Text         = artifactCodeRuleBO.GetArtifactCodeOfArtifactType(ArtifactTypeEnum.VOUCHER_PAYMENT);
                dateIssuedDate.Value = DateTime.Now;    //DND 851
                break;

            case "edit":
                ClearForm();
                if (args.Length > 1)
                {
                    PrivateSession.Instance.PaymentVoucherId = Guid.Parse(args[1]);
                    dsPaymentVoucher.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.PaymentVoucherId.ToString();
                    dsVouchersAmount.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.PaymentVoucherId.ToString();
                    txtCode.Text = CurrentPaymentVouches.Code;
                    //DND
                    if (bo.searchOrgDefault(session, CurrentPaymentVouches.TargetOrganizationId.OrganizationId.ToString()))
                    {
                        popPaymentVoucherEdit.JSProperties.Add("cpIsDefaultSourceOrg", true);
                    }
                    else
                    {
                        popPaymentVoucherEdit.JSProperties.Add("cpIsDefaultSourceOrg", false);
                    }
                    //END DND
                }
                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;
                try
                {
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(frmPaymentVoucher, true))
                    {
                        popPaymentVoucherEdit.JSProperties.Add("cpInvalid", true);
                        return;
                    }

                    //2013-11-18 Khoa.Truong DEL START
                    //DND 851
                    Guid targetOrgId;
                    bo = new ReceiptVouchesBO();     //ham dinh nghia ben NAS.BO
                    string cbVouchesType_name = cbVouchesType.Text;

                    if (cbTargetOrganization.Text == null || cbTargetOrganization.Text.Equals(""))
                    {
                        targetOrgId = Guid.Parse(bo.searchOrganizationId(session));
                    }
                    else
                    {
                        string[] org_code = cbTargetOrganization.Text.ToString().Split('-');
                        org_code[0] = org_code[0].Trim();

                        targetOrgId = Guid.Parse(bo.searchOrgId(session, org_code[0]));
                    }

                    Guid voucherTypeId = Guid.Parse(bo.searchVouchesTypeId(session, cbVouchesType_name));
                    //END DND
                    //2013-11-18 Khoa.Truong DEL START

                    //collect data for saving
                    string   code        = txtCode.Text;
                    DateTime issueDate   = DateTime.Parse(dateIssuedDate.Text);
                    string   description = memoDescription.Text;
                    string   address     = memoAddress.Text;
                    //2013-11-18 Khoa.Truong INS START
                    //Guid voucherTypeId = Guid.Parse(cbVouchesType.SelectedItem.Value.ToString());
                    //Guid targetOrgId = Guid.Parse(cbTargetOrganization.SelectedItem.Value.ToString());
                    //2013-11-18 Khoa.Truong INS END
                    string payee = txtPayer.Text;
                    //Logic to save data
                    if (args.Length > 1)
                    {
                        //Update mode
                        //Update general information
                        recordIdStr = args[1];
                        Guid recordId = Guid.Parse(recordIdStr);
                        PaymentVouchesBO.Update(PrivateSession.Instance.PaymentVoucherId,
                                                code,
                                                issueDate,
                                                description,
                                                address,
                                                payee,
                                                Constant.ROWSTATUS_ACTIVE,
                                                Utility.CurrentSession.Instance.AccessingOrganizationId,
                                                targetOrgId,
                                                voucherTypeId);
                    }
                    else
                    {
                        //Insert mode
                        PaymentVouchesBO.Insert(PrivateSession.Instance.PaymentVoucherId,
                                                code,
                                                issueDate,
                                                description,
                                                address,
                                                payee,
                                                Constant.ROWSTATUS_ACTIVE,
                                                Utility.CurrentSession.Instance.AccessingOrganizationId,
                                                targetOrgId,
                                                voucherTypeId);
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    popPaymentVoucherEdit.JSProperties.Add("cpCallbackArgs",
                                                           String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 13
0
        public override void CreateTransaction(Guid voucherId, string code, DateTime issuedDate, double amount, string description)
        {
            UnitOfWork uow = null;

            try
            {
                GeneralJournalBO generalJournalBO = new GeneralJournalBO();
                uow = XpoHelper.GetNewUnitOfWork();
                //Get the origin artifact
                PaymentVouches paymnetVouches = uow.GetObjectByKey <PaymentVouches>(voucherId);

                //Create new transaction
                PaymentVouchesTransaction transaction = new PaymentVouchesTransaction(uow)
                {
                    TransactionId    = Guid.NewGuid(),
                    Amount           = amount,
                    Code             = code,
                    CreateDate       = DateTime.Now,
                    Description      = description,
                    IssueDate        = issuedDate,
                    PaymentVouchesId = paymnetVouches,
                    RowStatus        = Utility.Constant.ROWSTATUS_ACTIVE,
                    UpdateDate       = DateTime.Now
                };
                uow.FlushChanges();
                //Create double entry
                //Create debit jounal
                GeneralJournal debitGeneralJournal = generalJournalBO.CreateGeneralJournal
                                                     (
                    uow,
                    transaction.TransactionId,
                    Account.GetDefault(uow, DefaultAccountEnum.NAAN_DEFAULT).AccountId,
                    Side.DEBIT,
                    amount,
                    description,
                    JounalTypeFlag.ACTUAL
                                                     );
                //Create credit jounal
                GeneralJournal creditGeneralJournal = generalJournalBO.CreateGeneralJournal
                                                      (
                    uow,
                    transaction.TransactionId,
                    Account.GetDefault(uow, DefaultAccountEnum.NAAN_DEFAULT).AccountId,
                    Side.CREDIT,
                    amount,
                    description,
                    JounalTypeFlag.ACTUAL
                                                      );

                ObjectBO objectBO = new ObjectBO();
                //Create CMS object for transaction
                NAS.DAL.CMS.ObjectDocument.Object transactionCMSObject =
                    objectBO.CreateCMSObject(uow,
                                             DAL.CMS.ObjectDocument.ObjectTypeEnum.VOUCHER_PAYMENT);

                TransactionObject transactionObject = new TransactionObject(uow)
                {
                    ObjectId      = transactionCMSObject,
                    TransactionId = transaction
                };

                GeneralJournalObject debitGeneralJournalObject  = null;
                GeneralJournalObject creditGeneralJournalObject = null;
                //Create CMS object for debit jounal
                NAS.DAL.CMS.ObjectDocument.Object debitJounalCMSObject =
                    objectBO.CreateCMSObject(uow,
                                             DAL.CMS.ObjectDocument.ObjectTypeEnum.VOUCHER_PAYMENT);
                debitGeneralJournalObject = new GeneralJournalObject(uow)
                {
                    GeneralJournalId = debitGeneralJournal,
                    ObjectId         = debitJounalCMSObject
                };

                //Create CMS object for debit jounal
                NAS.DAL.CMS.ObjectDocument.Object creditJounalCMSObject =
                    objectBO.CreateCMSObject(uow,
                                             DAL.CMS.ObjectDocument.ObjectTypeEnum.VOUCHER_PAYMENT);
                creditGeneralJournalObject = new GeneralJournalObject(uow)
                {
                    GeneralJournalId = creditGeneralJournal,
                    ObjectId         = creditJounalCMSObject
                };

                uow.FlushChanges();

                //Copy readonly data from original artifact
                //Get origin CMS object
                VoucherObject voucherObject = paymnetVouches.VoucherObjects.FirstOrDefault();
                if (voucherObject != null)
                {
                    NAS.DAL.CMS.ObjectDocument.Object CMSVoucherObject = voucherObject.ObjectId;
                    //Copy artifact's data to cms object of transaction
                    objectBO.CopyReadOnlyCustomFieldData(
                        CMSVoucherObject.ObjectId,
                        transactionCMSObject.ObjectId);
                    //Copy artifact's data to cms object of default general journals
                    objectBO.CopyReadOnlyCustomFieldData(
                        CMSVoucherObject.ObjectId,
                        debitJounalCMSObject.ObjectId);

                    objectBO.CopyReadOnlyCustomFieldData(
                        CMSVoucherObject.ObjectId,
                        creditJounalCMSObject.ObjectId);
                }

                uow.CommitChanges();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (uow != null)
                {
                    uow.Dispose();
                }
            }
        }