[英]General Journal AIF Services can't import offsets account of type customers - AX 2012
我正在嘗試使用AIF將數據從CSV文件導入AX 2012,並通過C#Web應用程序使用Web Service。
我嘗試提取的數據來自:
我正在使用的Web服務是基本GeneralJournalService 。 在Web應用程序中使用Web服務的代碼是(假設它是為string[]
解析CSV文件,而ImportingHelper.EnumUtils.Parse
則解析為枚舉類型):
public class ImportingJournals : ImportClass
{
internal static int TransDateIndex = 0;
internal static int AccountTypeIndex = 2;
internal static int LedgerDimensionMainAccountIndex = 3;
internal static int LedgerDimensionOnDisplayValueIndex = 4;
internal static int LedgerDimensionValuesIndex = 5;
internal static int DescriptionOnLineIndex = 6;
internal static int DebittIndex = 7;
internal static int CreditIndex = 8;
internal static int CurrencyIndex = 9;
internal static int OffsetAccountTypeIndex = 10;
internal static int OffsetMainAccountIndex = 11;
internal static int OffsetDisplayAccountIndex = 12;
internal static int OffsetAccountValuesIndex = 13;
internal static int JournalNameIndex = 14;
internal static int DescriptionHeaderIndex = 15;
internal static int CompanyIndex = 16;
internal static int OffsetCompanyIndex = 16;
internal static int FromCompanyIndex = 16;
internal static int ActiveIndex = 3;
internal static int ApproveIndex = 4;
internal static int FixedOffsetAccountIndex = 5;
internal static int ApprovalWorkflowIndex = 8;
internal static int DetailLevelIndex = 12;
internal static int FeesPostingIndex = 13;
internal static int LinesLimitIndex = 14;
internal static int PrivateForUserGroupIndex = 15;
internal static int VoucherSeriesIndex = 16;
internal static int NewVoucherIndex = 17;
internal static int NumberAllocationAtPostingIndex = 18;
internal static int DocumentIndex = 19;
internal static int FixedRateIndex = 20;
internal static int AmountIncludedSalesTaxIndex = 22;
internal static int HideSalesTaxFieldsInJournalEntryFormIndex = 23;
internal static int LanguageIndex = 27;
internal static int DescriptionTransIndex = 30;
public void CreateFromCSVFile()
{
throw new NotImplementedException();
}
public void CreateFromCSVFile(System.IO.Stream fileStream)
{
GeneralJournalServiceClient generalJournalServiceClient = new GeneralJournalServiceClient();
try
{
List<string[]> JournalData = Helper.ImportCSVFile.ParseCSVFile(fileStream, true);
foreach (string[] journal in JournalData)
{
CallContext callContext = new CallContext();
callContext.Company = journal[CompanyIndex];
callContext.Language = "en-gb";
AxdLedgerGeneralJournal journalEntity = new AxdLedgerGeneralJournal();
AxdEntity_LedgerJournalTable journalHeader = new LedgerServices.AxdEntity_LedgerJournalTable();
journalHeader.JournalName = journal[JournalNameIndex].Trim();
journalHeader.Name = journal[DescriptionHeaderIndex].Trim();
if (journal[DetailLevelIndex] != String.Empty)
{
journalHeader.DetailSummaryPostingSpecified = true;
AxdEnum_DetailSummary? parsingDetailSummary = ImportingHelper.EnumUtils.Parse<AxdEnum_DetailSummary>("Detail");
if (parsingDetailSummary != null)
journalHeader.DetailSummaryPosting = (AxdEnum_DetailSummary) parsingDetailSummary;
}
else
journalHeader.DetailSummaryPostingSpecified = false;
journalHeader.DetailSummaryPosting = AxdEnum_DetailSummary.Detail;
AxdEntity_LedgerJournalTrans journalLine = new AxdEntity_LedgerJournalTrans();
if (journal[TransDateIndex] != null)
{
journalLine.TransDateSpecified = true;
journalLine.TransDate = DateTime.Parse(journal[TransDateIndex]);
}
else
journalLine.TransDateSpecified = false;
if (journal[AccountTypeIndex] != null)
{
journalLine.AccountTypeSpecified = true;
AxdEnum_LedgerJournalACType? parsingLedgerJournalACType = ImportingHelper.EnumUtils.Parse<AxdEnum_LedgerJournalACType>(journal[AccountTypeIndex]);
if (parsingLedgerJournalACType != null)
journalLine.AccountType = (AxdEnum_LedgerJournalACType)parsingLedgerJournalACType;
}
else
journalLine.AccountTypeSpecified = false;
AxdType_MultiTypeAccount LedgerDimension = new AxdType_MultiTypeAccount();
LedgerDimension.DisplayValue = journal[LedgerDimensionOnDisplayValueIndex];
LedgerDimension.Account = journal[LedgerDimensionMainAccountIndex];
journalLine.LedgerDimension = LedgerDimension;
journalLine.Txt = journal[DescriptionOnLineIndex];
if (journal[DebittIndex] != String.Empty)
{
journalLine.AmountCurDebitSpecified = true;
journalLine.AmountCurDebit = Decimal.Parse(journal[DebittIndex]);
}
else
journalLine.AmountCurDebitSpecified = false;
if (journal[CreditIndex] != String.Empty)
{
journalLine.AmountCurCreditSpecified = true;
journalLine.AmountCurCredit = Decimal.Parse(journal[CreditIndex]);
}
else
journalLine.AmountCurCreditSpecified = false;
if (journal[OffsetAccountTypeIndex] != String.Empty)
{
journalLine.OffsetAccountTypeSpecified = true;
AxdEnum_LedgerJournalACType? parsingLedgerJournalACType = ImportingHelper.EnumUtils.Parse<AxdEnum_LedgerJournalACType>(journal[OffsetAccountTypeIndex]);
if (parsingLedgerJournalACType != null)
journalLine.OffsetAccountType = (AxdEnum_LedgerJournalACType)parsingLedgerJournalACType;
}
else
journalLine.OffsetAccountTypeSpecified = false;
AxdType_MultiTypeAccount ledgerOffsetDimension = new AxdType_MultiTypeAccount();
ledgerOffsetDimension.Account = journal[OffsetMainAccountIndex];
ledgerOffsetDimension.DisplayValue = journal[OffsetDisplayAccountIndex];
journalLine.OffsetLedgerDimension = ledgerOffsetDimension;
journalLine.CurrencyCode = journal[CurrencyIndex];
journalLine.OffsetCompany = journal[OffsetCompanyIndex];
journalLine.Company = journal[FromCompanyIndex];
AxdEntity_LedgerJournalTrans[] journalTransCollection = new AxdEntity_LedgerJournalTrans[1]
{
journalLine
};
journalHeader.LedgerJournalTrans = journalTransCollection;
journalEntity.LedgerJournalTable =
new AxdEntity_LedgerJournalTable[1]
{
journalHeader
};
generalJournalServiceClient.create(callContext, journalEntity);
}
}
catch (Exception ex)
{
String message = ex.Message;
}
finally
{
generalJournalServiceClient.Close();
}
如果有人知道如何解決此問題,請告訴我。 銀行和分類帳之間可以進行交易。 但是銀行與客戶之間的交易是不可能的。 我收到錯誤消息:
抵銷帳戶類型必須是以下類型之一:分類帳,銀行。
我不知道問題是否在於General Journal Service是否可以識別OffsetAccount托管帳戶。
經過數小時的研究,我可能很難獲得一些配置數據,但是問題與該博客中報道的問題非常相似:
http://www.amer-ax.com/2011/06/how-to-use-the-gl-aif-service-to-integrate-non-ledger-transactions/
Web服務提供有關C#的類:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.233")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes")]
public enum AxdEnum_LedgerJournalACType {
/// <remarks/>
Ledger,
/// <remarks/>
Cust,
/// <remarks/>
Vend,
/// <remarks/>
Project,
/// <remarks/>
FixedAssets,
/// <remarks/>
Bank,
}
和
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=9)]
public System.Nullable<AxdEnum_LedgerJournalACType> OffsetAccountType {
get {
return this.offsetAccountTypeField;
}
set {
this.offsetAccountTypeField = value;
this.RaisePropertyChanged("OffsetAccountType");
}
}
但是AX 2012在X ++的另一端不支持它。 查看LedgerTransType
類的方法validateOffsetAccountType
:
protected boolean validateOffsetAccountType()
{
boolean isValid = true;
switch (ledgerJournalTable.JournalType)
{
case LedgerJournalType::Daily :
if (ledgerJournalTrans.OffsetAccountType != LedgerJournalACType::Ledger &&
ledgerJournalTrans.OffsetAccountType != LedgerJournalACType::Bank)
{
if (this.isConsumerStateTracked())
{
// service limitation
isValid = AifFault::checkFailedLogFault("@SYS118081", #OffsetAccountTypeIsNotSupported);
}
}
break;
default :
break;
}
return isValid;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.