![]() | |
General Ledger Workflows |
General Ledger work-flows:
Receipts “ Apply To: Selected Items ” Work-flow
Due to technical limitations, the Epic SDK cannot directly implement the work-flow found when inserting a new Receipt with the “ Apply To:” option set to “ selected items.” Instead, a new method (Get_GeneralLedger_ReceiptDefaultApplyCreditsToDebits) was created that allows the user to update an existing Receipt to add an “ Apply To: Selected Items ” entry. Following is a description of the work-flow and then sample code demonstrating how the work-flow works when using a debit and a credit detail item.
Work-flow steps:
1. If the user wants to create a new Receipt that only has one “ Apply To: Selected Items ” detail item, the user needs to at this point create a new Receipt with a dummy detail item that will be deleted when the Selected Items detail item is added.
2. Call the “Get_GeneralLedger_ReceiptDefaultApplyCreditsToDebits” method with the Receipt number of the Receipt you wish to add an “ Apply to: Selected Items ” detail item and a detail item containing a DebitCreditOption of either Debit or Credit, the Agency which is associated with the Receipt, the amount of the Receipt, with ApplyTo = “ Selected Items,” a description, and the Account Lookup Code and Type.
3. You will now have a Receipt object with a new Detail Item (that is automatically set to insert when the Receipt object is updated). If you created a new Receipt with a dummy detail item, the dummy detail item should be set to delete so that it is deleted when the Receipt is updated. The steps are different if the Detail Item to be added is a debit or credit.
4. Debit: Select the credit you wish to apply the debit to and in the payments collection add a new payment with “ ApplyToDebitTransactionID = -1”. Enter whether it is a full or partial payment, and add how much the payment is for partial payments.
5. Credit: Find the new credit that was added and in the payments collection add a new payment with “ ApplyToDebitTransactionID = [ID of the debit item you wish to apply to]”. This can again be a full or partial payment.
6. Update the Receipt.
![]() |
---|
The sample code is just an automated example of how this work-flow can work without user input. It is highly recommended that this work-flow be tied into some form of interface that takes user input, especially when selecting the debit or debit item that the payment should be applied to. |
' work-flow for Inserting a Receipt with one "Apply To: Selected Items" detail item for a DEBIT type detail item. Code is in Visual Basic 2008 written in Visual Studio 2008.
1Class Sample 2 3 'Workflow for Inserting a Receipt with one "Apply To: Selected Items" detail item for a DEBIT type detail item. Code is in Visual Basic 2008 written in Visual Studio 2008. 4 Import statement 5 Imports GeneralLedger = MYPROJECT.schemas.appliedsystems.com.epic.sdk._2011._01._generalledger 6 Imports SDKv1 = MYPROJECT.schemas.appliedsystems.com.epic.sdk._2011._01 7 8 'Initializing Client and Header 9 oClientV1 = New EpicSDK_2017_02Client 10 oHeader = New schemas.appliedsystems.com.epic.sdk._2009._07.MessageHeader 11 12 oHeader.DatabaseName = "MY DATABASE" 13 'Use the name of the Epic product database (usually defaulted to Epic) 14 15 oHeader.AuthenticationKey = "MY AUTHENTICATION KEY" 16 'Authentication key can be obtained using the license utility in the Central server Software directory 17 18 'Initializing Receipt Object 19 Dim oDat As New GeneralLedger.Receipt 20 21 oDat.DetailValue = New GeneralLedger._receipt.Detail 22 oDat.DetailValue.DetailItemsValue = New GeneralLedger._receipt._detail.DetailItems 23 oDat.DetailValue.DetailItemsValue.Add(New GeneralLedger._receipt._detail.DetailItem) 24 25 oDat.DetailValue.DetailItemsValue.Item(0).DebitCreditOption = New MYPROJECT.schemas.appliedsystems.com.epic.sdk._2009._07._common.OptionType 26 27 'Setting Values for Inserting the Receipt + Dummy detail item 28 oDat.BankAccountNumberCode = 124 29 oDat.ReceiptAccountingMonth = 201009 30 oDat.ReceiptDescription = "Test Selected Items Debit Workflow Receipt" 31 oDat.ReceiptEffectiveDate = "12/7/2010" 32 oDat.SuspendedReceipt = True 33 oDat.DetailValue.DetailItemsValue.Item(0).DebitCreditOption.OptionName = "Debit" 34 oDat.DetailValue.DetailItemsValue.Item(0).DebitCreditOption.Value = 0 35 oDat.DetailValue.DetailItemsValue.Item(0).Amount = 100 36 oDat.DetailValue.DetailItemsValue.Item(0).ApplyTo = "Account" 37 oDat.DetailValue.DetailItemsValue.Item(0).DetailItemAccountLookupCode = "MY ACCOUNT LOOKUP CODE" 38 39 oDat.DetailValue.DetailItemsValue.Item(0).Description = "Test Selected Items Workflow Dummy Detail Item" 40 41 oDat.DetailValue.DetailItemsValue.Item(0).StructureAgencyCode = "MY AGENCY" 42 oDat.DetailValue.DetailItemsValue.Item(0).StructureBranchCode = "MY BRANCH" 43 44 'Inserting Receipt with Dummy detail item 45 Dim StoreReceiptID As Integer 'Need to store the Receipt ID from the inserted receipt for the next steps method 46 StoreReceiptID = oClientV1.Insert_GeneralLedger_Receipt(oHeader, odat) 47 48 'Creating a detail item to pass to the Get_Default method 49 Dim oGet As New SDKv1._get._generalledger.ReceiptGetResult 50 Dim oDetail As New GeneralLedger._receipt._detail.DetailItem 51 52 oDetail.DebitCreditOption = New MYPROJECT.schemas.appliedsystems.com.epic.sdk._2009._07._common.OptionType 53 54 oDetail.DebitCreditOption.OptionName = "Debit" 55 oDetail.DebitCreditOption.Value = 0 56 57 oDetail.ApplyToSelectedItemsApplyCreditsToDebits = New GeneralLedger._receipt._detail._detailitem.ApplyCreditsToDebits 58 59 oDetail.ApplyToSelectedItemsApplyCreditsToDebits.AgencyCode = "MYAGENCY" 60 oDetail.Amount = 100 61 oDetail.ApplyTo = "Selected Items" 62 oDetail.Description = "test selected items debit workflow detail item" 63 oDetail.DetailItemAccountLookupCode = "MY ACCOUNT LOOKUP CODE" 64 oDetail.DetailItemType = "MY ACCOUNT TYPE" 65 66 oGet = oClientV1.Get_GeneralLedger_ReceiptDefaultApplyCreditsToDebits(oHeader, StoreReceiptID, oDetail) 67 68 If oGet.Receipts.Count > 0 Then 69 odat = oGet.Receipts(Integer.Parse(Me.txtGetIndex.Text)) 70 End If 71 72 'Updating the Receipt to delete the dummy detail item and add the Selected Items detail item. 73 74 odat.DetailValue.DetailItemsValue.Item(1).Flag = schemas.appliedsystems.com.epic.sdk._2011._01._generalledger._receipt._detail._detailitem.Flags.Delete 75 odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Credits.Item(0).Payments.Add(New TestJournalEntries.schemas.appliedsystems.com.epic.sdk._2011._01._generalledger._receipt._detail._detailitem._applycreditstodebits._common.PaymentItem) 76 odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Credits.Item(0).Payments.Item(0).ApplyToDebitTransactionID = -1 77 odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Credits.Item(0).Payments.Item(0).FullPayment = True 78 79 oClientV1.Update_GeneralLedger_Receipt(oHeader, odat) 80 81 MessageBox.Show("Methods Finished - Receipt ID = " + StoreReceiptID.ToString()) 82 83 'Workflow for Inserting a Receipt with one "Apply To: Selected Items" detail item for a CREDIT type detail item. 84 'Import statement 85 Imports GeneralLedger = MYPROJECT.schemas.appliedsystems.com.epic.sdk._2011._01._generalledger 86 Imports SDKv1 = MYPROJECT.schemas.appliedsystems.com.epic.sdk._2011._01 87 88 'Initializing Client and Header 89 oClientV1 = New EpicSDK_2017_02Client 90 oHeader = New schemas.appliedsystems.com.epic.sdk._2009._07.MessageHeader 91 92 oHeader.DatabaseName = "MY DATABASE" 93 'Use the name of the Epic product database (usually defaulted to Epic) 94 95 oHeader.AuthenticationKey = "MY AUTHENTICATION KEY" 96 'Authentication key can be obtained using the license utility in the Central server Software directory 97 98 'Initializing Receipt Object 99 Dim odat As New GeneralLedger.Receipt 100 odat.DetailValue = New GeneralLedger._receipt.Detail 101 odat.DetailValue.DetailItemsValue = New GeneralLedger._receipt._detail.DetailItems 102 odat.DetailValue.DetailItemsValue.Add(New GeneralLedger._receipt._detail.DetailItem) 103 104 odat.DetailValue.DetailItemsValue.Item(0).DebitCreditOption = New MYPROJECT.schemas.appliedsystems.com.epic.sdk._2009._07._common.OptionType 105 106 'Setting Values for Inserting the Receipt + Dummy detail item 107 odat.BankAccountNumberCode = 124 108 odat.ReceiptAccountingMonth = 201009 109 odat.ReceiptDescription = "Test Selected Items Credit Workflow Receipt" 110 odat.ReceiptEffectiveDate = "12/7/2010" 111 odat.SuspendedReceipt = True 112 odat.DetailValue.DetailItemsValue.Item(0).DebitCreditOption.OptionName = "Debit" 113 odat.DetailValue.DetailItemsValue.Item(0).DebitCreditOption.Value = 0 114 odat.DetailValue.DetailItemsValue.Item(0).Amount = 100 115 odat.DetailValue.DetailItemsValue.Item(0).ApplyTo = "Account" 116 odat.DetailValue.DetailItemsValue.Item(0).DetailItemAccountLookupCode = "MY ACCOUNT LOOKUP CODE" 117 odat.DetailValue.DetailItemsValue.Item(0).Description = "Test Selected Items Workflow Dummy Detail Item" 118 odat.DetailValue.DetailItemsValue.Item(0).StructureAgencyCode = "MY AGENCY" 119 odat.DetailValue.DetailItemsValue.Item(0).StructureBranchCode = "MY BRANCH" 120 121 'Inserting Receipt with Dummy detail item 122 Dim StoreReceiptID As Integer 'Need to store the Receipt ID from the inserted receipt for the next steps method 123 StoreReceiptID = oClientV1.Insert_GeneralLedger_Receipt(oHeader, odat) 124 125 'Creating a detail item to pass to the Get_Default method 126 Dim oGet As New SDKv1._get._generalledger.ReceiptGetResult 127 Dim oDetail As New GeneralLedger._receipt._detail.DetailItem 128 129 oDetail.DebitCreditOption = New MYPROJECT.schemas.appliedsystems.com.epic.sdk._2009._07._common.OptionType 130 131 oDetail.DebitCreditOption.OptionName = "Credit" 132 oDetail.DebitCreditOption.Value = 1 133 134 oDetail.ApplyToSelectedItemsApplyCreditsToDebits = New GeneralLedger._receipt._detail._detailitem.ApplyCreditsToDebits 135 136 oDetail.ApplyToSelectedItemsApplyCreditsToDebits.AgencyCode = "MY AGENCY" 137 oDetail.Amount = 100 138 oDetail.ApplyTo = "Selected Items" 139 oDetail.Description = "test selected items credit workflow detail item" 140 oDetail.DetailItemAccountLookupCode = "MY ACCOUNT LOOKUP CODE" 141 oDetail.DetailItemType = "Client" 142 143 oGet = oClientV1.Get_GeneralLedger_ReceiptDefaultApplyCreditsToDebits(oHeader, StoreReceiptID, oDetail) 144 145 If oGet.Receipts.Count > 0 Then 146 odat = oGet.Receipts(Integer.Parse(Me.txtGetIndex.Text)) 147 End If 148 149 'Updating the Receipt to delete the dummy detail item and add the Selected Items detail item. 150 odat.DetailValue.DetailItemsValue.Item(1).Flag = schemas.appliedsystems.com.epic.sdk._2011._01._generalledger._receipt._detail._detailitem.Flags.Delete 151 odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Credits.Item(odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Credits.Count - 1).Payments.Add(New MYPROJECT.schemas.appliedsystems.com.epic.sdk._2011._01._generalledger._receipt._detail._detailitem._applycreditstodebits._common.PaymentItem) 152 odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Credits.Item(odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Credits.Count - 1).Payments.Item(0).FullPayment = True 153 154 'Looping through the debits to find the last non-pending debit 155 '(this does not have to be done, the most likely workflow is to create a GUI to allow the user to select the debit) 156 Dim counter As Integer 157 counter = 0 158 Dim debitItem As Integer 159 While (counter < odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Debits.Count) 160 161 If(odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Debits.Item(counter).Pending = False) Then 162 debitItem = counter 163 End If 164 counter = counter + 1 165 End While 166 odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Credits.Item(odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Credits.Count - 1).Payments.Item(0).ApplyToDebitTransactionID = odat.DetailValue.DetailItemsValue.Item(2).ApplyToSelectedItemsApplyCreditsToDebits.Debits.Item(debitItem).TransactionID 167 168 oClientV1.Update_GeneralLedger_Receipt(oHeader, odat) 169 170 MessageBox.Show("Methods Finished - Receipt ID = " + StoreReceiptID.ToString()) 171 172End Class