protected void gridviewReceiptVoucherAllocation_InitNewRowWithDefaultDataEvent(Controls.GridViewVoucherAllocation.GridViewVoucherAllocation.TransactionInitRowData data)
        {
            if (VoucherId != null && !VoucherId.Equals(Guid.Empty))
            {
                data.IssuedDate  = txtIssueDate.Date;
                data.Description = txtDescription.Text;

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

                double amount = 0;
                if (voucher.SumOfDebit != 0)
                {
                    amount = voucher.SumOfCredit - voucher.ReceiptVouchesTransactions.Sum(r => r.Amount);
                    if (amount < 0)
                    {
                        amount = 0;
                    }
                }
                else
                {
                    amount = (double)spinAmount.Number - voucher.ReceiptVouchesTransactions.Sum(r => r.Amount);
                    if (amount < 0)
                    {
                        amount = 0;
                    }
                }
                data.Amount = amount;
            }
        }
Beispiel #2
0
        public ETL_Voucher ExtractReceiptVoucher(Session session, Guid VoucherId, bool ExtractTransaction)
        {
            ETL_Voucher result = null;

            try
            {
                ReceiptVouches voucher = session.GetObjectByKey <ReceiptVouches>(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 (ReceiptVouchesTransaction transaction in voucher.ReceiptVouchesTransactions)
                    {
                        ETL_Transaction temp = new ETL_Transaction();
                        temp = etlAccountingBO.ExtractTransaction(session, transaction.TransactionId);
                        result.FinancialTransactionList.Add(temp);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(result);
        }
Beispiel #3
0
        public static void UpdateSumOfDebit(Guid receiptVouchesId)
        {
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                ReceiptVouches receiptVouches =
                    session.GetObjectByKey <ReceiptVouches>(receiptVouchesId);
                double sumOfDebit = 0;
                foreach (var item in receiptVouches.VouchesAmounts)
                {
                    sumOfDebit += item.Debit * item.ExchangeRate;
                }
                receiptVouches.SumOfDebit = sumOfDebit;
                receiptVouches.Save();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
        private void formlayoutVoucherAmount_DataBind()
        {
            CriteriaOperator criteria = new BinaryOperator("VouchesId!Key", VoucherId);

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

            ReceiptVouches receiptVouches = GetCurrentReceiptVoucher();
            VouchesAmount  vouchesAmount  = receiptVouches.VouchesAmounts.FirstOrDefault();

            if (vouchesAmount != null)
            {
                if (vouchesAmount.CurrencyId != null)
                {
                    gridlookupCurrency.SetSelectedCurrencyByKey(vouchesAmount.CurrencyId.CurrencyId);
                }
                else
                {
                    gridlookupCurrency.ResetToDefault();
                }
            }
            else
            {
                gridlookupCurrency.ResetToDefault();
            }
        }
        public bool ReceiptVoucherCreating_CRUD()
        {
            ClearForm();
            //Create temp voucher
            ReceiptVouches receiptVouches = receiptVouchesBO.CreateNewObject(session);

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

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

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

            //Link to the bill
            if (BillId != Guid.Empty)
            {
                //Link bill to voucher
                LinkVoucherWithBill(session, BillId, receiptVouches);
                //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);
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ReceiptVouches voucher =
                session.GetObjectByKey <ReceiptVouches>(Guid.Parse("C5E3DCD2-F8F1-4D5D-9531-B29548B9D699"));

            GridViewBookingEntries1.SetDataSource(voucher.ReceiptVouchesTransactions);
            GridViewBookingEntries2.SetDataSource(voucher.ReceiptVouchesTransactions);
        }
Beispiel #7
0
        /*2013-12-05 Khoa.Truong DEL START
         * Changes to non static method
         * //public static 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();
         * //    }
         * //}
         * 2013-12-05 Khoa.Truong DEL END*/

        #region 2013-12-05 Khoa.Truong INS START
        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();
                }
            }
        }
        public bool ReceiptVoucherLocked_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();

            ReceiptVouches receiptVoucher = GetCurrentReceiptVoucher();

            txtCode.Text = receiptVoucher.Code;
            //spinAmount.Number = (decimal)receiptVoucher.SumOfDebit;
            return(true);
        }
Beispiel #9
0
        public override bool CanBookEntries(Guid voucherId)
        {
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                //Get voucher
                ReceiptVouches voucher = session.GetObjectByKey <ReceiptVouches>(voucherId);
                if (voucher == null)
                {
                    throw new Exception("Could not found voucher");
                }
                TransactionBOBase transactionBOBase = new TransactionBOBase();
                foreach (var transaction in voucher.ReceiptVouchesTransactions)
                {
                    if (transaction.RowStatus < 1)
                    {
                        continue;
                    }
                    if (transactionBOBase.CanBookingEntry(transaction.TransactionId, true)
                        != CanBookingEntryReturnValue.BALANCED)
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Beispiel #10
0
        public ReceiptVouches CreateNewObject(Session session)
        {
            try
            {
                ReceiptVouches receiptVouches = new ReceiptVouches(session)
                {
                    VouchesId = Guid.NewGuid(),
                    RowStatus = Utility.Constant.ROWSTATUS_TEMP
                };
                receiptVouches.Save();

                ObjectBO objectBO = new ObjectBO();

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

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

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

                return(receiptVouches);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
            }
        }
Beispiel #11
0
        protected void popReceiptVouchesEdit_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":
                ReceiptVouches tempReceiptVouches = ReceiptVouches.InitNewRow(session);
                popReceiptVouchesEdit.JSProperties["cpNewRecordId"]           = tempReceiptVouches.VouchesId.ToString();
                PrivateSession.Instance.ReceiptVoucherId                      = tempReceiptVouches.VouchesId;
                dsReceiptVouches.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                dsVouchersAmount.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                this.InvisibleCommandColumnGridviewIfApprovedCosting(grdVouchersAmount, "CommonOperations");
                ClearForm();
                txtCode.Text = artifactCodeRuleBO.GetArtifactCodeOfArtifactType(ArtifactTypeEnum.VOUCHER_RECEIPT);
                //DND 851
                dateIssuedDate.Value = DateTime.Now;


                //END DND
                break;

            case "edit":
                ClearForm();
                if (args.Length > 1)
                {
                    PrivateSession.Instance.ReceiptVoucherId = Guid.Parse(args[1]);
                    dsReceiptVouches.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                    dsVouchersAmount.CriteriaParameters["VouchesId"].DefaultValue = PrivateSession.Instance.ReceiptVoucherId.ToString();
                    txtCode.Text = CurrentReceiptVouches.Code;
                    this.InvisibleCommandColumnGridviewIfApprovedCosting(grdVouchersAmount, "CommonOperations");
                    //DND
                    if (bo.searchOrgDefault(session, CurrentReceiptVouches.SourceOrganizationId.OrganizationId.ToString()))
                    {
                        popReceiptVouchesEdit.JSProperties.Add("cpIsDefaultSourceOrg", true);
                    }
                    else
                    {
                        popReceiptVouchesEdit.JSProperties.Add("cpIsDefaultSourceOrg", false);
                    }
                    //END DND
                }
                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;

                try
                {
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(frmReceiptVouches, true))
                    {
                        popReceiptVouchesEdit.JSProperties.Add("cpInvalid", true);
                        return;
                    }

                    //collect data for saving
                    string   code      = txtCode.Text;
                    DateTime issueDate = new DateTime();
                    if (!DateTime.TryParse(dateIssuedDate.Text, out issueDate))
                    {
                        issueDate = DateTime.Now;
                    }

                    string description = memoDescription.Text;
                    string address     = memoAddress.Text;
                    //2013-11-18 Khoa.Truong INS START
                    //Guid voucherTypeId = Guid.Parse(cbVouchesType.SelectedItem.Value.ToString());
                    //Guid sourceOrgId = Guid.Parse(cbSourceOrganization.SelectedItem.Value.ToString());
                    //2013-11-18 Khoa.Truong INS END

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


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

                        org_code[0] = org_code[0].Trim();

                        sourceOrgId = Guid.Parse(bo.searchOrgId(session, org_code[0]));
                    }
                    Guid voucherTypeId = Guid.Parse(bo.searchVouchesTypeId(session, cbVouchesType_name));
                    ////END DND
                    //2013-11-18 Khong.Truong DEL END

                    string payer = txtPayer.Text;
                    //Logic to save data

                    if (args.Length > 1)
                    {
                        //Update mode
                        //Update general information
                        recordIdStr = args[1];
                        Guid             recordId         = Guid.Parse(recordIdStr);
                        ReceiptVouchesBO receiptVouchesBO = new ReceiptVouchesBO();
                        receiptVouchesBO.Update(PrivateSession.Instance.ReceiptVoucherId,
                                                code,
                                                issueDate,
                                                description,
                                                address,
                                                payer,
                                                Constant.ROWSTATUS_ACTIVE,
                                                sourceOrgId,
                                                Utility.CurrentSession.Instance.AccessingOrganizationId,
                                                voucherTypeId);
                    }
                    else
                    {
                        //Insert mode
                        ReceiptVouchesBO receiptVouchesBO = new ReceiptVouchesBO();
                        receiptVouchesBO.Insert(PrivateSession.Instance.ReceiptVoucherId,
                                                code,
                                                issueDate,
                                                description,
                                                address,
                                                payer,
                                                Constant.ROWSTATUS_ACTIVE,
                                                sourceOrgId,
                                                Utility.CurrentSession.Instance.AccessingOrganizationId,
                                                voucherTypeId);
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    popReceiptVouchesEdit.JSProperties.Add("cpCallbackArgs",
                                                           String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));
                }
                break;

            default:
                break;
            }
        }
