Forum Discussion
RobbSalzmann
2 days agoValued Contributor II
It might be better to use DecimalAndNoData objects to assign JournalLineItem.DebitAmount and JournalLineItem.CreditAmount. I don't think you can directly assign a decimal value to these.
.DebitAmount = New DecimalAndNoData(0.0D, True),
.CreditAmount = New DecimalAndNoData(-150, False)
Putting it all together:
Sub CreateJournal(ByVal sessionInfo As SessionInfo)
Try
' member IDs
Dim entityId As Integer = BRApi.Finance.Members.GetMemberId(sessionInfo, DimType.Entity.Id, "100_US")
Dim debitAccountId As Integer = BRApi.Finance.Members.GetMemberId(sessionInfo, DimType.Account.Id, "10220030")
Dim creditAccountId As Integer = BRApi.Finance.Members.GetMemberId(sessionInfo, DimType.Account.Id, "10220050")
Dim flowId As Integer = BRApi.Finance.Members.GetMemberId(sessionInfo, DimType.Flow.Id, "EndBal")
Dim intercompanyId As Integer = BRApi.Finance.Members.GetMemberId(sessionInfo, DimType.IC.Id, "None")
' journal header
Dim journalHeader As New JournalHeader() With {
.Name = "Test_Journal",
.Description = "This is a test journal",
.WorkflowProfileID = sessionInfo.WorkflowClusterPk.ProfileKey,
.JournalStatus = JournalStatus.Working,
.IsSingleEntity = False,
.MemberIds = New KeyedByDimTypeList(Of Integer)() With {
.Scenario = sessionInfo.WorkflowClusterPk.ScenarioKey,
.Time = sessionInfo.WorkflowClusterPk.TimeKey
}
}
' line items
Dim debitLineItem As New JournalLineItem() With {
.EntityId = entityId,
.AccountId = debitAccountId,
.FlowId = flowId,
.ICId = intercompanyId,
.DebitAmount = New DecimalAndNoData(150, False),
.CreditAmount = New DecimalAndNoData(0.0D, True)
}
Dim creditLineItem As New JournalLineItem() With {
.EntityId = entityId,
.AccountId = creditAccountId,
.FlowId = flowId,
.ICId = intercompanyId,
.DebitAmount = New DecimalAndNoData(0.0D, True),
.CreditAmount = New DecimalAndNoData(-150, False)
}
' line items list
Dim journalLineItems As New List(Of JournalLineItem) From {
debitLineItem,
creditLineItem
}
' Create and save the journal
Dim journal As New Journal(journalHeader, journalLineItems)
BRApi.Journals.Metadata.SaveJournalOrTemplateUsingIds(sessionInfo, journal, False, True)
Catch ex As Exception
Throw ErrorHandler.LogWrite(sessionInfo, New XFException(sessionInfo, ex))
End Try
End Sub
Curious why you are making the credit amount negative?...
Related Content
- 3 years ago
- 4 years ago
- 4 years ago
- 2 years ago
- 2 years ago