Breakout code can be implemented to force the load of the POS Popup screen on saving a sales order under specific conditions. In the following example, when the debtor belongs to a specific sales group saving a sales order displays the POS Popup:
1. |
Record Manage Breakouts |
2. |
Code to be added to the Form Loaded breakout point Public Function IsDebtorCashSale(SalesOrderObject) Dim SQL Dim rHwnd Dim ReturnValue ReturnValue = 0 With SalesOrderObject.Database
rHwnd = .StatementOpen(.ConnectionRead1,,,0) SQL = "SELECT CN_Group.Description " _ & "FROM CN_Group " _ & "JOIN CN_GroupLink ON (CN_Group.GroupID = CN_GroupLink.GroupID) " _ & "JOIN CN_Main ON (CN_Main.ProspectID = CN_GroupLink.ProspectID) " _ & "WHERE CN_Main.DebtorID = " & .FormatChar(SalesOrderObject.DebtorID) If .ExecuteSelect(CInt(rHwnd), SQL) = True Then .BindMem Cint(Rhwnd), 1, vbString Do While .FetchRow(Cint(rHwnd)) = True If Trim(UCase(.GetData(Cint(rHwnd),1))) = "CASH SALES" Then If ReturnValue = 0 Then ReturnValue = 1 End If ElseIf Trim(UCase(.GetData(Cint(rHwnd),1))) = "CASH ONLY" Then ReturnValue = 2 Exit Do End If Loop Else MsgBox "Error : " & .ErrorMessage End If .StatementClose(Cint(rHwnd)) End With IsDebtorCashSale = ReturnValue End Function
|
3. |
Code to be added to Sales Order Save Before breakout point Dim DebtorCashSaleType Dim TenderedResult DebtorCashSaleType = IsDebtorCashSale(SalesOrderObject) If DebtorCashSaleType > 0 Then TenderedResult = AmountTendered(SalesOrderObject, FormObject) If TenderedResult = 0 Then rtnCancel = True ElseIf (DebtorCashSaleType = 2 And TenderedResult <> 1) Then rtnCancel = True MsgBox "This debtor belongs to the CASH ONLY group." & vbcrlf & vbcrlf & "You must tender at least the invoice amount.", vbOkOnly + vbExclamation, "Insufficient Payment" End If End If End Sub
|
4. |
Create debtor groups Cash Sales and Cash Only in the Debtor Configuration Groups form. Attach relevant debtors to the appropriate group in the Main, Contacts tab of the debtor record
|
Copyright © 2012 Jiwa Financials. All rights reserved.