Beispiel #12
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
                ReceiptVouches receiptVouches = uow.GetObjectByKey <ReceiptVouches>(voucherId);

                //Create new transaction
                ReceiptVouchesTransaction transaction = new ReceiptVouchesTransaction(uow)
                {
                    TransactionId    = Guid.NewGuid(),
                    Amount           = amount,
                    Code             = code,
                    CreateDate       = DateTime.Now,
                    Description      = description,
                    IssueDate        = issuedDate,
                    ReceiptVouchesId = receiptVouches,
                    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_RECEIPT);

                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_RECEIPT);
                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_RECEIPT);
                creditGeneralJournalObject = new GeneralJournalObject(uow)
                {
                    GeneralJournalId = creditGeneralJournal,
                    ObjectId         = creditJounalCMSObject
                };

                uow.FlushChanges();

                //Copy readonly data from original artifact
                //Get origin CMS object
                VoucherObject voucherObject = receiptVouches.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();
                }
            }
        }
Beispiel #13
0
        public void Update(Guid receiptVouchesId,
                           string code,
                           DateTime issuedDate,
                           string description,
                           string address,
                           string payer,
                           Guid sourceOrganizationId,
                           Guid targetOrganizationId,
                           double debit,
                           Guid currencyId,
                           double exchangeRate)
        {
            UnitOfWork uow = null;

            try
            {
                uow = XpoHelper.GetNewUnitOfWork();
                //Update voucher data
                ReceiptVouches receiptVouches =
                    uow.GetObjectByKey <ReceiptVouches>(receiptVouchesId);
                receiptVouches.Code                 = code;
                receiptVouches.IssuedDate           = issuedDate;
                receiptVouches.Description          = description;
                receiptVouches.Address              = address;
                receiptVouches.SourceOrganizationId =
                    uow.GetObjectByKey <Organization>(sourceOrganizationId);
                receiptVouches.TargetOrganizationId =
                    uow.GetObjectByKey <Organization>(targetOrganizationId);
                receiptVouches.Payer          = payer;
                receiptVouches.LastUpdateDate = receiptVouches.CreateDate;
                receiptVouches.SumOfCredit    = 0;
                receiptVouches.SumOfDebit     = debit * exchangeRate;

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

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

                uow.CommitTransaction();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (uow != null)
                {
                    uow.Dispose();
                }
            }
        }
Beispiel #14
0
        public void Insert(Guid tempReceiptVouchesId,
                           string code,
                           DateTime issuedDate,
                           string description,
                           string address,
                           string payer,
                           Guid sourceOrganizationId,
                           Guid targetOrganizationId,
                           double debit,
                           Guid currencyId,
                           double exchangeRate)
        {
            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            = Utility.Constant.ROWSTATUS_ACTIVE;
                newReceiptVouches.SourceOrganizationId =
                    uow.GetObjectByKey <Organization>(sourceOrganizationId);
                newReceiptVouches.TargetOrganizationId =
                    uow.GetObjectByKey <Organization>(targetOrganizationId);
                newReceiptVouches.Payer          = payer;
                newReceiptVouches.CreateDate     = DateTime.Now;
                newReceiptVouches.LastUpdateDate = newReceiptVouches.CreateDate;
                newReceiptVouches.SumOfCredit    = 0;
                newReceiptVouches.SumOfDebit     = debit * exchangeRate;

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

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

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