Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
KBizRules Class
Message
 
To
22/12/2000 23:33:33
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Title:
Miscellaneous
Thread ID:
00456530
Message ID:
00456581
Views:
27
>>I can send the ExecuteEvent method code of my ImportCompanyData object in a >few days if it will help. I just need to document it < g >.
>
>That might be helpful, if you get the chance.

I'll try to get that done in the next couple of days.

>>- You can't have an empty customer name.
>>- Make sure the customer's sate is in the states table.
>>- If a customer's credit limit is $500, and their purchase is $600, warn the >operator.
>
>The rules you mention... i like to group them in with data rules. Which seem to belong in kbizrules or in the data engine.
>
>The rules i'm questioning the placement of are more like :
>- calculation of sales commission
>- setting a companies credit rating
>- determining the value of an account

As far as the sales commission goes, it sounds like you may have the following entities collaborating:

Customer
InvoiceHeader
InvoiceDetail
Salesman

An event object may work for this (and again, this is my first work with MM or OOP < g >). Something like this, given an InvoiceID, and SalesPersonID:
LPARAMETERS tnInvoiceID, tnSalesPersonID

LOCAL lnCommission

lnCommission = 0

*-- Load the specified Invoice Record and Salesperson records
IF oInvoice.Load( tnInvoiceID ) = FILE_OK AND ;
   oSalesPerson.Load( tnSalesPersonID ).Load = FILE_OK
   LOCAL lnCustomerID

   *-- From the Invoice object, get the customer ID
   lnCustomerID = oInvoice.GetCustomerID()

   *-- Load the customer's record
   IF oCustomer.Load( lnCustomerID ) = FILE_OK
      *-- Do salespeople get commissions for this customer?
      IF oCustomer.Commissionable()
         *-- Load the InvoiceDetail records (items on the invoice)
         IF oInvoiceDetail.Load( THIS.nInvoiceID ) = FILE_OK
            LOCAL lnTotal

            *-- The total salesperson gets a commission on.  
            lnTotal = oInvoiceDetail.GetCommissionableTotal   (THIS.nSalesPersonID )

            lnCommision = lnTotal * oSalesPerson.GetCommisionRate() 
         ENDIF
      ENDIF
   ENDIF
ENDIF

RETURN lnCommission
I think the key is to keep each entity object focused only on the data in the corresponding table. When you need to use data from more than one table, use and event object.
RETURN lnCommission
Chris McCandless
Red Sky Software
Previous
Reply
Map
View

Click here to load this message in the networking platform