Example #1
0
        /// <summary>
        /// check value
        /// </summary>
        /// <param name="name"></param>
        /// <param name="obj"></param>
        /// <exception cref="NoFieldNameException"></exception>
        /// <exception cref="NotInValueRangeException"></exception>
        private void checkValueVendorEntry(String name, Object obj)
        {
            VendorEntry           entry = new VendorEntry(_coreDriver, _mdMgmt);
            List <MasterDataBase> datas = entry.GetValueSet(name);

            foreach (MasterDataBase data in datas)
            {
                if (data.Identity.Equals(obj))
                {
                    return;
                }
            }

            throw new NotInValueRangeException(name, obj);
        }
Example #2
0
        /// <summary>
        /// parse to vendor entry
        /// </summary>
        /// <param name="head"></param>
        /// <returns>return null if parse error</returns>
        public static VendorEntry Parse(HeadEntity head)
        {
            // check
            if (head.DocType != DocumentType.VENDOR_INVOICE)
            {
                return(null);
            }
            List <ItemEntity> items = head.Items;

            if (items.Count != 2)
            {
                return(null);
            }
            // credit item
            ItemEntity creditItem = items[0];

            if (creditItem.AccType != AccountType.VENDOR)
            {
                return(null);
            }
            ItemEntity debitItem = items[1];

            if (debitItem.AccType != AccountType.GL_ACCOUNT)
            {
                return(null);
            }

            VendorEntry entry = new VendorEntry(head._coreDriver, head._coreDriver.MdMgmt);

            entry._recAcc       = creditItem.GLAccount;
            entry._vendor       = creditItem.Vendor;
            entry._glAccount    = debitItem.GLAccount;
            entry._businessArea = debitItem.BusinessArea;

            entry._date   = head.PstDate;
            entry._amount = creditItem.Amount;
            if (creditItem.CdIndicator == CreditDebitIndicator.DEBIT)
            {
                // reverse
                entry._amount.Negate();
            }
            entry._text    = head.DocText;
            entry._isSaved = true;
            entry._doc     = head;

            return(entry);
        }
Example #3
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 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);
        }
        /// <summary>
        /// parse to vendor entry
        /// </summary>
        /// <param name="head"></param>
        /// <returns>return null if parse error</returns>
        public static VendorEntry Parse(HeadEntity head)
        {
            // check
            if (head.DocType != DocumentType.VENDOR_INVOICE)
            {
                return null;
            }
            List<ItemEntity> items = head.Items;
            if (items.Count != 2)
            {
                return null;
            }
            // credit item
            ItemEntity creditItem = items[0];
            if (creditItem.AccType != AccountType.VENDOR)
            {
                return null;
            }
            ItemEntity debitItem = items[1];
            if (debitItem.AccType != AccountType.GL_ACCOUNT)
            {
                return null;
            }

            VendorEntry entry = new VendorEntry(head._coreDriver, head._coreDriver.MdMgmt);
            entry._recAcc = creditItem.GLAccount;
            entry._vendor = creditItem.Vendor;
            entry._glAccount = debitItem.GLAccount;
            entry._businessArea = debitItem.BusinessArea;

            entry._date = head.PstDate;
            entry._amount = creditItem.Amount;
            if (creditItem.CdIndicator == CreditDebitIndicator.DEBIT)
            {
                // reverse
                entry._amount.Negate();
            }
            entry._text = head.DocText;
            entry._isSaved = true;
            entry._doc = head;

            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);
        }