Script: Level Show hourly rate

The script shows in a message box at which level the hourly rate of the current service was calculated

Product line

Standard

|

Expert

Operating mode

CLOUD ABO

|

ON-PREMISES

Modules

Services & CRM

Budget & Phases

Purchases

Resource Planning

Business Intelligence

Created: 22.09.2014
Updated: 10.10.2024 | Script replaced. Consider only active editorsPhaseLinks analogous to business logic.

Content

Displays in a message box at which level the hourly rate of the current service was calculated. Base on the priority list according to article The rate system.

Version

All Vertec versions

Execute

On a single service (open or charged)

Scripting

ShowLevelhourrate.py

Script text

# coding: windows-1252
#
#---Description: Level Show hourly rate
# Class: Performance
#   CondExpression:
#   ObjectScript: Y
#   ContainerScript: N
#   EventType: None
#   EventClass:
#   EventMembers:
#   ExtendedRights: N
#---Shows at which level the hourly rate is
#---of a service.
#---2014-09-18, FG: created.
#---2014-09-22, FG: Formatting adjusted (whitespace in enumeration).
#---2014-10-29, FG: in the rate table Costrate changed to Feerateext
#   Version = 102
#
import vtcapp

# shows a MessageBox marked on the
# Priority level
def showPriority(level):
    msg = “1. Priority: Service type on phase”
    if level == 1:
        msg += “\t\t<----”
    msg += “\n2. Priority: user on phase”
    msg += “\n\t1. Explicitly set rate”
    if level == 2:
        msg += “\t\t<----”
    msg += “\n\t2. Set level”
    if level == 3:
        msg += “\t\t<----”
    msg += “\n3. Priority: Default to Phase”
    if level == 4:
        msg += “\t\t<----”
    msg += “\n4. Priority: user on project”
    msg += “\n\t1. Explicitly set rate”
    if level == 5:
        msg += “\t\t<----”
    msg += “\n\t2. Set level”
    if level == 6:
        msg += “\t\t<----”
    msg += “\n5. Priority: Default on project”
    if level == 7:
        msg += “\t\t<----”
    msg += “\n6. Priority: Default to project type”
    if level == 8:
        msg += “\t\t<----”
    msg += “\n7. Priority: Rate table”
    if level == 9:
        msg += “\t\t<----”
    msg += “\n8. Priority: Default to user”
    if level == 10:
        msg += “\t\t<----”
    msg += “\n 9.Priority: 0.00”
    if level == 11:
        msg += “\t\t<----”
    vtcapp.msgbox(msg)

# returns the rate table of a service
def getTariff table(service):
    if power.type:
        for obj in performance.typ.tariffs:
            if obj.currency == output.currency:
                # Rate table found
                return obj

    for obj in service.currency.tariffs:
        if not obj.activity:
            # Rate table found
            return obj

    return None

def main():
    service = argobject

    # When a phase is assigned
    if power.phase:
        # 1. Priority: Service type on phase
        if power.type and power.eval(“phase.activityphaselink->select(name=self.typ.code).approachExt->first”):
            showPriority(1)
            return

        # 2.1 Priority: User on phase -> Explicitly Set Rate
        if leistung.eval(“phase.processorPhase->select(active)->select(active)->select(employer=self.processor).stroketext->first”):
            showPriority(2)
            return
            
         # 2.2 Priority: User on phase -> Set Level
        if leistung.eval(“phase.processorPhases->select(active)->select(active)->select(employer=self.processor).processorlevel->first”):
            showPriority(3)
            return

        # 3. Priority: Default on Phase
        if power.phase.approachtext:
            showPriority(4)
            return

    # When a project is assigned
    if performance.project:
        # 4.1 Priority: User on project -> Explicitly set rate
        if leistung.eval(“project.controllerlinks->select(user=self.controller).controllertext->first”):
            showPriority(5)
            return
            
        # 4.2 Priority: User on project -> Set Level
        if leistung.eval(“project.editorlinks->select(“project.editor=self.editor).editorlevel->first”):
            showPriority(6)
            return

        # 5. Priority: Default on project
        if performance.project.approachtext:
            showPriority(7)
            return

        # 6. Priority: Default on project type
        if performance.project.type.approachtext:
            showPriority(8)
            return

        # 7. Priority: Rate table
        # Find rate table via type
        rate table = getTariff table(services)

        if rate table:
        # Search rate in rate table
            for obj in tariff table:
                if (obj.tariff level == service.project.tariff level) and (obj.processor level == service.processor level):
                    # Rate found
                    if obj.anatzext:
                        showPriority(9)
                        return

        # 8. Priority: Default to user
        if power.processor.approachtext:
            showPriority(10)
            return

        # 9. Priority: 0.00
        showPriority(11)

main()
Bitte wählen Sie Ihren Standort