/// <summary> /// Converts a GL account string to a composite data object /// </summary> public static AccountNumberCompositeReadOnly ToCompositeAccount(this string accountCString) { var accountCs = new AccountNumberCompositeData(); // AccountNumberCompositeReadOnly acctReadOnly; //TODO: get the setup delimiter from company setup // split the string by the delimiter char delimiter = '-'; // split the segments var acctSegments = accountCString.Split(delimiter); // add each segment to the composite data for (int i = 0; i < acctSegments.Length; i++) { accountCs[i] = acctSegments[i]; } //// create the readonly composite data //acctReadOnly = new AccountNumberCompositeReadOnly(accountCs); // Microsoft.Dexterity.Applications.DynamicsDictionary.AccountNumberCompositeData accountNumberData = new AccountNumberCompositeData(); //accountNumberData[0] = "000"; //accountNumberData[1] = "1100"; //accountNumberData[2] = "00"; //accountNumberData[3] = ""; // Create the read-only composite that is used for the function call var accountNumber = new AccountNumberCompositeReadOnly(accountCs); // Convert the account number to its account alias string alias = Dynamics.Forms.GlAcctBase.Functions.ConvertAcctToAliasStr.Invoke(accountNumber); return(accountNumber); }
/// <summary> /// Converts GL composite data to an account string value /// </summary> public static string CompositeToString(this AccountNumberCompositeData accountCS) { // get the account composite value and convert it to a string string accountNumber = string.Empty; for (int i = 0; i < accountCS.Length; i++) { // check to make sure theere are segment values in the composite value if (!string.IsNullOrEmpty(accountCS[i])) { // add the account separator only if the segment is not the first one // TODO: pull the configuration for the account separator if (i > 0) { accountNumber += "-"; } // add the account segment value accountNumber += accountCS[i]; } } return(accountNumber); }