Chapter 15: ADO Scripts for Rates
In this chapter, you see how to use ADO scripts to calculate the payment for each contribution approved by the editor. The computation is based on some input data present in meta document and other information from a local Access database. We also introduce the database structure for rates and other relevant information, the XML source element, and computation scripts needed to calculate the payment amount to the contributor. For completeness, you will see also how to update and complete some information about the contributor and the story when the editor approves the content.
Rating Process
In Chapter 13, you saw how script actions were applied during the publishing process. In this chapter, you investigate payment authorization.When the editor receives the stories from the contributor and approves them, he or she must calculate the amount due to the contributor based on the extent of content received. As you have seen previously (Chapter 12), the payment approval is started by the editor clicking the Filed button in the Desk view, which invokes a script action, AuthorizePayment.Filed and spiked are mutually exclusive states, since “spike” effectively stops publication or at least puts it on hold. The script sets the following data values in the XML document:
Sets the status to Filed
Updates the modificationTime
Completes the creator element: url and byline attributes
Sets the meta/@id and identifier
Completes the payment element
Some data is set and updated directly by the script without requiring additional information, whereas in other cases, such as payment element, the computation depends on lookup tables present in the contracts database.You could invoke the AuthorizePayment function in several ways. For example, you could explicitly use a task pane link command or a view button control. You could also intercept the OnAfterChange event for the status element, so that when it is set to Filed, it starts updating and setting the payment values. We’ve chosen this last approach in this chapter.