/// <summary> /// /// constructor /// </summary> /// <param name="coreDriver"></param> public GLAccountEntry(CoreDriver coreDriver , MasterDataManagement mdMgmt) { _coreDriver = coreDriver; _mdMgmt = mdMgmt; _isSaved = false; }
/// <summary> /// Get group balance from start month to end month /// </summary> /// <param name="accountGroup"></param> /// <param name="startMonthId"></param> /// <param name="endMonthId"></param> /// <returns></returns> /// <exception cref="SystemException"></exception> public CurrencyAmount GetGroupBalance(GLAccountGroupENUM accountGroup, MonthIdentity startMonthId, MonthIdentity endMonthId) { CurrencyAmount ret = new CurrencyAmount(); MasterDataManagement mdMgmt = this._mdMgmt; foreach (var item in _items) { GLAccountMasterData glAccount; try { glAccount = (GLAccountMasterData)mdMgmt .GetMasterData(item.Key, MasterDataType.GL_ACCOUNT); } catch (Exception e) { _coreDriver.logDebugInfo(this.GetType(), 183, e.Message, MessageType.ERRO); throw new SystemException(e); } if (glAccount.Group.Identity == accountGroup) { ret.AddTo(item.Value.GetSumAmount(startMonthId, endMonthId)); } } return(ret); }
/// <summary> /// construct /// </summary> /// <param name="coreDriver"></param> /// <param name="mdMgmt"></param> public TransactionDataManagement(CoreDriver coreDriver, MasterDataManagement mdMgmt) : base(coreDriver) { _masterDataMgmt = mdMgmt; _list = new Dictionary <MonthIdentity, MonthLedger>(); _glAccBalCol = new GLAccountBalanceCollection(_coreDriver, _masterDataMgmt); }
public ReportsManagement(CoreDriver coreDriver, MasterDataManagement mdMgmt) : base(coreDriver) { _mdMgmt = mdMgmt; indexes = new DocumentIndex[DocumentIndex.INDEX_COUNT]; indexes[DocumentIndex.ACCOUNT_INDEX] = new DocumentAccountIndex( _coreDriver, mdMgmt); indexes[DocumentIndex.BUSINESS_INDEX] = new DocumentBusinessIndex( _coreDriver, mdMgmt); }
/// <summary> /// Construcotr /// </summary> /// <param name="coreDriver"></param> /// <param name="entryType"></param> /// <param name="id"></param> /// <param name="name"></param> internal EntryTemplate(CoreDriver coreDriver, MasterDataManagement mdMgmt , EntryType entryType, int id, String name) { _coreDriver = coreDriver; _mdMgmt = mdMgmt; _defaultValues = new Dictionary <String, Object>(); _entryType = entryType; _id = id; _name = name; }
/// <summary> /// document index /// </summary> /// <param name="coreDriver"></param> /// <param name="mdMgmt"></param> protected DocumentIndex(CoreDriver coreDriver, MasterDataManagement mdMgmt) { _coreDriver = coreDriver; _mdMgmt = mdMgmt; _list = new Dictionary <MasterDataIdentity, DocumentIndexItem>(); _coreDriver.ListenerMgmt.DocumentSavedHandler += documentSaved; _coreDriver.ListenerMgmt.DocumentLoadHandler += documentLoad; _coreDriver.ListenerMgmt.DocumentReversedHandler += documentReversed; }
/// <summary> /// Constructor /// </summary> /// <param name="coreDriver"></param> /// <param name="management"></param> public HeadEntity(CoreDriver coreDriver, MasterDataManagement management) { _coreDriver = coreDriver; _management = management; _items = new List <ItemEntity>(); _fields = new Dictionary <String, String>(); _postingDate = DateTime.Today; _docText = String.Empty; _isReversed = false; _isSaved = false; }
public VendorEntry(CoreDriver coreDriver, MasterDataManagement mdMgmt) { _coreDriver = coreDriver; _mdMgmt = mdMgmt; _text = ""; _recAcc = null; _glAccount = null; _vendor = null; _amount = new CurrencyAmount(); _businessArea = null; _doc = null; }
internal GLAccountBalanceCollection(CoreDriver coreDriver, MasterDataManagement mdMgmt) { _coreDriver = coreDriver; _mdMgmt = mdMgmt; _items = new Dictionary <MasterDataIdentity_GLAccount, GLAccountBalanceItem>(); _coreDriver.ListenerMgmt.DocumentSavedHandler += documentSaved; _coreDriver.ListenerMgmt.DocumentLoadHandler += documentLoad; _coreDriver.ListenerMgmt.MasterDataLoadHandler += masterDataLoad; _coreDriver.ListenerMgmt.MasterDataCreatedHandler += masterDataCreated; _coreDriver.ListenerMgmt.DocumentReversedHandler += documentReversed; _coreDriver.ListenerMgmt.GLAccountInitAmountChangedHandler += glAccountInitAmountChanged; }
/// <summary> /// Only internal can invoke /// </summary> /// <param name="coreDriver"></param> /// <param name="management"></param> /// <param name="head"></param> /// <param name="lineNum"></param> internal ItemEntity(CoreDriver coreDriver, MasterDataManagement management, HeadEntity head, int lineNum) { _coreDriver = coreDriver; _management = management; _head = head; _lineNum = lineNum; _glAccount = null; _customer = null; _vendor = null; _amount = new CurrencyAmount(); _businessArea = null; }
/// <summary> /// /// </summary> /// <param name="monthId"></param> /// <returns></returns> public ObservableCollection <AbstractAdapterItem> GetItems(MonthIdentity monthId) { CoreDriver coreDriver = _dataCore.BackendCoreDriver; if (coreDriver.IsInitialize == false) { return(_items); } if (_curMonthId == null || _curMonthId.Equals(monthId) == false) { // clear _items.Clear(); // change month _curMonthId = monthId; GLAccountBalanceCollection balCol = coreDriver.TransMgmt.AccountBalanceCol; MasterDataManagement mdMgmt = coreDriver.MdMgmt; // for each cost group List <CostReportItem> costList = new List <CostReportItem>(); foreach (GLAccountGroupENUM group in GLAccountGroup.COST_GROUP) { List <MasterDataIdentity_GLAccount> ids = mdMgmt .GetGLAccountsBasedGroup(group); // for g/l account in each group foreach (MasterDataIdentity_GLAccount id in ids) { // get master data GLAccountMasterData masterData = (GLAccountMasterData)mdMgmt .GetMasterData(id, MasterDataType.GL_ACCOUNT); // get balance item GLAccountBalanceItem item = balCol.GetBalanceItem(id); costList.Add(new CostReportItem(id, masterData.Descp , item.GetAmount(_curMonthId), this)); } } // sort costList.Sort(); foreach (CostReportItem costItem in costList) { _items.Add(costItem); } } return(_items); }
/// <summary> /// pasrse document to customer entry /// </summary> /// <param name="head"></param> /// <returns>return null, when cannot parse</returns> public static CustomerEntry parse(HeadEntity head, MasterDataManagement mdMgmt) { // check if (head.DocType != DocumentType.CUSTOMER_INVOICE) { return(null); } List <ItemEntity> items = head.Items; if (items.Count != 2) { return(null); } // credit item ItemEntity creditItem = items[0]; if (creditItem.AccType != AccountType.GL_ACCOUNT) { return(null); } ItemEntity debitItem = items[1]; if (debitItem.AccType != AccountType.CUSTOMER) { return(null); } CustomerEntry entry = new CustomerEntry(head._coreDriver , head._coreDriver.MdMgmt); entry._glAccount = creditItem.GLAccount; entry._recAcc = debitItem.GLAccount; entry._customer = debitItem.Customer; 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); }
/// <summary> /// check core driver /// </summary> /// <param name="coreDriver"></param> private void checkCore(CoreDriver coreDriver) { Assert.AreEqual(true, coreDriver.IsInitialize); MasterDataManagement masterData = coreDriver.MdMgmt; foreach (MasterDataType type in Enum.GetValues(typeof(MasterDataType))) { MasterDataFactoryBase factory = masterData .GetMasterDataFactory(type); Assert.AreEqual(0, factory.AllEntities.Count); } TransactionDataManagement tranData = coreDriver .TransMgmt; Assert.IsTrue(null != tranData); MonthIdentity[] monthIds = coreDriver.MonthIds; Assert.AreEqual(1, monthIds.Length); }
public CoreDriver() { _infos = new List <DebugInformation>(); _listenerManagement = new ListenersManagement(); // _listenerManagement.addCloseLedgerListener(_closeLedgerListener); // managements _managements = new Dictionary <String, AbstractManagement>(); MasterDataManagement mdMgmt = new MasterDataManagement(this); _managements.Add(MASTERDATA, mdMgmt); _managements.Add(TRANDATA, new TransactionDataManagement(this, mdMgmt)); _managements.Add(REPORTDATA, new ReportsManagement(this, mdMgmt)); _managements.Add(TEMPLATE, new EntryTemplatesManagement(this, mdMgmt)); _startMonthId = null; _isInitialized = false; _language = Language.SimpleChinese; }
/// <summary> /// Parse XElement to header /// </summary> /// <param name="coreDriver"></param> /// <param name="management"></param> /// <param name="elem"></param> /// <returns></returns> /// <exception cref="TransactionDataFileFormatException"></exception> public static HeadEntity Parse(CoreDriver coreDriver, MasterDataManagement management, XElement elem) { HeadEntity head = new HeadEntity(coreDriver, management); head._isSaved = true; #region get document number XAttribute docNumStr = elem.Attribute(TransDataUtils.XML_DOC_NUM); if (docNumStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format( "Field {0} is missing in.", TransDataUtils.XML_DOC_NUM), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } try { head._docNumber = new DocumentNumber(docNumStr.Value.ToCharArray()); } catch (Exception) { coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format( "Format of field {0} is error.", TransDataUtils.XML_DOC_NUM), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } #endregion #region fiscal year XAttribute yearStr = elem.Attribute(TransDataUtils.XML_YEAR); if (yearStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 283, String.Format( "Field %s is missing in.", TransDataUtils.XML_YEAR), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } int year; if (!Int32.TryParse(yearStr.Value, out year)) { coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format( "Format of field {0} is error.", TransDataUtils.XML_YEAR), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } #endregion #region fiscal month XAttribute monthStr = elem.Attribute(TransDataUtils.XML_MONTH); if (monthStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 295, String.Format( "Field %s is missing in.", TransDataUtils.XML_MONTH), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } int month; if (!Int32.TryParse(monthStr.Value, out month)) { coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format( "Format of field {0} is error.", TransDataUtils.XML_MONTH), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } #endregion try { head._monthId = new MonthIdentity(year, month); } catch (FiscalMonthRangeException) { coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format( "Format of field {0} is error.", TransDataUtils.XML_MONTH), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } catch (FiscalYearRangeException) { coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format( "Format of field {0} is error.", TransDataUtils.XML_YEAR), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } // posting date XAttribute dateStr = elem.Attribute(TransDataUtils.XML_DATE); if (dateStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 307, String.Format( "Field %s is missing in.", TransDataUtils.XML_DATE), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } if (!DateTime.TryParse(dateStr.Value, out head._postingDate)) { coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format( "Format of field {0} is error.", TransDataUtils.XML_DATE), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } // text XAttribute text = elem.Attribute(TransDataUtils.XML_TEXT); if (text == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 325, String.Format( "Field %s is missing in.", TransDataUtils.XML_TEXT), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } head._docText = text.Value; // document type XAttribute docTypeStr = elem.Attribute(TransDataUtils.XML_DOC_TYPE); if (docTypeStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 325, String.Format( "Field %s is missing in.", TransDataUtils.XML_DOC_TYPE), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } if (docTypeStr.Value.Length != 1 || (docTypeStr.Value[0] != (char)DocumentType.CUSTOMER_INVOICE && docTypeStr.Value[0] != (char)DocumentType.GL && docTypeStr.Value[0] != (char)DocumentType.VENDOR_INVOICE)) { coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format( "Format of field {0} is error.", TransDataUtils.XML_DOC_TYPE), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } head._type = (DocumentType)docTypeStr.Value[0]; // is reversed XAttribute isReversedStr = elem .Attribute(TransDataUtils.XML_IS_REVERSED); if (isReversedStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 338, String.Format( "Field %s is missing in.", TransDataUtils.XML_IS_REVERSED), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } if (!bool.TryParse(isReversedStr.Value, out head._isReversed)) { coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format( "Format of field {0} is error.", TransDataUtils.XML_IS_REVERSED), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } // parse item foreach (XElement itemElem in elem.Elements(TransDataUtils.XML_ITEM)) { ItemEntity item = ItemEntity.Parse(coreDriver, management, head, itemElem); item._isSaved = true; coreDriver .logDebugInfo( typeof(HeadEntity), 377, String.Format( "Line Item %d appended during parsing document.", item.LineNum), MessageType.INFO); head._items.Add(item); } // addition attributes foreach (XAttribute attr in elem.Attributes()) { head._fields.Add(attr.Name.LocalName, attr.Value); } // remove fields is not additional fields foreach (String str in TransDataUtils.HEAD_XML_TAGS) { head._fields.Remove(str); } // check balance CurrencyAmount sum = new CurrencyAmount(); foreach (ItemEntity item in head._items) { if (item.CdIndicator == CreditDebitIndicator.DEBIT) { sum.AddTo(item.Amount); } else { sum.MinusTo(item.Amount); } } if (sum.IsZero() == false) { throw new TransactionDataFileFormatException("No Balance"); } StringBuilder strBuilder = new StringBuilder( String.Format( "Parse document %s with posting date %s, text %s, type %s, is_reversed %s", head.DocIdentity, head.PstDate, head.DocText, head.DocType, head.IsReversed)); coreDriver.logDebugInfo(typeof(HeadEntity), 377, strBuilder.ToString(), MessageType.INFO); return(head); }
public static void CheckMasterData(CoreDriver _coreDriver) { Assert.AreEqual(true, _coreDriver.IsInitialize); MasterDataManagement masterDataManagement = _coreDriver.MdMgmt; List <MasterDataBase> datas; // check vendor data VendorMasterDataFactory vendorFactory = (VendorMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.VENDOR); Assert.AreEqual(2, vendorFactory.MasterDataCount); datas = vendorFactory.AllEntities; Assert.AreEqual(TestData.VENDOR_BUS, datas[0].Identity.ToString()); Assert.AreEqual(TestData.VENDOR_BUS_DESCP, datas[0].Descp); Assert.AreEqual(TestData.VENDOR_SUBWAY, datas[1].Identity.ToString()); Assert.AreEqual(TestData.VENDOR_SUBWAY_DESCP, datas[1].Descp); // check customer data CustomerMasterDataFactory customerFactory = (CustomerMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.CUSTOMER); Assert.AreEqual(2, customerFactory.MasterDataCount); datas = customerFactory.AllEntities; Assert.AreEqual(TestData.CUSTOMER1, datas[0].Identity.ToString()); Assert.AreEqual(TestData.CUSTOMER1_DESCP, datas[0].Descp); Assert.AreEqual(TestData.CUSTOMER2, datas[1].Identity.ToString()); Assert.AreEqual(TestData.CUSTOMER2_DESCP, datas[1].Descp); // check business area BusinessAreaMasterDataFactory businessAreaFactory = (BusinessAreaMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.BUSINESS_AREA); Assert.AreEqual(3, businessAreaFactory.MasterDataCount); datas = businessAreaFactory.AllEntities; Assert.AreEqual(TestData.BUSINESS_AREA_WORK, datas[0].Identity .ToString()); Assert.AreEqual(TestData.BUSINESS_AREA_WORK_DESCP, datas[0].Descp); Assert.AreEqual(CriticalLevel.HIGH, ((BusinessAreaMasterData)datas[0]).CriLevel); Assert.AreEqual(TestData.BUSINESS_AREA_SNACKS, datas[1].Identity .ToString()); Assert.AreEqual(TestData.BUSINESS_AREA_SNACKS_DESCP, datas[1].Descp); Assert.AreEqual(CriticalLevel.LOW, ((BusinessAreaMasterData)datas[1]).CriLevel); Assert.AreEqual(TestData.BUSINESS_AREA_ENTERTAIN, datas[2].Identity .ToString()); Assert.AreEqual(TestData.BUSINESS_AREA_ENTERTAIN_DESCP, datas[2].Descp); Assert.AreEqual(CriticalLevel.MEDIUM, ((BusinessAreaMasterData)datas[2]).CriLevel); // check bank key BankKeyMasterDataFactory bankKeyFactory = (BankKeyMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.BANK_KEY); Assert.AreEqual(1, bankKeyFactory.MasterDataCount); datas = bankKeyFactory.AllEntities; Assert.AreEqual(TestData.BANK_KEY, datas[0].Identity.ToString()); Assert.AreEqual(TestData.BANK_KEY_DESCP, datas[0].Descp); // check bank account BankAccountMasterDataFactory bankAccountFactory = (BankAccountMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.BANK_ACCOUNT); Assert.AreEqual(2, bankAccountFactory.MasterDataCount); datas = bankAccountFactory.AllEntities; Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6235, datas[0].Identity .ToString()); Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6235_DESCP, datas[0].Descp); Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6235_ACC, ((BankAccountMasterData)datas[0]).AccountNumber .ToString()); Assert.AreEqual(BankAccountType.SAVING_ACCOUNT, ((BankAccountMasterData)datas[0]).BankAccType); Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6620, datas[1].Identity .ToString()); Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6620_DESCP, datas[1].Descp); Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6620_ACC, ((BankAccountMasterData)datas[1]).AccountNumber .ToString()); Assert.AreEqual(BankAccountType.CREDIT_CARD, ((BankAccountMasterData)datas[1]).BankAccType); // check G/L account GLAccountMasterDataFactory accountFactory = (GLAccountMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.GL_ACCOUNT); Assert.AreEqual(5, accountFactory.MasterDataCount); datas = accountFactory.AllEntities; Assert.AreEqual(TestData.GL_ACCOUNT_CASH, datas[0].Identity .ToString()); Assert.AreEqual(TestData.GL_ACCOUNT_CASH_DESCP, datas[0].Descp); Assert.AreEqual(TestData.AMOUNT_VENDOR, ((GLAccountMasterData)datas[0]).InitAmount); Assert.AreEqual(TestData.GL_ACCOUNT_BANK, datas[1].Identity .ToString()); Assert.AreEqual(TestData.GL_ACCOUNT_BANK_DESCP, datas[1].Descp); Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6235, ((GLAccountMasterData)datas[1]).BankAccount.ToString()); Assert.AreEqual(new CurrencyAmount(), ((GLAccountMasterData)datas[1]).InitAmount); Assert.AreEqual(TestData.GL_ACCOUNT_EQUITY, datas[2].Identity .ToString()); Assert.AreEqual(TestData.GL_ACCOUNT_EQUITY_DESCP, datas[2].Descp); Assert.AreEqual(new CurrencyAmount(), ((GLAccountMasterData)datas[2]).InitAmount); Assert.AreEqual(TestData.GL_ACCOUNT_REV, datas[3].Identity .ToString()); Assert.AreEqual(TestData.GL_ACCOUNT_REV_DESCP, datas[3].Descp); Assert.AreEqual(new CurrencyAmount(), ((GLAccountMasterData)datas[3]).InitAmount); Assert.AreEqual(TestData.GL_ACCOUNT_COST, datas[4].Identity .ToString()); Assert.AreEqual(TestData.GL_ACCOUNT_COST_DESCP, datas[4].Descp); Assert.AreEqual(new CurrencyAmount(), ((GLAccountMasterData)datas[4]).InitAmount); }
internal DocumentAccountIndex(CoreDriver coreDriver, MasterDataManagement mdMgmt) : base(coreDriver, mdMgmt) { }
/// <summary> /// parse XML to template /// </summary> /// <param name="coreDriver"></param> /// <param name="elem"></param> /// <returns></returns> /// <exception cref="TemplateFormatException"></exception> public static EntryTemplate Parse(CoreDriver coreDriver, MasterDataManagement mdMgmt , XElement elem) { XAttribute idStr = elem.Attribute(XML_ID); XAttribute name = elem.Attribute(XML_NAME); XAttribute typeStr = elem.Attribute(XML_TYPE); if (name == null) { coreDriver.logDebugInfo(typeof(EntryTemplate), 228, "No value in template name", MessageType.ERRO); throw new TemplateFormatException(); } int id; if (int.TryParse(idStr.Value, out id) == false) { throw new TemplateFormatException(); } EntryType type; if (typeStr.Value.Equals(XML_VENDOR)) { type = EntryType.VendorEntry; } else if (typeStr.Value.Equals(XML_CUSTOMER)) { type = EntryType.CustomerEntry; } else if (typeStr.Value.Equals(XML_GL)) { type = EntryType.GLEntry; } else { coreDriver.logDebugInfo(typeof(EntryTemplate), 252, "template type is not correct: " + typeStr.Value, MessageType.ERRO); throw new TemplateFormatException(); } EntryTemplate template = new EntryTemplate(coreDriver, mdMgmt , type, id, name.Value); foreach (XElement fieldElem in elem.Elements(XML_FIELD)) { XAttribute fieldName = fieldElem.Attribute(XML_NAME); XAttribute fieldValue = fieldElem.Attribute(XML_VALUE); if (fieldName.Value.Equals(EntryTemplate.AMOUNT)) { try { CurrencyAmount amount = CurrencyAmount .Parse(fieldValue.Value); template.AddDefaultValue(fieldName.Value, amount); } catch (CurrencyAmountFormatException e) { coreDriver.logDebugInfo(typeof(EntryTemplate), 287, e.Message, MessageType.ERRO); throw new TemplateFormatException(); } catch (NotInValueRangeException e) { coreDriver.logDebugInfo(typeof(EntryTemplate), 287, e.Message, MessageType.ERRO); throw new TemplateFormatException(); } catch (NoFieldNameException e) { coreDriver.logDebugInfo(typeof(EntryTemplate), 287, e.Message, MessageType.ERRO); throw new TemplateFormatException(); } } else if (fieldName.Value.Equals(EntryTemplate.TEXT)) { try { template.AddDefaultValue(fieldName.Value, fieldValue.Value); } catch (NotInValueRangeException e) { coreDriver.logDebugInfo(typeof(EntryTemplate), 287, e.Message, MessageType.ERRO); throw new TemplateFormatException(); } catch (NoFieldNameException e) { coreDriver.logDebugInfo(typeof(EntryTemplate), 287, e.Message, MessageType.ERRO); throw new TemplateFormatException(); } } else { try { switch (type) { case EntryType.VendorEntry: if (fieldName.Value.Equals(VendorEntry.REC_ACC) || fieldName .Value.Equals(VendorEntry.GL_ACCOUNT)) { MasterDataIdentity_GLAccount accountId = new MasterDataIdentity_GLAccount( fieldValue.Value); template.AddDefaultValue(fieldName.Value, accountId); } else { MasterDataIdentity dataId = new MasterDataIdentity( fieldValue.Value); template.AddDefaultValue(fieldName.Value, dataId); } break; case EntryType.CustomerEntry: if (fieldName.Value.Equals(CustomerEntry.REC_ACC) || fieldName.Value .Equals(CustomerEntry.GL_ACCOUNT)) { MasterDataIdentity_GLAccount accountId = new MasterDataIdentity_GLAccount( fieldValue.Value); template.AddDefaultValue(fieldName.Value, accountId); } else { MasterDataIdentity dataId = new MasterDataIdentity( fieldValue.Value); template.AddDefaultValue(fieldName.Value, dataId); } break; case EntryType.GLEntry: MasterDataIdentity_GLAccount accId = new MasterDataIdentity_GLAccount( fieldValue.Value); template.AddDefaultValue(fieldName.Value, accId); break; } } catch (Exception e) { coreDriver.logDebugInfo(typeof(EntryTemplate), 309, e.Message, MessageType.ERRO); throw new TemplateFormatException(); } } } return(template); }
/// <summary> /// parse XML to item entity /// </summary> /// <param name="coreDriver"></param> /// <param name="management"></param> /// <param name="head"></param> /// <param name="elem"></param> /// <returns></returns> /// <exception cref="TransactionDataFileFormatException"></exception> /// <exception cref="SystemException"></exception> public static ItemEntity Parse(CoreDriver coreDriver, MasterDataManagement management, HeadEntity head, XElement elem) { #region get line number XAttribute lineNumStr = elem.Attribute(TransDataUtils.XML_LINE_NUM); if (lineNumStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 363, String.Format( "Field {0} is missing in.", TransDataUtils.XML_LINE_NUM), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } int lineNum; if (!Int32.TryParse(lineNumStr.Value, out lineNum)) { coreDriver.logDebugInfo(typeof(HeadEntity), 363, String.Format( "Format of field {0} is error.", TransDataUtils.XML_LINE_NUM), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } #endregion #region get account type XAttribute typeStr = elem.Attribute(TransDataUtils.XML_ACCOUNT_TYPE); if (typeStr == null) { coreDriver .logDebugInfo(typeof(HeadEntity), 375, String.Format( "Field {0} is missing in.", TransDataUtils.XML_ACCOUNT_TYPE), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } if (typeStr.Value.Length != 1 || (typeStr.Value[0] != (char)AccountType.CUSTOMER && typeStr.Value[0] != (char)AccountType.GL_ACCOUNT && typeStr.Value[0] != (char)AccountType.VENDOR)) { coreDriver .logDebugInfo(typeof(HeadEntity), 375, String.Format( "Format of field {0} is error.", TransDataUtils.XML_ACCOUNT_TYPE), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } AccountType type = (AccountType)typeStr.Value[0]; #endregion #region amount XAttribute amountStr = elem.Attribute(TransDataUtils.XML_AMOUNT); if (amountStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 375, String.Format( "Field {0} is missing in.", TransDataUtils.XML_AMOUNT), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } CurrencyAmount amount; try { amount = CurrencyAmount.Parse(amountStr.Value); } catch (Exception e) { coreDriver .logDebugInfo(typeof(HeadEntity), 375, e.Message, MessageType.ERRO); throw new TransactionDataFileFormatException(""); } #endregion #region credit debit indicator XAttribute cdIndStr = elem.Attribute(TransDataUtils.XML_CD_INDICATOR); if (cdIndStr == null) { coreDriver .logDebugInfo(typeof(HeadEntity), 375, String.Format( "Field {0} is missing in.", TransDataUtils.XML_CD_INDICATOR), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } if (cdIndStr.Value.Length != 1 || (cdIndStr.Value[0] != (char)CreditDebitIndicator.CREDIT && cdIndStr.Value[0] != (char)CreditDebitIndicator.DEBIT)) { coreDriver .logDebugInfo(typeof(HeadEntity), 375, String.Format( "Format of field {0} is error.", TransDataUtils.XML_CD_INDICATOR), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } CreditDebitIndicator indicator = (CreditDebitIndicator)cdIndStr.Value[0]; #endregion #region G/L account XAttribute glAccountStr = elem.Attribute(TransDataUtils.XML_GL_ACCOUNT); if (glAccountStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 414, String.Format( "Field {0} is missing in.", TransDataUtils.XML_GL_ACCOUNT), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } MasterDataIdentity_GLAccount glAccount; try { glAccount = new MasterDataIdentity_GLAccount( glAccountStr.Value); } catch (Exception e) { coreDriver .logDebugInfo(typeof(HeadEntity), 375, e.Message, MessageType.ERRO); throw new TransactionDataFileFormatException(""); } #endregion // vendor XAttribute vendorStr = elem.Attribute(TransDataUtils.XML_VENDOR); // customer XAttribute customerStr = elem.Attribute(TransDataUtils.XML_CUSTOMER); XAttribute businessAreaStr = elem .Attribute(TransDataUtils.XML_BUSINESS_AREA); try { ItemEntity newItem = new ItemEntity(coreDriver, management, head, lineNum); #region set account, vendor and customer if (type == AccountType.GL_ACCOUNT) { newItem.SetGLAccount(glAccount); } else if (type == AccountType.VENDOR) { if (vendorStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 414, String .Format("Field %s is missing in.", TransDataUtils.XML_VENDOR), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } MasterDataIdentity vendorId = new MasterDataIdentity( vendorStr.Value); newItem.SetVendor(vendorId, glAccount); } else if (type == AccountType.CUSTOMER) { if (customerStr == null) { coreDriver.logDebugInfo(typeof(HeadEntity), 414, String .Format("Field %s is missing in.", TransDataUtils.XML_CUSTOMER), MessageType.ERRO); throw new TransactionDataFileFormatException(""); } MasterDataIdentity customerId = new MasterDataIdentity( customerStr.Value); newItem.SetCustomer(customerId, glAccount); } #endregion newItem.SetAmount(indicator, amount); if (businessAreaStr != null) { newItem.SetBusinessArea(new MasterDataIdentity(businessAreaStr.Value)); } coreDriver.logDebugInfo( typeof(ItemEntity), 455, String.Format("Parsed line Item {0}.", newItem.LineNum), MessageType.INFO); return(newItem); } catch (IdentityTooLong e) { coreDriver.logDebugInfo(typeof(ItemEntity), 463, e.Message, MessageType.ERRO); throw new TransactionDataFileFormatException(""); } catch (IdentityNoData e) { coreDriver.logDebugInfo(typeof(ItemEntity), 463, e.Message, MessageType.ERRO); throw new TransactionDataFileFormatException(""); } catch (IdentityInvalidChar e) { coreDriver.logDebugInfo(typeof(ItemEntity), 463, e.Message, MessageType.ERRO); throw new TransactionDataFileFormatException(""); } catch (ArgumentNullException e) { coreDriver.logDebugInfo(typeof(ItemEntity), 463, e.Message, MessageType.ERRO); throw new SystemException(e); } catch (MasterDataIdentityNotDefined e) { coreDriver.logDebugInfo(typeof(ItemEntity), 463, e.Message, MessageType.ERRO); throw new TransactionDataFileFormatException(""); } catch (CurrencyAmountFormatException e) { throw new TransactionDataFileFormatException(e.Message); } }
/// <summary> /// constructor /// </summary> /// <param name="coreDriver"></param> public CustomerEntry(CoreDriver coreDriver, MasterDataManagement mdMgmt) { _coreDriver = coreDriver; _mdMgmt = mdMgmt; }
public static void CreateMasterData(CoreDriver coreDriver) { /// /// check the factory is initialized, and the factory with no master data /// MasterDataManagement masterDataManagement = coreDriver.MdMgmt; // vendor VendorMasterDataFactory vendorFactory = (VendorMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.VENDOR); Assert.AreEqual(0, vendorFactory.MasterDataCount); // customer CustomerMasterDataFactory customerFactory = (CustomerMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.CUSTOMER); Assert.AreEqual(0, customerFactory.MasterDataCount); // business area BusinessAreaMasterDataFactory businessFactory = (BusinessAreaMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.BUSINESS_AREA); Assert.AreEqual(0, businessFactory.MasterDataCount); // bank key BankKeyMasterDataFactory bankKeyFactory = (BankKeyMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.BANK_KEY); Assert.AreEqual(0, bankKeyFactory.MasterDataCount); // bank account BankAccountMasterDataFactory bankAccountFactory = (BankAccountMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.BANK_ACCOUNT); Assert.AreEqual(0, bankAccountFactory.MasterDataCount); // GL account GLAccountMasterDataFactory accountFactory = (GLAccountMasterDataFactory)masterDataManagement .GetMasterDataFactory(MasterDataType.GL_ACCOUNT); Assert.AreEqual(0, accountFactory.MasterDataCount); /** add master data entities */ // vendor VendorMasterData vendor = (VendorMasterData)vendorFactory .CreateNewMasterDataBase(new MasterDataIdentity( TestData.VENDOR_BUS), TestData.VENDOR_BUS_DESCP); Assert.IsTrue(vendor != null); vendor = (VendorMasterData)vendorFactory.CreateNewMasterDataBase( new MasterDataIdentity(TestData.VENDOR_SUBWAY), TestData.VENDOR_SUBWAY_DESCP); Assert.IsTrue(vendor != null); // duplicate id try { vendorFactory.CreateNewMasterDataBase(new MasterDataIdentity( TestData.VENDOR_SUBWAY), TestData.VENDOR_SUBWAY_DESCP); Assert.Fail("Duplicate Id"); } catch (MasterDataIdentityExists) { } // customer CustomerMasterData customer = (CustomerMasterData)customerFactory .CreateNewMasterDataBase(new MasterDataIdentity( TestData.CUSTOMER1), TestData.CUSTOMER1_DESCP); Assert.IsTrue(customer != null); customer = (CustomerMasterData)customerFactory .CreateNewMasterDataBase(new MasterDataIdentity( TestData.CUSTOMER2), TestData.CUSTOMER2_DESCP); Assert.IsTrue(customer != null); // duplicate id try { customerFactory.CreateNewMasterDataBase(new MasterDataIdentity( TestData.CUSTOMER2), TestData.CUSTOMER2_DESCP); Assert.Fail("Duplicate Id"); } catch (MasterDataIdentityExists) { } // bank key BankKeyMasterData bankKey = (BankKeyMasterData)bankKeyFactory .CreateNewMasterDataBase(new MasterDataIdentity( TestData.BANK_KEY), TestData.BANK_KEY_DESCP); Assert.IsTrue(bankKey != null); // duplicate id try { bankKeyFactory.CreateNewMasterDataBase(new MasterDataIdentity( TestData.BANK_KEY), TestData.BANK_KEY_DESCP); Assert.Fail("Duplicate Id"); } catch (MasterDataIdentityExists) { } // bank account MasterDataIdentity bankKeyId = new MasterDataIdentity(TestData.BANK_KEY); BankAccountNumber accountNum = new BankAccountNumber( TestData.BANK_ACCOUNT_CMB_6235_ACC); BankAccountMasterData bankAcc = (BankAccountMasterData)bankAccountFactory .CreateNewMasterDataBase(new MasterDataIdentity( TestData.BANK_ACCOUNT_CMB_6235), TestData.BANK_ACCOUNT_CMB_6235_DESCP, accountNum, bankKeyId, BankAccountType.SAVING_ACCOUNT); Assert.IsTrue(bankAcc != null); accountNum = new BankAccountNumber(TestData.BANK_ACCOUNT_CMB_6620_ACC); bankAcc = (BankAccountMasterData)bankAccountFactory .CreateNewMasterDataBase(new MasterDataIdentity( TestData.BANK_ACCOUNT_CMB_6620), TestData.BANK_ACCOUNT_CMB_6620_DESCP, accountNum, bankKeyId, BankAccountType.CREDIT_CARD); Assert.IsTrue(bankAcc != null); // duplicate id try { bankAccountFactory.CreateNewMasterDataBase(new MasterDataIdentity( TestData.BANK_ACCOUNT_CMB_6620), TestData.BANK_ACCOUNT_CMB_6620_DESCP, accountNum, bankKey, BankAccountType.SAVING_ACCOUNT); Assert.Fail("Duplicate Id"); } catch (MasterDataIdentityExists) { } // business area BusinessAreaMasterData businessArea = (BusinessAreaMasterData)businessFactory .CreateNewMasterDataBase(new MasterDataIdentity( TestData.BUSINESS_AREA_ENTERTAIN), TestData.BUSINESS_AREA_ENTERTAIN_DESCP, CriticalLevel.MEDIUM); Assert.IsTrue(businessArea != null); businessArea = (BusinessAreaMasterData)businessFactory .CreateNewMasterDataBase(new MasterDataIdentity( TestData.BUSINESS_AREA_WORK), TestData.BUSINESS_AREA_WORK_DESCP, CriticalLevel.HIGH); Assert.IsTrue(businessArea != null); businessArea = (BusinessAreaMasterData)businessFactory .CreateNewMasterDataBase(new MasterDataIdentity( TestData.BUSINESS_AREA_SNACKS), TestData.BUSINESS_AREA_SNACKS_DESCP, CriticalLevel.LOW); Assert.IsTrue(businessArea != null); // duplicate id try { businessArea = (BusinessAreaMasterData)businessFactory .CreateNewMasterDataBase(new MasterDataIdentity( TestData.BUSINESS_AREA_SNACKS), TestData.BUSINESS_AREA_SNACKS_DESCP, CriticalLevel.LOW); Assert.Fail("Duplicate Id"); } catch (MasterDataIdentityExists) { } // G/L account MasterDataIdentity bankAccId = new MasterDataIdentity( TestData.BANK_ACCOUNT_CMB_6235); GLAccountMasterData glAccount = (GLAccountMasterData)accountFactory .CreateNewMasterDataBase(new MasterDataIdentity_GLAccount( TestData.GL_ACCOUNT_BANK), TestData.GL_ACCOUNT_BANK_DESCP, bankAccId); Assert.IsTrue(glAccount != null); glAccount = (GLAccountMasterData)accountFactory .CreateNewMasterDataBase(new MasterDataIdentity_GLAccount( TestData.GL_ACCOUNT_CASH), TestData.GL_ACCOUNT_CASH_DESCP); Assert.IsTrue(glAccount != null); glAccount.SetInitAmount(TestData.AMOUNT_VENDOR); glAccount = (GLAccountMasterData)accountFactory .CreateNewMasterDataBase(new MasterDataIdentity_GLAccount( TestData.GL_ACCOUNT_COST), TestData.GL_ACCOUNT_COST_DESCP); Assert.IsTrue(glAccount != null); glAccount = (GLAccountMasterData)accountFactory .CreateNewMasterDataBase(new MasterDataIdentity_GLAccount( TestData.GL_ACCOUNT_EQUITY), TestData.GL_ACCOUNT_EQUITY_DESCP); Assert.IsTrue(glAccount != null); glAccount = (GLAccountMasterData)accountFactory .CreateNewMasterDataBase(new MasterDataIdentity_GLAccount( TestData.GL_ACCOUNT_REV), TestData.GL_ACCOUNT_REV_DESCP); Assert.IsTrue(glAccount != null); // duplicate id try { accountFactory.CreateNewMasterDataBase( new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_REV), TestData.GL_ACCOUNT_REV_DESCP); Assert.Fail("Duplicate Id"); } catch (MasterDataIdentityExists) { } }
/// <summary> /// constructor /// </summary> /// <param name="coreDriver"></param> /// <param name="mdMgmt"></param> public EntryTemplatesManagement(CoreDriver coreDriver, MasterDataManagement mdMgmt) : base(coreDriver) { _list = new Dictionary <int, EntryTemplate>(); _mdMgmt = mdMgmt; }
internal DocumentBusinessIndex(CoreDriver coreDriver, MasterDataManagement mdMgmt) : base(coreDriver, mdMgmt) { }