Skip to Content
author's profile photo Former Member
Former Member

Sales Order Additional Expenses

Problem: Would like to manipulate Document Additional Expenses in code with the UI-API before clicking on "Add" for the main form and adding the record, and without opening the "Expenses" form (3007). Creating an object with the DI API won't work because the order record has not yet been saved to the database so can't be retrieved and updated.

The reason this is needed is that the customer wants to create the additional expenses automatically based on the specifics of the order, e.g. the shipping method, tax code, etc. The customer does not want to have to open the expenses screen and manually enter the expenses for each sale. Also, the customer wants to see the total expenses before adding the order the first time.

Example: The sales order form (139) has an "Add Expenses" field with a golden arrow. Clicking the arrow opens an "Expenses" form (3007) where expenses can be added. In the case of a brand new order, these items are apparently stored by SBO in the DocumentsAdditionalExpenses object until the add button on form 139 is clicked and the record added.

Question: Is there a way in code using the UI-API, (not the DI-API) to access the DocumentsAdditionalExpenses of the new sales order? If not is there any other way to manipulate the expenses before the sale is added?

Thanks for your help.

Mel

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 10, 2005 at 10:39 PM

    Mel,

    I have achieved this but found it quite slow when you had about 20 or more products entered.

    I used the properties in inventory item to flag additional expenses ex1, ex2 or ex3 (In my case damage waiver and stamp duty). A formatted search would query this when an item is entered into a sales order and flag the additional expenses combo boxes in the matrix.

    The following code then queries every line or a single line in the matrix and inserts the calculated additional expenses.

    It then sums these amounts to show them separately on the order form.

    Hope this code below helps, but remember it is quite low. I'm trying to find a faster way at the moment. If you know of any please let me know.

    Cheers,

    Richard

    Private Sub Recalculate_Expenses()

    'This routine will calculate the Damage waiver and Stamp duty in an order/quote

    Dim DamageWaiverTotal As Double

    Dim StampDutyTotal As Double

    Dim DamageWaiverPercentage As Double

    Dim StampDutyPercentage As Double

    Dim oObject As Object

    oMatrix = oOrderForm.Items.Item("38").Specific

    DamageWaiverTotal = 0

    StampDutyTotal = 0

    For i = 1 To oMatrix.VisualRowCount

    oComboBox = oMatrix.Columns.Item("257").Cells.Item(i).Specific 'Line type combo box

    If oComboBox.Selected.Value = "" Then

    oItemText = oMatrix.Columns.Item("112").Cells.Item(i).Specific

    DamageWaiverTotal = DamageWaiverTotal + CDbl(Replace(oItemText.String, "AUD", ""))

    oItemText = oMatrix.Columns.Item("116").Cells.Item(i).Specific

    StampDutyTotal = StampDutyTotal + CDbl(Replace(oItemText.String, "AUD", ""))

    End If

    Next

    oItemText = oOrderForm.Items.Item("txtDamage").Specific

    oItemText.String = Format(DamageWaiverTotal, "$###,##0.00")

    oItemText = oOrderForm.Items.Item("txtSDamt").Specific

    oItemText.String = Format(StampDutyTotal, "$###,##0.00")

    End Sub

    Private Sub Recalculate_DamageWaiver_StampDuty(ByVal PerLine As Integer)

    'This routine will calculate the Damage waiver and Stamp duty in an order/quote

    Dim DamageWaiverTotal As Double

    Dim StampDutyTotal As Double

    Dim DamageWaiverPercentage As Double

    Dim StampDutyPercentage As Double

    Dim oObject As Object

    DamageWaiverPercentage = 0.06

    StampDutyPercentage = 0.0075

    oMatrix = oOrderForm.Items.Item("38").Specific

    DamageWaiverTotal = 0

    StampDutyTotal = 0

    For i = 1 To oMatrix.VisualRowCount

    If PerLine = 0 Or PerLine = i Then

    oComboBox = oMatrix.Columns.Item("257").Cells.Item(i).Specific 'Line type combo box

    If oComboBox.Selected.Value = "" Then

    'Damage Waiver

    oComboBox = oMatrix.Columns.Item("111").Cells.Item(i).Specific 'Damage waiver flag

    If oComboBox.Selected.Value <> "-1" Then

    oItemText = oMatrix.Columns.Item("21").Cells.Item(i).Specific 'Item total price exGST

    DamageWaiverTotal = CDbl(Replace(oItemText.String, "AUD", "")) * DamageWaiverPercentage

    oItemText = oMatrix.Columns.Item("112").Cells.Item(i).Specific 'Damage waiver Amt

    If CDbl(Replace(oItemText.String, "AUD ", "")) <> Math.Round(DamageWaiverTotal, 3) Then

    oItemText.Value = Math.Round(DamageWaiverTotal, 3)

    End If

    End If

    'Stamp Duty

    oComboBox = oMatrix.Columns.Item("115").Cells.Item(i).Specific 'Stamp duty flag

    If oComboBox.Selected.Value <> "-1" Then

    oItemText = oMatrix.Columns.Item("21").Cells.Item(i).Specific 'Item total price exGST

    StampDutyTotal = CDbl(Replace(oItemText.String, "AUD", "")) * StampDutyPercentage

    oItemText = oMatrix.Columns.Item("116").Cells.Item(i).Specific 'Stamp Duty Amt

    If CDbl(Replace(oItemText.String, "AUD ", "")) <> Math.Round(StampDutyTotal, 3) Then

    oItemText.Value = Math.Round(StampDutyTotal, 3)

    End If

    End If

    End If

    End If

    Next

    Recalculate_Expenses()

    End Sub

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.