예제 #1
0
        //public abstract IEnumerable<NAS.DAL.Accounting.Journal.Transaction> GetTransactions(Session session);

        //public abstract NAS.DAL.CMS.ObjectDocument.ObjectTypeEnum GetObjectTypeEnum();

        public virtual GeneralJournal CreateGeneralJournal(
            Session session,
            Guid transactionId,
            Guid accountId,
            Side side,
            double amount,
            string description,
            JounalTypeFlag journalType)
        {
            GeneralJournal   ret              = null;
            ObjectBO         objectBO         = new ObjectBO();
            GeneralJournalBO generalJournalBO = new GeneralJournalBO();

            ret = generalJournalBO.CreateGeneralJournal(
                session,
                transactionId,
                accountId,
                side,
                amount,
                description,
                journalType);

            //Create CMS object...
            Guid objectTypeId = ret.TransactionId.TransactionObjects.First().ObjectId.ObjectTypeId.ObjectTypeId;

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

            GeneralJournalObject generalJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = ret,
                ObjectId         = CMSObject
            };

            generalJournalObject.Save();

            if (session is UnitOfWork)
            {
                session.FlushChanges();
            }
            //Copy readonly data from transaction to journal
            //Get transaction object
            NAS.DAL.CMS.ObjectDocument.Object transactionCMSObject
                = session.GetObjectByKey <NAS.DAL.Accounting.Journal.Transaction>(transactionId)
                  .TransactionObjects.First().ObjectId;
            //Get general journal object
            NAS.DAL.CMS.ObjectDocument.Object generalJournalCMSObject =
                ret.GeneralJournalObjects.First().ObjectId;

            objectBO.CopyReadOnlyCustomFieldData(
                transactionCMSObject.ObjectId,
                generalJournalCMSObject.ObjectId);

            return(ret);
        }
예제 #2
0
        public virtual GeneralJournal CreateGeneralJournal(
            Session session,
            Guid transactionId,
            Guid accountId,
            Side side,
            double amount,
            string description,
            JounalTypeFlag journalType)
        {
            GeneralJournalBO generalJournalBO = new GeneralJournalBO();

            return(generalJournalBO.CreateGeneralJournal(
                       session,
                       transactionId,
                       accountId,
                       side,
                       amount,
                       description,
                       journalType));
        }
예제 #3
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();
                }
            }
        }
예제 #4
0
        public Guid CreateTransaction(string code, DateTime issuedDate, double amount, string description)
        {
            UnitOfWork uow             = null;
            Guid       m_TransactionId = Guid.NewGuid();

            try
            {
                GeneralJournalBO generalJournalBO = new GeneralJournalBO();
                uow = XpoHelper.GetNewUnitOfWork();

                //Create new transaction
                ManualBookingTransaction transaction = new ManualBookingTransaction(uow)
                {
                    TransactionId = m_TransactionId,
                    Amount        = amount,
                    Code          = code,
                    CreateDate    = DateTime.Now,
                    Description   = description,
                    IssueDate     = issuedDate,
                    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.MANUAL_BOOKING);

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

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

            return(m_TransactionId);
        }