public override NAS.DAL.Accounting.Journal.GeneralJournal CreateGeneralJournal(DevExpress.Xpo.Session session, Guid transactionId, Guid accountId, NAS.BO.Accounting.Journal.Side side, double amount, string description, NAS.BO.Accounting.Journal.JounalTypeFlag journalType)
        {
            GeneralJournal generalJournal =
                base.CreateGeneralJournal(session,
                                          transactionId,
                                          accountId,
                                          side,
                                          amount,
                                          description,
                                          journalType);
            //Create CMS object...

            ObjectBO objectBO = new ObjectBO();

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

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

            generalJournalObject.Save();

            return(generalJournal);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        protected void Unnamed1_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            ItemBO itemBO = new ItemBO();
            int    cnt    = 0;

            using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
            {
                try
                {
                    XPCollection <NAS.DAL.Nomenclature.Item.Item> items = new XPCollection <NAS.DAL.Nomenclature.Item.Item>(uow, new BinaryOperator("RowStatus", 0, BinaryOperatorType.Greater));
                    foreach (NAS.DAL.Nomenclature.Item.Item i in items)
                    {
                        ObjectBO objectBO = new ObjectBO();
                        Item     item     = uow.GetObjectByKey <Item>(i.ItemId);
                        if (item == null)
                        {
                            throw new Exception("The key is not exist in Item");
                        }

                        List <NAS.DAL.CMS.ObjectDocument.ObjectType> typeList = null;

                        if (item.ItemCustomTypes != null)
                        {
                            typeList = item.ItemCustomTypes.Select(r => r.ObjectTypeId).ToList();
                        }

                        if (typeList != null)
                        {
                            foreach (NAS.DAL.CMS.ObjectDocument.ObjectType type in typeList)
                            {
                                if (!itemBO.checkAlreadyHasObjectWithObjectType(uow, i.ItemId, type.ObjectTypeId))
                                {
                                    NAS.DAL.CMS.ObjectDocument.Object o = objectBO.CreateCMSObject(uow, type.ObjectTypeId);
                                    ItemObject it = new ItemObject(uow);
                                    it.ObjectId = o;
                                    it.ItemId   = item;
                                }
                            }
                        }

                        uow.FlushChanges();
                        cnt++;
                    }
                    lblnum.Text = cnt.ToString();

                    ////Get MANUFACTURER object type
                    //NAS.DAL.CMS.ObjectDocument.ObjectType objectType = Util.getXPCollection<NAS.DAL.CMS.ObjectDocument.ObjectType>(uow, "Name", "MANUFACTURER").FirstOrDefault();
                    //XPCollection<NAS.DAL.Nomenclature.Organization.ManufacturerOrg> manufacturers = new XPCollection<NAS.DAL.Nomenclature.Organization.ManufacturerOrg>(uow);
                    //manufacturers.Criteria = new UnaryOperator(UnaryOperatorType.IsNull, "ObjectId");
                    //foreach (var manufacturer in manufacturers)
                    //{
                    //    //Create new CMS object
                    //    NAS.DAL.CMS.ObjectDocument.Object CMSObject = new NAS.DAL.CMS.ObjectDocument.Object(uow)
                    //    {
                    //        ObjectId = Guid.NewGuid(),
                    //        ObjectTypeId = objectType
                    //    };
                    //    CMSObject.Save();
                    //    manufacturer.ObjectTypeId = objectType;
                    //    manufacturer.ObjectId = CMSObject;
                    //    manufacturer.Save();
                    //}
                    uow.CommitChanges();
                }
                catch
                {
                    throw;
                }
            }
        }
