Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 4, 2020 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/d3d183d03a9cc8e4ce248a95919a6cff to your computer and use it in GitHub Desktop.
Save aspose-com-gists/d3d183d03a9cc8e4ce248a95919a6cff to your computer and use it in GitHub Desktop.
Aspose.Finance for .NET
This gist contains code snippets for Aspose.Finance for .NET API.
XbrlDocument document = new XbrlDocument();
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()];
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs;
schemaRefs.Add(XbrlFilePath + @"schema.xsd", "example", "http://example.com/xbrl/taxonomy");
SchemaRef schema = schemaRefs[0];
ArcroleType arcroleType = schema.GetArcroleTypeByURI("http://abc.com/arcrole/footnote-test");
if (arcroleType != null)
{
ArcroleReference arcroleReference = new ArcroleReference(arcroleType);
xbrlInstance.ArcroleReferences.Add(arcroleReference);
}
document.Save(XbrlFilePath + @"output\document8.xbrl");
XbrlDocument document = new XbrlDocument();
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()];
ContextPeriod contextPeriod = new ContextPeriod(DateTime.Parse("2020-01-01"), DateTime.Parse("2020-02-10"));
ContextEntity contextEntity = new ContextEntity("exampleIdentifierScheme", "exampleIdentifier");
Context context = new Context(contextPeriod, contextEntity);
xbrlInstance.Contexts.Add(context);
document.Save(XbrlFilePath + @"output\document3.xbrl");
XbrlDocument document = new XbrlDocument();
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()];
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs;
schemaRefs.Add(XbrlFilePath + @"schema.xsd", "example", "http://example.com/xbrl/taxonomy");
SchemaRef schema = schemaRefs[0];
ContextPeriod contextPeriod = new ContextPeriod(DateTime.Parse("2020-01-01"), DateTime.Parse("2020-02-10"));
ContextEntity contextEntity = new ContextEntity("exampleIdentifierScheme", "exampleIdentifier");
Context context = new Context(contextPeriod, contextEntity);
context.Id = "cd1";
xbrlInstance.Contexts.Add(context);
FootnoteLink footnoteLink = new FootnoteLink();
Footnote footnote = new Footnote("footnote1");
footnote.Text = "Including the effects of the merger.";
Loc loc = new Loc("#cd1", "fact1");
FootnoteArc footnoteArc = new FootnoteArc(loc.Label, footnote.Label);
footnoteLink.Footnotes.Add(footnote);
footnoteLink.Locators.Add(loc);
footnoteLink.FootnoteArcs.Add(footnoteArc);
xbrlInstance.FootnoteLinks.Add(footnoteLink);
document.Save(XbrlFilePath + @"output\document6.xbrl");
XbrlDocument document = new XbrlDocument();
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()];
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs;
schemaRefs.Add(XbrlFilePath + @"schema.xsd", "example", "http://example.com/xbrl/taxonomy");
SchemaRef schema = schemaRefs[0];
ContextPeriod contextPeriod = new ContextPeriod(DateTime.Parse("2020-01-01"), DateTime.Parse("2020-02-10"));
ContextEntity contextEntity = new ContextEntity("exampleIdentifierScheme", "exampleIdentifier");
Context context = new Context(contextPeriod, contextEntity);
xbrlInstance.Contexts.Add(context);
Unit unit = new Unit(UnitType.Measure);
unit.MeasureQualifiedNames.Add(new QualifiedName("USD", "iso4217", "http://www.xbrl.org/2003/iso4217"));
xbrlInstance.Units.Add(unit);
Concept fixedAssetsConcept = schema.GetConceptByName("fixedAssets");
if (fixedAssetsConcept != null)
{
Item item = new Item(fixedAssetsConcept);
item.ContextRef = context;
item.UnitRef = unit;
item.Precision = 4;
item.Value = "1444";
xbrlInstance.Facts.Add(item);
}
document.Save(XbrlFilePath + @"output\document5.xbrl");
XbrlDocument document = new XbrlDocument();
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()];
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs;
schemaRefs.Add(XbrlFilePath + @"schema.xsd", "example", "http://example.com/xbrl/taxonomy");
SchemaRef schema = schemaRefs[0];
RoleType roleType = schema.GetRoleTypeByURI("http://abc.com/role/link1");
if (roleType != null)
{
RoleReference roleReference = new RoleReference(roleType);
xbrlInstance.RoleReferences.Add(roleReference);
}
document.Save(XbrlFilePath + @"output\document7.xbrl");
XbrlDocument document = new XbrlDocument();
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()];
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs;
schemaRefs.Add(XbrlFilePath + @"schema.xsd", "example", "http://example.com/xbrl/taxonomy");
document.Save(XbrlFilePath + @"output\document2.xbrl");
XbrlDocument document = new XbrlDocument();
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()];
Unit unit = new Unit(UnitType.Measure);
unit.MeasureQualifiedNames.Add(new QualifiedName("USD", "iso4217", "http://www.xbrl.org/2003/iso4217"));
xbrlInstance.Units.Add(unit);
document.Save(XbrlFilePath + @"output\document4.xbrl");
XbrlDocument document = new XbrlDocument();
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[xbrlInstances.Add()];
document.Save(XbrlFilePath + @"output\document1.xbrl");
// For complete examples and data files, please go to https://github.com/aspose-finance/Aspose.Finance-for-.NET
// Working directories
string sourceDir = RunExamples.Get_SourceDirectory();
string outputDir = RunExamples.Get_OutputDirectory();
XbrlDocument document = new XbrlDocument(sourceDir + @"IdScopeContextPeriodStartAfterEnd.xml");
// Set save options
SaveOptions saveOptions = new SaveOptions();
saveOptions.SaveFormat = SaveFormat.IXBRL;
// Save file to XLSX format
document.Save(outputDir + @"ConvertXbrlToIXbrl_out.ixbrl", saveOptions);
// For complete examples and data files, please go to https://github.com/aspose-finance/Aspose.Finance-for-.NET
// Working directories
string sourceDir = RunExamples.Get_SourceDirectory();
string outputDir = RunExamples.Get_OutputDirectory();
XbrlDocument document = new XbrlDocument(sourceDir + @"IdScopeContextPeriodStartAfterEnd.xml");
// Set save options
SaveOptions saveOptions = new SaveOptions();
saveOptions.SaveFormat = SaveFormat.XLSX;
// Save file to XLSX format
document.Save(outputDir + @"ConvertXbrlToXlsx_out.xlsx", saveOptions);
// For complete examples and data files, please go to https://github.com/aspose-finance/Aspose.Finance-for-.NET
// Working directories
string sourceDir = RunExamples.Get_SourceDirectory();
string outputDir = RunExamples.Get_OutputDirectory();
OfxRequestDocument document = new OfxRequestDocument(sourceDir + @"bankTransactionReq.sgml");
document.Save(outputDir + @"bankTransactionReq.xml", OfxVersionEnum.V2x);
// For complete examples and data files, please go to https://github.com/aspose-finance/Aspose.Finance-for-.NET
// Working directories
string sourceDir = RunExamples.Get_SourceDirectory();
string outputDir = RunExamples.Get_OutputDirectory();
OfxResponseDocument document = new OfxResponseDocument(sourceDir + @"bankTransactionRes.sgml");
document.Save(outputDir + @"bankTransactionRes.xml", OfxVersionEnum.V2x);
// For complete examples and data files, please go to https://github.com/aspose-finance/Aspose.Finance-for-.NET
// Working directories
string outputDir = RunExamples.Get_OutputDirectory();
OfxRequestDocument document = new OfxRequestDocument();
document.SignonRequestMessageSetV1 = new SignonRequestMessageSetV1();
SignonRequest signonRequest = new SignonRequest();
document.SignonRequestMessageSetV1.SignonRequest = signonRequest;
signonRequest.ClientDate = "20200611000000";
signonRequest.UserId = "aspose";
signonRequest.UserPassword = "password";
FinancialInstitution fi = new FinancialInstitution();
fi.Organization = "aspose";
fi.FinancialInstitutionId = "1";
signonRequest.FinancialInstitution = fi;
signonRequest.AppVersion = "1.0";
signonRequest.AppId = "Aspose.Finance";
signonRequest.ClientUserId = "aaaaaaa";
document.BankRequestMessageSetV1 = new BankRequestMessageSetV1();
StatementTransactionRequest stmtTransRequest = new StatementTransactionRequest();
document.BankRequestMessageSetV1.StatementTransactionRequests.Add(stmtTransRequest);
stmtTransRequest.TransactionUniqueId = "1111111";
stmtTransRequest.StatementRequest = new StatementRequest();
stmtTransRequest.StatementRequest.BankAccountFrom = new BankAccount();
stmtTransRequest.StatementRequest.BankAccountFrom.BankId = "sssss";
stmtTransRequest.StatementRequest.BankAccountFrom.AccountId = "sfsdfsfsdf";
stmtTransRequest.StatementRequest.BankAccountFrom.AccountType = AccountEnum.CHECKING;
stmtTransRequest.StatementRequest.IncTransaction = new IncTransaction();
stmtTransRequest.StatementRequest.IncTransaction.StartDate = "20200601000000";
stmtTransRequest.StatementRequest.IncTransaction.EndDate = "20200611000000";
stmtTransRequest.StatementRequest.IncTransaction.Include = true;
document.Save(outputDir + @"newOfxRequestBankStatement.xml", OfxVersionEnum.V2x);
document.Save(outputDir + @"newOfxRequestBankStatement.sgml", OfxVersionEnum.V1x);
// For complete examples and data files, please go to https://github.com/aspose-finance/Aspose.Finance-for-.NET
// Working directories
string outputDir = RunExamples.Get_OutputDirectory();
OfxResponseDocument document = new OfxResponseDocument();
document.SignonResponseMessageSetV1 = new SignonResponseMessageSetV1();
SignonResponse signonResponse = new SignonResponse();
document.SignonResponseMessageSetV1.SignonResponse = signonResponse;
signonResponse.Status = new Status();
signonResponse.Status.Code = "0";
signonResponse.Status.Severity = SeverityEnum.INFO;
signonResponse.Status.Message = "SUCCESS";
signonResponse.ServerDate = "20200611";
signonResponse.ProfileUpdateDate = "20200611";
FinancialInstitution fi = new FinancialInstitution();
fi.Organization = "aspose";
fi.FinancialInstitutionId = "1";
signonResponse.FinancialInstitution = fi;
signonResponse.SessionCookie = "11111111111111111";
document.BankResponseMessageSetV1 = new BankResponseMessageSetV1();
StatementTransactionResponse stmtTransResponse = new StatementTransactionResponse();
document.BankResponseMessageSetV1.StatementTransactionResponses.Add(stmtTransResponse);
stmtTransResponse.TransactionUniqueId = "829631324";
stmtTransResponse.Status = new Status();
stmtTransResponse.Status.Code = "0";
stmtTransResponse.Status.Severity = SeverityEnum.INFO;
stmtTransResponse.StatementResponse = new StatementResponse();
stmtTransResponse.StatementResponse.Currency = CurrencyEnum.USD;
stmtTransResponse.StatementResponse.BankAccountFrom = new BankAccount();
stmtTransResponse.StatementResponse.BankAccountFrom.BankId = "1111111";
stmtTransResponse.StatementResponse.BankAccountFrom.AccountId = "1111111111111";
stmtTransResponse.StatementResponse.BankAccountFrom.AccountType = AccountEnum.CHECKING;
stmtTransResponse.StatementResponse.BankTransactionList = new BankTransactionList();
stmtTransResponse.StatementResponse.BankTransactionList.StartDate = "20200601000000";
stmtTransResponse.StatementResponse.BankTransactionList.EndDate = "20200611000000";
StatementTransaction transaction1 = new StatementTransaction();
transaction1.TransactionType = TransactionEnum.DEBIT;
transaction1.PostedDate = "20200611000000";
transaction1.TransactionAmount = "-12";
transaction1.FinancialInstitutionTransactionId = "1111111111111111111111111";
transaction1.Name = "bbbbbbbbbbbbbbbbbbbbbbb";
StatementTransaction transaction2 = new StatementTransaction();
transaction2.TransactionType = TransactionEnum.CREDIT;
transaction2.PostedDate = "20200611000000";
transaction2.TransactionAmount = "22222.11";
transaction2.FinancialInstitutionTransactionId = "2222222222222222222222222222";
transaction2.Name = "wwwwwwwwwwwwwwwwwwwwwwww";
stmtTransResponse.StatementResponse.BankTransactionList.StatementTransactions.Add(transaction1);
stmtTransResponse.StatementResponse.BankTransactionList.StatementTransactions.Add(transaction2);
stmtTransResponse.StatementResponse.LedgerBalance = new LedgerBalance();
stmtTransResponse.StatementResponse.LedgerBalance.BalanceAmount = "+2222.42";
stmtTransResponse.StatementResponse.LedgerBalance.DateAsOf = "20200611000000";
stmtTransResponse.StatementResponse.AvailableBalance = new AvailableBalance();
stmtTransResponse.StatementResponse.AvailableBalance.BalanceAmount = "+222222.42";
stmtTransResponse.StatementResponse.AvailableBalance.DateAsOf = "20200611000000";
document.Save(outputDir + @"newOfxResponseBankStatement.xml", OfxVersionEnum.V2x);
document.Save(outputDir + @"newOfxResponseBankStatement.sgml", OfxVersionEnum.V1x);
InlineXbrlDocument document = new InlineXbrlDocument(XbrlFilePath + @"account_1.html");
List<InlineFact> inlineFacts = document.Facts;
List<Context> contexts = document.Contexts;
List<Unit> units = document.Units;
XbrlDocument document = new XbrlDocument(XbrlFilePath + @"IdScopeContextPeriodStartAfterEnd.xml");
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[0];
List<Fact> facts = xbrlInstance.Facts;
SchemaRefCollection schemaRefs = xbrlInstance.SchemaRefs;
List<Context> contexts = xbrlInstance.Contexts;
List<Unit> units = xbrlInstance.Units;
InlineXbrlDocument document = new InlineXbrlDocument(XbrlFilePath + @"account_1.html");
document.Validate();
if (document.ValidationErrors.Count > 0)
{
List<ValidationError> validationErrors = document.ValidationErrors;
}
XbrlDocument document = new XbrlDocument(XbrlFilePath + @"IdScopeContextPeriodStartAfterEnd.xml");
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[0];
xbrlInstance.Validate();
if(xbrlInstance.ValidationErrors.Count > 0)
{
List<ValidationError> validationErrors = xbrlInstance.ValidationErrors;
}
XbrlDocument document = new XbrlDocument(XbrlFilePath + @"IdScopeContextPeriodStartAfterEnd.xml");
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[0];
xbrlInstance.Validate();
if (xbrlInstance.ValidationErrors.Count > 0)
{
foreach (ValidationError validationError in xbrlInstance.ValidationErrors)
{
if(validationError.Code == ValidationErrorCode.ContextPeriodStartAfterEnd)
{
ContextValidationError contextValidationError = validationError as ContextValidationError;
Console.WriteLine("Validation error: end date is before start date in context " + contextValidationError.Object.Id);
}
else
{
Console.WriteLine("Find validation error:" + validationError.Message);
}
}
}
XbrlDocument document = new XbrlDocument(XbrlFilePath + @"IdScopeContextPeriodStartAfterEnd.xml");
XbrlInstanceCollection xbrlInstances = document.XbrlInstances;
XbrlInstance xbrlInstance = xbrlInstances[0];
xbrlInstance.Validate();
if (xbrlInstance.ValidationErrors.Count > 0)
{
foreach(ValidationError validationError in xbrlInstance.ValidationErrors)
{
Console.WriteLine("Find validation error:" + validationError.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment