public static async Task<HeadEntity> CreateVendorDoc(CoreDriver coreDriver, DateTime date)
        {
            HeadEntity headEntity = new HeadEntity(coreDriver,
                    coreDriver.MdMgmt);
            headEntity.setPostingDate(date);
            headEntity.SetDocumentType(DocumentType.VENDOR_INVOICE);
            headEntity.SetDocText(TestData.TEXT_VENDOR_DOC);

            ItemEntity item1 = headEntity.CreateEntity();
            MasterDataIdentity_GLAccount rec_account = new MasterDataIdentity_GLAccount(
                    TestData.GL_ACCOUNT_CASH);
            item1.SetVendor(new MasterDataIdentity(TestData.VENDOR_BUS),
                    rec_account);
            item1.SetAmount(CreditDebitIndicator.CREDIT, TestData.AMOUNT_VENDOR);

            ItemEntity item2 = headEntity.CreateEntity();
            item2.SetGLAccount(new MasterDataIdentity_GLAccount(
                    TestData.GL_ACCOUNT_COST));
            item2.SetAmount(CreditDebitIndicator.DEBIT, TestData.AMOUNT_VENDOR);
            item2.SetBusinessArea(new MasterDataIdentity(
                    TestData.BUSINESS_AREA_WORK));

            try
            {
                await headEntity.SaveAsync(true);
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
            return headEntity;
        }
        public static async Task<HeadEntity> CreateCustomerDoc(CoreDriver coreDriver, DateTime date)
        {
            HeadEntity headEntity = new HeadEntity(coreDriver,
                    coreDriver.MdMgmt);
            headEntity.setPostingDate(date);
            headEntity.SetDocumentType(DocumentType.CUSTOMER_INVOICE);
            headEntity.SetDocText(TestData.TEXT_CUSTOMER_DOC);

            ItemEntity item1 = headEntity.CreateEntity();
            item1.SetGLAccount(new MasterDataIdentity_GLAccount(
                    TestData.GL_ACCOUNT_REV));
            item1.SetAmount(CreditDebitIndicator.CREDIT,
                    TestData.AMOUNT_CUSTOMER);

            ItemEntity item2 = headEntity.CreateEntity();
            MasterDataIdentity_GLAccount account2 = new MasterDataIdentity_GLAccount(
                    TestData.GL_ACCOUNT_BANK);
            item2.SetCustomer(new MasterDataIdentity(TestData.CUSTOMER1),
                    account2);
            item2.SetAmount(CreditDebitIndicator.DEBIT,
                    TestData.AMOUNT_CUSTOMER);

            try
            {
                await headEntity.SaveAsync(true);
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }

            return headEntity;
        }
Пример #3
0
        public static async Task <HeadEntity> CreateGLDoc(CoreDriver coreDriver, DateTime date)
        {
            HeadEntity headEntity = new HeadEntity(coreDriver,
                                                   coreDriver.MdMgmt);

            headEntity.setPostingDate(date);
            headEntity.SetDocumentType(DocumentType.GL);
            headEntity.SetDocText(TestData.TEXT_GL_DOC);

            ItemEntity item1 = headEntity.CreateEntity();

            item1.SetGLAccount(new MasterDataIdentity_GLAccount(
                                   TestData.GL_ACCOUNT_BANK));
            item1.SetAmount(CreditDebitIndicator.CREDIT, TestData.AMOUNT_GL);

            ItemEntity item2 = headEntity.CreateEntity();

            item2.SetGLAccount(new MasterDataIdentity_GLAccount(
                                   TestData.GL_ACCOUNT_CASH));
            item2.SetAmount(CreditDebitIndicator.DEBIT, TestData.AMOUNT_GL);
            try
            {
                await headEntity.SaveAsync(true);
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
            return(headEntity);
        }
Пример #4
0
        public static async Task <HeadEntity> CreateVendorDoc(CoreDriver coreDriver, DateTime date)
        {
            HeadEntity headEntity = new HeadEntity(coreDriver,
                                                   coreDriver.MdMgmt);

            headEntity.setPostingDate(date);
            headEntity.SetDocumentType(DocumentType.VENDOR_INVOICE);
            headEntity.SetDocText(TestData.TEXT_VENDOR_DOC);

            ItemEntity item1 = headEntity.CreateEntity();
            MasterDataIdentity_GLAccount rec_account = new MasterDataIdentity_GLAccount(
                TestData.GL_ACCOUNT_CASH);

            item1.SetVendor(new MasterDataIdentity(TestData.VENDOR_BUS),
                            rec_account);
            item1.SetAmount(CreditDebitIndicator.CREDIT, TestData.AMOUNT_VENDOR);

            ItemEntity item2 = headEntity.CreateEntity();

            item2.SetGLAccount(new MasterDataIdentity_GLAccount(
                                   TestData.GL_ACCOUNT_COST));
            item2.SetAmount(CreditDebitIndicator.DEBIT, TestData.AMOUNT_VENDOR);
            item2.SetBusinessArea(new MasterDataIdentity(
                                      TestData.BUSINESS_AREA_WORK));

            try
            {
                await headEntity.SaveAsync(true);
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
            return(headEntity);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="saved"></param>
        /// <exception cref="MandatoryFieldIsMissing"></exception>
        /// <exception cref="SaveClosedLedgerException"></exception>
        public async Task SaveAsync(bool store)
        {
            if (_isSaved)
            {
                return;
            }

            // check before save
            CheckBeforeSave();

            try
            {
                HeadEntity doc = new HeadEntity(_coreDriver,
                                                _coreDriver.MdMgmt);
                doc.SetDocText(_text);
                doc.SetDocumentType(DocumentType.VENDOR_INVOICE);
                doc.setPostingDate(_date);

                // credit item
                ItemEntity creditItem = doc.CreateEntity();
                creditItem.SetAmount(CreditDebitIndicator.CREDIT, _amount);
                creditItem.SetVendor(_vendor, _recAcc);

                // debit item
                ItemEntity debitItem = doc.CreateEntity();
                debitItem.SetAmount(CreditDebitIndicator.DEBIT, _amount);
                debitItem.SetGLAccount(_glAccount);
                debitItem.SetBusinessArea(_businessArea);


                await doc.SaveAsync(store);


                _isSaved = true;
                _doc     = doc;
            }
            catch (ArgumentNullException e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 123, e.ToString(),
                                         MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (MasterDataIdentityNotDefined e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 123, e.ToString(),
                                         MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (BalanceNotZero)
            {
                _coreDriver.logDebugInfo(this.GetType(), 163,
                                         "Balance is not zero", MessageType.ERRO);
            }
        }
Пример #6
0
        /// <summary>
        /// save document
        /// </summary>
        /// <param name="store"></param>
        /// <exception cref="MandatoryFieldIsMissing"></exception>
        /// <exception cref="SaveClosedLedgerException"></exception>
        public async Task SaveAsync(bool store)
        {
            if (_isSaved)
            {
                return;
            }
            CheckBeforeSave();

            try
            {
                HeadEntity doc = new HeadEntity(_coreDriver,
                                                _coreDriver.MdMgmt);
                doc.SetDocText(_text);
                doc.SetDocumentType(DocumentType.CUSTOMER_INVOICE);
                doc.setPostingDate(_date);

                // credit item
                ItemEntity creditItem = doc.CreateEntity();
                creditItem.SetAmount(CreditDebitIndicator.CREDIT, _amount);
                creditItem.SetGLAccount(_glAccount);

                // debit item
                ItemEntity debitItem = doc.CreateEntity();
                debitItem.SetAmount(CreditDebitIndicator.DEBIT, _amount);
                debitItem.SetCustomer(_customer, _recAcc);

                await doc.SaveAsync(store);


                _isSaved = true;
                _doc     = doc;
            }
            catch (ArgumentNullException e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 267,
                                         "Null value not acceptable.", MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (MasterDataIdentityNotDefined e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 267,
                                         "Master data identity is not defined.", MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (BalanceNotZero e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 267,
                                         "Balance is not zero.", MessageType.ERRO);
                throw new SystemException(e);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="store"></param>
        /// <exception cref="MandatoryFieldIsMissing"></exception>
        /// <exception cref="SaveClosedLedgerException"></exception>
        public async Task SaveAsync(bool store)
        {
            if (_isSaved)
            {
                return;
            }

            CheckBeforeSave();
            try
            {
                HeadEntity head = new HeadEntity(_coreDriver,
                                                 _coreDriver.MdMgmt);
                head.setPostingDate(_pstDate);
                head.SetDocText(_text);
                head.SetDocumentType(DocumentType.GL);

                ItemEntity srcItem = head.CreateEntity();
                srcItem.SetAmount(CreditDebitIndicator.CREDIT, _amount);
                srcItem.SetGLAccount(_srcAccount);

                ItemEntity dstItem = head.CreateEntity();
                dstItem.SetAmount(CreditDebitIndicator.DEBIT, _amount);
                dstItem.SetGLAccount(_dstAccount);


                await head.SaveAsync(store);


                _isSaved = true;
                _doc     = head;
            }
            catch (ArgumentNullException e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 123, e.ToString(),
                                         MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (MasterDataIdentityNotDefined e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 123, e.ToString(),
                                         MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (BalanceNotZero)
            {
                _coreDriver.logDebugInfo(this.GetType(), 163,
                                         "Balance is not zero", MessageType.ERRO);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="saved"></param>
        /// <exception cref="MandatoryFieldIsMissing"></exception>
        /// <exception cref="SaveClosedLedgerException"></exception>
        public async Task SaveAsync(bool store)
        {
            if (_isSaved)
            {
                return;
            }

            // check before save
            CheckBeforeSave();

            try
            {
                HeadEntity doc = new HeadEntity(_coreDriver,
                        _coreDriver.MdMgmt);
                doc.SetDocText(_text);
                doc.SetDocumentType(DocumentType.VENDOR_INVOICE);
                doc.setPostingDate(_date);

                // credit item
                ItemEntity creditItem = doc.CreateEntity();
                creditItem.SetAmount(CreditDebitIndicator.CREDIT, _amount);
                creditItem.SetVendor(_vendor, _recAcc);

                // debit item
                ItemEntity debitItem = doc.CreateEntity();
                debitItem.SetAmount(CreditDebitIndicator.DEBIT, _amount);
                debitItem.SetGLAccount(_glAccount);
                debitItem.SetBusinessArea(_businessArea);


                await doc.SaveAsync(store);


                _isSaved = true;
                _doc = doc;

            }
            catch (ArgumentNullException e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 123, e.ToString(),
                        MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (MasterDataIdentityNotDefined e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 123, e.ToString(),
                        MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (BalanceNotZero)
            {
                _coreDriver.logDebugInfo(this.GetType(), 163,
                        "Balance is not zero", MessageType.ERRO);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="store"></param>
        /// <exception cref="MandatoryFieldIsMissing"></exception>
        /// <exception cref="SaveClosedLedgerException"></exception>
        public async Task SaveAsync(bool store)
        {
            if (_isSaved)
            {
                return;
            }

            CheckBeforeSave();
            try
            {
                HeadEntity head = new HeadEntity(_coreDriver,
                        _coreDriver.MdMgmt);
                head.setPostingDate(_pstDate);
                head.SetDocText(_text);
                head.SetDocumentType(DocumentType.GL);

                ItemEntity srcItem = head.CreateEntity();
                srcItem.SetAmount(CreditDebitIndicator.CREDIT, _amount);
                srcItem.SetGLAccount(_srcAccount);

                ItemEntity dstItem = head.CreateEntity();
                dstItem.SetAmount(CreditDebitIndicator.DEBIT, _amount);
                dstItem.SetGLAccount(_dstAccount);


                await head.SaveAsync(store);


                _isSaved = true;
                _doc = head;

            }
            catch (ArgumentNullException e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 123, e.ToString(),
                        MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (MasterDataIdentityNotDefined e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 123, e.ToString(),
                        MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (BalanceNotZero)
            {
                _coreDriver.logDebugInfo(this.GetType(), 163,
                        "Balance is not zero", MessageType.ERRO);
            }

        }
        /// <summary>
        /// save document
        /// </summary>
        /// <param name="store"></param>
        /// <exception cref="MandatoryFieldIsMissing"></exception>
        /// <exception cref="SaveClosedLedgerException"></exception>
        public async Task SaveAsync(bool store)
        {
            if (_isSaved)
            {
                return;
            }
            CheckBeforeSave();

            try
            {
                HeadEntity doc = new HeadEntity(_coreDriver,
                        _coreDriver.MdMgmt);
                doc.SetDocText(_text);
                doc.SetDocumentType(DocumentType.CUSTOMER_INVOICE);
                doc.setPostingDate(_date);

                // credit item
                ItemEntity creditItem = doc.CreateEntity();
                creditItem.SetAmount(CreditDebitIndicator.CREDIT, _amount);
                creditItem.SetGLAccount(_glAccount);

                // debit item
                ItemEntity debitItem = doc.CreateEntity();
                debitItem.SetAmount(CreditDebitIndicator.DEBIT, _amount);
                debitItem.SetCustomer(_customer, _recAcc);

                await doc.SaveAsync(store);


                _isSaved = true;
                _doc = doc;

            }
            catch (ArgumentNullException e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 267,
                        "Null value not acceptable.", MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (MasterDataIdentityNotDefined e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 267,
                        "Master data identity is not defined.", MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (BalanceNotZero e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 267,
                        "Balance is not zero.", MessageType.ERRO);
                throw new SystemException(e);
            }
        }