Esempio n. 4
0
        protected override void CloneBillTransaction(Session session, Guid billId, ref Bill ret)
        {
            SaleInvoiceTransactionBO invoiceTransactionBO = new SaleInvoiceTransactionBO();
            var      transactions = invoiceTransactionBO.GetTransactions(session, billId);
            ObjectBO objectBO     = new ObjectBO();

            foreach (var invoiceTransaction in transactions)
            {
                SaleInvoiceTransaction sourceSaleInvoiceTransaction =
                    (SaleInvoiceTransaction)invoiceTransaction;
                SaleInvoiceTransaction saleInvoiceTransaction = new SaleInvoiceTransaction(session)
                {
                    Amount         = sourceSaleInvoiceTransaction.Amount,
                    Code           = String.Format("BT_{0}", ret.Code),
                    CreateDate     = DateTime.Now,
                    Description    = String.Format("BT_{0}", ret.Code),
                    IssueDate      = sourceSaleInvoiceTransaction.IssueDate,
                    SalesInvoiceId = (NAS.DAL.Invoice.SalesInvoice)ret,
                    RowStatus      = Utility.Constant.ROWSTATUS_ACTIVE,
                    UpdateDate     = DateTime.Now
                };
                saleInvoiceTransaction.Save();
                //Create CMS Object for Transaction
                NAS.DAL.CMS.ObjectDocument.Object transactionCMSObject =
                    objectBO.CreateCMSObject(session, DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
                TransactionObject transactionObject = new TransactionObject(session)
                {
                    ObjectId      = transactionCMSObject,
                    TransactionId = saleInvoiceTransaction
                };
                transactionObject.Save();
                //Clone GeneralJournal
                var generalJournals = sourceSaleInvoiceTransaction.GeneralJournals
                                      .Where(r => r.RowStatus >= Utility.Constant.ROWSTATUS_ACTIVE);
                foreach (var sourceGeneralJournal in generalJournals)
                {
                    GeneralJournal generalJournal = new GeneralJournal(session)
                    {
                        AccountId     = sourceGeneralJournal.AccountId,
                        CreateDate    = DateTime.Now,
                        Credit        = sourceGeneralJournal.Credit,
                        CurrencyId    = sourceGeneralJournal.CurrencyId,
                        Debit         = sourceGeneralJournal.Debit,
                        Description   = sourceGeneralJournal.Description,
                        JournalType   = sourceGeneralJournal.JournalType,
                        RowStatus     = Utility.Constant.ROWSTATUS_ACTIVE,
                        TransactionId = saleInvoiceTransaction
                    };
                    generalJournal.Save();
                    //Create CMS object for GeneralJournal
                    NAS.DAL.CMS.ObjectDocument.Object generalJournalCMSObject =
                        objectBO.CreateCMSObject(session, DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
                    GeneralJournalObject generalJournalObject = new GeneralJournalObject(session)
                    {
                        GeneralJournalId = generalJournal,
                        ObjectId         = generalJournalCMSObject
                    };
                    generalJournalObject.Save();
                }
            }
        }
Esempio n. 5
0
        public override bool Save(
            DevExpress.Xpo.Session session,
            Guid billId,
            string billCode,
            DateTime issuedDate,
            DAL.Nomenclature.Organization.Organization sourceOrganizationBill,
            DAL.Nomenclature.Organization.Person targetOrganizationBill)
        {
            try
            {
                //Get bill by ID
                NAS.DAL.Invoice.SalesInvoice bill =
                    session.GetObjectByKey <NAS.DAL.Invoice.SalesInvoice>(billId);
                if (bill == null)
                {
                    throw new Exception("Could not found bill");
                }

                bill.Code                 = billCode;
                bill.IssuedDate           = issuedDate;
                bill.SourceOrganizationId = sourceOrganizationBill;
                bill.TargetOrganizationId = targetOrganizationBill;
                bill.RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE;

                bill.Save();

                //Create default actual transaction
                CriteriaOperator criteria = CriteriaOperator.And(
                    new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual),
                    CriteriaOperator.Or(
                        new ContainsOperator("GeneralJournals",
                                             new BinaryOperator("JournalType", JounalTypeConstant.ACTUAL)
                                             ),
                        new BinaryOperator(new AggregateOperand("GeneralJournals", Aggregate.Count), 0, BinaryOperatorType.Equal)
                        )
                    );

                var actualSaleInvoiceTransactions = bill.SaleInvoiceTransactions;

                actualSaleInvoiceTransactions.Criteria = criteria;

                if (actualSaleInvoiceTransactions == null ||
                    actualSaleInvoiceTransactions.Count == 0)
                {
                    SaleInvoiceTransaction saleInvoiceTransaction
                        = new SaleInvoiceTransaction(session)
                        {
                        Code           = "BT_" + bill.Code,
                        CreateDate     = DateTime.Now,
                        Description    = "BT_" + bill.Code,
                        IssueDate      = issuedDate,
                        RowStatus      = Utility.Constant.ROWSTATUS_ACTIVE,
                        UpdateDate     = DateTime.Now,
                        SalesInvoiceId = bill
                        };
                    saleInvoiceTransaction.Save();

                    ObjectBO objectBO = new ObjectBO();
                    NAS.DAL.CMS.ObjectDocument.Object cmsObject =
                        objectBO.CreateCMSObject(session, DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);

                    TransactionObject transactionObject = new TransactionObject(session)
                    {
                        ObjectId      = cmsObject,
                        TransactionId = saleInvoiceTransaction
                    };

                    transactionObject.Save();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 6
0
File: CMSBO.cs Progetto: ewin66/dev
        public List <object> GetFullObjectCustomFieldList(NAS.DAL.CMS.ObjectDocument.Object newobject)
        {
            List <object> result = new List <object>();

            return(result);
        }
Esempio n. 7
0
File: CMSBO.cs Progetto: ewin66/dev
 //ObjectCustomField
 public void InitObjectCustomField(Session session, NAS.DAL.CMS.ObjectDocument.Object newobject, NAS.DAL.CMS.ObjectDocument.ObjectType objectType)
 {
 }
Esempio n. 8
0
File: CMSBO.cs Progetto: ewin66/dev
 //Obbject Type
 //Obbject
 public void CreateObject(Session session, NAS.DAL.CMS.ObjectDocument.ObjectType objectType)
 {
     NAS.DAL.CMS.ObjectDocument.Object newobject = new NAS.DAL.CMS.ObjectDocument.Object(session);
     InitObjectCustomField(session, newobject, objectType);
 }
Esempio n. 9
0
        public void BillTransactionInit(Session session,
                                        Guid BillId,
                                        double TotalAmount,
                                        double DiscountAmount,
                                        double TaxAmount,
                                        double ItemAmount
                                        )
        {
            CriteriaOperator filter  = new BinaryOperator("Code", DefaultAccountEnum.NAAN_DEFAULT.ToString(), BinaryOperatorType.Equal);
            Account          account = session.FindObject <Account>(filter);

            PurchaseInvoiceTransaction saleInvoiceTransaction = new PurchaseInvoiceTransaction(session);

            saleInvoiceTransaction.TransactionId = Guid.NewGuid();
            saleInvoiceTransaction.CreateDate    = saleInvoiceTransaction.IssueDate = DateTime.Now;
            saleInvoiceTransaction.Amount        = TotalAmount;
            saleInvoiceTransaction.RowStatus     = 0;

            saleInvoiceTransaction.Save();

            ObjectBO objectBO = new ObjectBO();

            NAS.DAL.CMS.ObjectDocument.Object transactionCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);

            TransactionObject transactionObject = new TransactionObject(session)
            {
                ObjectId      = transactionCMSObject,
                TransactionId = saleInvoiceTransaction
            };

            transactionObject.Save();

            // total
            GeneralJournal generalJournal = new GeneralJournal(session);

            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = session.GetObjectByKey <Transaction>(saleInvoiceTransaction.TransactionId);
            generalJournal.RowStatus        = 0;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Debit     = TotalAmount;
            generalJournal.Save();

            GeneralJournalObject debitGeneralJournalObject = null;

            NAS.DAL.CMS.ObjectDocument.Object debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();

            // Discount
            generalJournal = new GeneralJournal(session);
            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = session.GetObjectByKey <Transaction>(saleInvoiceTransaction.TransactionId);
            generalJournal.RowStatus        = 0;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Credit    = DiscountAmount;
            generalJournal.Save();

            debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();

            // Tax

            generalJournal = new GeneralJournal(session);
            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = session.GetObjectByKey <Transaction>(saleInvoiceTransaction.TransactionId);
            generalJournal.RowStatus        = 0;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Credit    = DiscountAmount;
            generalJournal.Save();

            debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();

            // Item
            generalJournal = new GeneralJournal(session);
            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = session.GetObjectByKey <Transaction>(saleInvoiceTransaction.TransactionId);
            generalJournal.RowStatus        = 0;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Credit    = ItemAmount;
            generalJournal.Save();

            debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();
        }
Esempio n. 10
0
        public void objectCustomFieldItems()
        {
            CustomFieldObjects = itemBO.getAllCustomFieldObjects(session, ItemId);
            if (CustomFieldObjects == null || CustomFieldObjects.Count == 0)
            {
                //TittleProductCustomFieldGrid.Visible =
                NASProductCustomFieldDataGridView.Visible                          =
                    TittleToolCustomFieldGrid.Visible                              =
                        NASToolCustomFieldDataGridView.Visible                     =
                            TittleServiceCustomFieldGrid.Visible                   =
                                NASServiceCustomFieldDataGridView.Visible          =
                                    TittleMaterialCustomFieldGrid.Visible          =
                                        NASMaterialCustomFieldDataGridView.Visible = false;
                TittleProductCustomFieldGrid.Text    = "Để sử dụng chức năng cấu hình động vui lòng cập nhật phân loại đối tượng ở Tab-Thông tin chung";
                TittleProductCustomFieldGrid.Visible = true;
                return;
            }
            else
            {
                TittleProductCustomFieldGrid.Text = "Cấu hình thuộc tính cho hàng hóa";
            }

            NAS.DAL.CMS.ObjectDocument.Object product        = null;
            NAS.DAL.CMS.ObjectDocument.Object tool           = null;
            NAS.DAL.CMS.ObjectDocument.Object service        = null;
            NAS.DAL.CMS.ObjectDocument.Object material       = null;
            NAS.DAL.CMS.ObjectDocument.Object seflProduction = null;
            NAS.DAL.CMS.ObjectDocument.Object fixedAssest    = null;
            bool flgProduct        = false;
            bool flgTool           = false;
            bool flgService        = false;
            bool flgMaterial       = false;
            bool flgSelfProduction = false;
            bool flgFixedAssest    = false;

            foreach (NAS.DAL.CMS.ObjectDocument.Object o in CustomFieldObjects)
            {
                if (o.ObjectTypeId.Name.Equals("PRODUCT"))
                {
                    product    = o;
                    flgProduct = true;
                }

                if (o.ObjectTypeId.Name.Equals("TOOL"))
                {
                    flgTool = true;
                    tool    = o;
                }

                if (o.ObjectTypeId.Name.Equals("SERVICE"))
                {
                    service    = o;
                    flgService = true;
                }

                if (o.ObjectTypeId.Name.Equals("MATERIAL"))
                {
                    material    = o;
                    flgMaterial = true;
                }

                if (o.ObjectTypeId.Name.Equals("FIXED_ASSETS"))
                {
                    fixedAssest    = o;
                    flgFixedAssest = true;
                }

                if (o.ObjectTypeId.Name.Equals("SELF_PRODUCTION"))
                {
                    seflProduction    = o;
                    flgSelfProduction = true;
                }
            }

            if (flgProduct)
            {
                NASProductCustomFieldDataGridView.CMSObjectId = product.ObjectId;
                NASProductCustomFieldDataGridView.DataBind();
            }

            TittleProductCustomFieldGrid.Visible      = flgProduct;
            NASProductCustomFieldDataGridView.Visible = flgProduct;

            if (flgTool)
            {
                NASToolCustomFieldDataGridView.CMSObjectId = tool.ObjectId;
                NASToolCustomFieldDataGridView.DataBind();
            }
            TittleToolCustomFieldGrid.Visible      = flgTool;
            NASToolCustomFieldDataGridView.Visible = flgTool;


            if (flgService)
            {
                NASServiceCustomFieldDataGridView.CMSObjectId = service.ObjectId;
                NASServiceCustomFieldDataGridView.DataBind();
            }
            TittleServiceCustomFieldGrid.Visible      = flgService;
            NASServiceCustomFieldDataGridView.Visible = flgService;

            if (flgMaterial)
            {
                NASMaterialCustomFieldDataGridView.CMSObjectId = material.ObjectId;
                NASMaterialCustomFieldDataGridView.DataBind();
            }

            TittleMaterialCustomFieldGrid.Visible      = flgMaterial;
            NASMaterialCustomFieldDataGridView.Visible = flgMaterial;

            if (flgFixedAssest)
            {
                NASFixedAssestCustomFieldDataGridView.CMSObjectId = fixedAssest.ObjectId;
                NASFixedAssestCustomFieldDataGridView.DataBind();
            }

            TittleFixedAssestCustomFieldGrid.Visible      = flgFixedAssest;
            NASFixedAssestCustomFieldDataGridView.Visible = flgFixedAssest;

            if (flgSelfProduction)
            {
                NASSelfProductionCustomFieldDataGridView.CMSObjectId = seflProduction.ObjectId;
                NASSelfProductionCustomFieldDataGridView.DataBind();
            }

            TittleSelfProductionCustomFieldGrid.Visible      = flgSelfProduction;
            NASSelfProductionCustomFieldDataGridView.Visible = flgSelfProduction;
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        public void BillTransactionInit(Session session,
                                        Guid BillId,
                                        double TotalAmount,
                                        double DiscountAmount,
                                        double TaxAmount,
                                        double ItemAmount
                                        )
        {
            CriteriaOperator filter = new GroupOperator(GroupOperatorType.And,
                                                        new BinaryOperator("Code", "", BinaryOperatorType.Equal),
                                                        //new BinaryOperator("SalesInvoiceId", BillId, BinaryOperatorType.Equal),
                                                        new BinaryOperator("SalesInvoiceId", BillId, BinaryOperatorType.Equal));

            SaleInvoiceTransaction saleInvoiceTransaction = session.FindObject <SaleInvoiceTransaction>(filter);

            if (saleInvoiceTransaction != null)
            {
                filter = new BinaryOperator("TransactionId", saleInvoiceTransaction.TransactionId, BinaryOperatorType.Equal);
                TransactionObject transactionO = session.FindObject <TransactionObject>(filter);

                if (transactionO != null)
                {
                    transactionO.Delete();
                    transactionO.Save();
                }

                filter = new BinaryOperator("GeneralJournalId.TransactionId", saleInvoiceTransaction.TransactionId, BinaryOperatorType.Equal);
                XPCollection <GeneralJournalObject> collectGeneralJournalObject = new XPCollection <GeneralJournalObject>(session, filter);

                if (collectGeneralJournalObject.Count > 0)
                {
                    session.Delete(collectGeneralJournalObject);
                    session.Save(collectGeneralJournalObject);
                }

                filter = new BinaryOperator("TransactionId", saleInvoiceTransaction.TransactionId, BinaryOperatorType.Equal);
                XPCollection <GeneralJournal> collectGeneralJournal = new XPCollection <GeneralJournal>(session, filter);
                if (collectGeneralJournal.Count > 0)
                {
                    session.Delete(collectGeneralJournal);
                    session.Save(collectGeneralJournal);
                }

                Transaction transaction = session.GetObjectByKey <Transaction>(saleInvoiceTransaction.TransactionId);
                if (transaction != null)
                {
                    transaction.Delete();
                    transaction.Save();
                }

                saleInvoiceTransaction.Delete();
                saleInvoiceTransaction.Save();
            }



            saleInvoiceTransaction = new SaleInvoiceTransaction(session);

            saleInvoiceTransaction.Code           = "";
            saleInvoiceTransaction.TransactionId  = Guid.NewGuid();
            saleInvoiceTransaction.CreateDate     = saleInvoiceTransaction.IssueDate = DateTime.Now;
            saleInvoiceTransaction.Amount         = TotalAmount;
            saleInvoiceTransaction.RowStatus      = Utility.Constant.ROWSTATUS_ACTIVE;
            saleInvoiceTransaction.SalesInvoiceId = session.GetObjectByKey <SalesInvoice>(BillId);

            saleInvoiceTransaction.Save();

            ObjectBO objectBO = new ObjectBO();

            NAS.DAL.CMS.ObjectDocument.Object transactionCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);

            TransactionObject transactionObject = new TransactionObject(session)
            {
                ObjectId      = transactionCMSObject,
                TransactionId = saleInvoiceTransaction
            };

            transactionObject.Save();

            filter = new BinaryOperator("Code", DefaultAccountEnum.NAAN_DEFAULT.ToString(), BinaryOperatorType.Equal);
            Account account = session.FindObject <Account>(filter);

            // total
            GeneralJournal generalJournal = new GeneralJournal(session);

            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = saleInvoiceTransaction;
            generalJournal.RowStatus        = Utility.Constant.ROWSTATUS_ACTIVE;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Debit     = TotalAmount;
            generalJournal.Save();

            GeneralJournalObject debitGeneralJournalObject = null;

            NAS.DAL.CMS.ObjectDocument.Object debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();

            // Discount
            generalJournal = new GeneralJournal(session);
            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = saleInvoiceTransaction;
            generalJournal.RowStatus        = Utility.Constant.ROWSTATUS_ACTIVE;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Credit    = DiscountAmount;
            generalJournal.Save();

            debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();

            // Tax

            generalJournal = new GeneralJournal(session);
            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = saleInvoiceTransaction;
            generalJournal.RowStatus        = Utility.Constant.ROWSTATUS_ACTIVE;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Credit    = TaxAmount;
            generalJournal.Save();

            debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();

            // Item
            generalJournal = new GeneralJournal(session);
            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = session.GetObjectByKey <Transaction>(saleInvoiceTransaction.TransactionId);
            generalJournal.RowStatus        = Utility.Constant.ROWSTATUS_ACTIVE;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Credit    = ItemAmount;
            generalJournal.Save();

            debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();
        }