public async static Task CreateTemplate(CoreDriver coreDriver,
            EntryTemplatesManagement tempMgmt)
        {
            // vendor
            VendorEntry vendorEntry = new VendorEntry(coreDriver, coreDriver.MdMgmt);
            vendorEntry.SetValue(EntryTemplate.AMOUNT, TestData.AMOUNT_VENDOR);
            vendorEntry.SetValue(VendorEntry.VENDOR, new MasterDataIdentity(
                    TestData.VENDOR_BUS));
            vendorEntry.SetValue(EntryTemplate.TEXT, TestData.TEXT_VENDOR_DOC);
            vendorEntry.SetValue(VendorEntry.REC_ACC,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_CASH));
            vendorEntry.SetValue(VendorEntry.GL_ACCOUNT,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_COST));
            vendorEntry.SetValue(VendorEntry.BUSINESS_AREA, new MasterDataIdentity(
                    TestData.BUSINESS_AREA_WORK));
            await tempMgmt.SaveAsTemplate(vendorEntry, TestData.TEXT_VENDOR_DOC);

            // GL
            GLAccountEntry glEntry = new GLAccountEntry(coreDriver, coreDriver.MdMgmt);
            glEntry.SetValue(EntryTemplate.TEXT, TestData.TEXT_GL_DOC);
            glEntry.SetValue(GLAccountEntry.SRC_ACCOUNT,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_BANK));
            glEntry.SetValue(GLAccountEntry.DST_ACCOUNT,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_CASH));
            await tempMgmt.SaveAsTemplate(glEntry, TestData.TEXT_GL_DOC);

            // customer
            CustomerEntry customerEntry = new CustomerEntry(coreDriver, coreDriver.MdMgmt);
            customerEntry.SetValue(EntryTemplate.TEXT, TestData.TEXT_CUSTOMER_DOC);
            customerEntry.SetValue(CustomerEntry.CUSTOMER, new MasterDataIdentity(
                    TestData.CUSTOMER1));
            customerEntry.SetValue(CustomerEntry.REC_ACC,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_BANK));
            customerEntry.SetValue(CustomerEntry.GL_ACCOUNT,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_REV));
            await tempMgmt.SaveAsTemplate(customerEntry, TestData.TEXT_CUSTOMER_DOC);
        }
Example #2
0
        /// <summary>
        /// generate document entry with this template
        /// </summary>
        /// <returns></returns>
        /// <exception cref="SystemException"></exception>
        public IDocumentEntry GenerateEntry()
        {
            IDocumentEntry entry;

            switch (_entryType)
            {
            case EntryType.GLEntry:
                entry = new GLAccountEntry(_coreDriver, _mdMgmt);
                break;

            case EntryType.VendorEntry:
                entry = new VendorEntry(_coreDriver, _mdMgmt);
                break;

            case EntryType.CustomerEntry:
                entry = new CustomerEntry(_coreDriver, _mdMgmt);
                break;

            default:
                return(null);
            }
            foreach (var item in _defaultValues)
            {
                try
                {
                    entry.SetValue(item.Key, item.Value);
                }
                catch (NoFieldNameException e)
                {
                    _coreDriver.logDebugInfo(this.GetType(), 72, e.Message,
                                             MessageType.ERRO);
                    throw new SystemException(e);
                }
                catch (NotInValueRangeException e)
                {
                    _coreDriver.logDebugInfo(this.GetType(), 72, e.Message,
                                             MessageType.ERRO);
                    throw new SystemException(e);
                }
            }
            return(entry);
        }
        public async Task TestCreateTransDataWithEntry()
        {
            Assert.IsTrue(_coreDriver.IsInitialize);
            MasterDataCreater.CreateMasterData(_coreDriver);

            // month 08, reverse document
            DateTime date = DateTime.Parse("2012.07.02");
            // ledger
            VendorEntry vendorEntry = new VendorEntry(_coreDriver, _coreDriver.MdMgmt);
            vendorEntry.SetValue(EntryTemplate.POSTING_DATE, date);
            vendorEntry.SetValue(EntryTemplate.TEXT, TestData.TEXT_VENDOR_DOC);
            vendorEntry.SetValue(VendorEntry.VENDOR, new MasterDataIdentity(
                    TestData.VENDOR_BUS));
            vendorEntry.SetValue(VendorEntry.REC_ACC,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_CASH));
            vendorEntry.SetValue(VendorEntry.GL_ACCOUNT,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_COST));
            vendorEntry.SetValue(VendorEntry.BUSINESS_AREA, new MasterDataIdentity(
                    TestData.BUSINESS_AREA_WORK));
            vendorEntry.SetValue(EntryTemplate.AMOUNT, TestData.AMOUNT_VENDOR);
            await vendorEntry.SaveAsync(true);

            // customer
            CustomerEntry customerEntry = new CustomerEntry(_coreDriver, _coreDriver.MdMgmt);
            customerEntry.SetValue(EntryTemplate.POSTING_DATE, date);
            customerEntry.SetValue(EntryTemplate.TEXT, TestData.TEXT_CUSTOMER_DOC);
            customerEntry.SetValue(CustomerEntry.CUSTOMER, new MasterDataIdentity(
                    TestData.CUSTOMER1));
            customerEntry.SetValue(CustomerEntry.REC_ACC,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_BANK));
            customerEntry.SetValue(CustomerEntry.GL_ACCOUNT,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_REV));
            customerEntry.SetValue(EntryTemplate.AMOUNT, TestData.AMOUNT_CUSTOMER);
            await customerEntry.SaveAsync(true);

            // GL
            GLAccountEntry glAccEntry = new GLAccountEntry(_coreDriver, _coreDriver.MdMgmt);
            glAccEntry.SetValue(EntryTemplate.POSTING_DATE, date);
            glAccEntry.SetValue(EntryTemplate.TEXT, TestData.TEXT_GL_DOC);
            glAccEntry.SetValue(GLAccountEntry.SRC_ACCOUNT,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_BANK));
            glAccEntry.SetValue(GLAccountEntry.DST_ACCOUNT,
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_CASH));
            glAccEntry.SetValue(EntryTemplate.AMOUNT, TestData.AMOUNT_GL);
            await glAccEntry.SaveAsync(true);

            TransactionDataManagement transManagement = _coreDriver.TransMgmt;

            date = DateTime.Parse("2012.08.02");
            HeadEntity headEntity = await DocumentCreater.CreateVendorDoc(_coreDriver,
                    date);
            DocumentIdentity docId = headEntity.DocIdentity;
            transManagement.ReverseDocument(docId);

            // check
            TransactionDataChecker.CheckTransactionData(_coreDriver);

            // reload
            await _coreDriver.RestartAsync();
            TransactionDataChecker.CheckTransactionData(_coreDriver);
        }