LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Help with BRAINscript fragment concerning call duration splitting among charge zones

    Employee
    Posted 04-17-2013 10:32

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Theo

    I have the following commands in a filter node:

    DURATION_ROUNDED_EDITED=(DURATION_ROUNDED*1000).lo ng()
    END_DATETIME= dateTimeAdjust(timestamp(DATE,TIME),DURATION_ROUND ED_EDITED.long(),"milliseconds")
    SPLIT_DATETIME=END_DATETIME.str().split(" ")
    END_DATE=getItem(SPLIT_DATETIME,0).date("CCYY-MM-DD")
    END_TIME=getItem(SPLIT_DATETIME,1).left(8).time("H H:MM:SS")
    END_DOW=weekday(END_DATE)

    if PEAK_FLAG=="Peak" then #PEAK INITIAL ZONE CATEGORY
    {
    if (END_DOW==6 or ((END_TIME<"08:00:00".time("HH:MM:SS") or END_TIME>="20:00:00".time("HH:MM:SS")) and END_DOW<>0)) then # Saturday or off-peak hours check
    {
    END_PEAK_FLAG="Off-Peak 1"
    if END_TIME>="20:00:00".time("HH:MM:SS") then
    {
    CHARGEABLE_SECONDS_ALPHA=timeSubtract("20:00:00".t ime("HH:MM:SS"),TIME)
    CHARGEABLE_SECONDS_BETA=timeSubtract(END_TIME,"20: 00:00".time("HH:MM:SS"))
    }
    }
    else
    {
    END_PEAK_FLAG=="Peak"
    CHARGEABLE_SECONDS_ALPHA=DURATION_ROUNDED.double()
    }
    }
    else if PEAK_FLAG=="Off-Peak 1" then #OFF-PEAK 1 INITIAL ZONE CATEGORY
    {
    if END_DOW==0 then # Sunday flag
    {
    END_PEAK_FLAG="Off-Peak 2 Sunday"
    CHARGEABLE_SECONDS_ALPHA= (timeSubtract("23:59:59".time("HH:MM:SS"),TIME)+1) .double #Seconds with first Tariff
    CHARGEABLE_SECONDS_BETA= (DURATION_ROUNDED-CHARGEABLE_SECONDS_ALPHA).double() #Seconds with second Tariff
    }
    else if (END_TIME>="08:00:00".time("HH:MM:SS") and END_TIME<"20:00:00".time("HH:MM:SS") and END_DOW<>6) then # Peak hours check
    {
    END_PEAK_FLAG="Peak"
    CHARGEABLE_SECONDS_ALPHA=timeSubtract("08:00:00".t ime("HH:MM:SS"),TIME).double()
    CHARGEABLE_SECONDS_BETA=timeSubtract(END_TIME,"08: 00:00".time("HH:MM:SS")).double()
    }
    else
    {
    END_PEAK_FLAG=="Off-Peak 1"
    CHARGEABLE_SECONDS_ALPHA=DURATION_ROUNDED.double()
    }
    }

    else if PEAK_FLAG=="Off-Peak 2 Sunday" then #OFF-PEAK 2 INITIAL ZONE CATEGORY
    {
    if END_TIME<"08:00:00".time("HH:MM:SS") and END_DOW<>0 then
    {
    END_PEAK_FLAG="Off-Peak 1"
    CHARGEABLE_SECONDS_ALPHA=timeSubtract("23:59:59".t ime("HH:MM:SS"),TIME)+1
    CHARGEABLE_SECONDS_BETA=timeSubtract(END_TIME,"08: 00:00".time("HH:MM:SS")).double()
    }
    else
    {
    END_PEAK_FLAG=="Off-Peak 2 Sunday"
    CHARGEABLE_SECONDS_ALPHA=DURATION_ROUNDED.double()
    }
    }

    else
    {
    END_PEAK_FLAG=="Short Call"
    }

    CHARGEABLE_DURATION_DIFFERENCE = (CHARGEABLE_SECONDS_ALPHA+CHARGEABLE_SECONDS_BETA-DURATION_ROUNDED.round(0))

    emit *,END_DATETIME,END_DATE,END_TIME,END_DOW,END_PEAK_ FLAG,CHARGEABLE_SECONDS_ALPHA,CHARGEABLE_SECONDS_B ETA,CHARGEABLE_DURATION_DIFFERENCE



    I am trying to identify and split a call among specified time zones(peak/off-peak) where applicable.


    The problem lies with the highlighted statements (Off-peak 2 Sunday "else" fragment).
    Even if a call occurs on a normal Sunday and ends in the same Sunday, this code seems to allocate it in Off-peak 1 zone, whereas it should remain in Off-peak 2 zone.
    Can you help me?

    When I try to alter the if...else commands a bit, a "double" instead of "long" error occurs as well.

    I am sorry for the rarther "messy" script.
    Thank you.

    Input Fields:

    CARRIER_NAME (str) B_NUMBER(str) DURATION_ROUNDED (double) DURATION_ACTUAL(double) CALL_TYPE (Originating/Terminating - str) A_NUMBER(str) DATE(date) TIME(time) EVENT_COST_NO_VAT(double) EVENT_COST_NO_VAS(double) ROUNDING_RULE(str)


  • 2.  RE: Help with BRAINscript fragment concerning call duration splitting among charge zones

    Employee
    Posted 04-17-2013 10:34

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Theo

    I also have these fields in the input.
    DOW (int) PEAK_FLAG (str) RATE_PER_MIN (double) TRANSIT_FLAG (str) DIFFERENCE_FROM_POLICY (double)


  • 3.  RE: Help with BRAINscript fragment concerning call duration splitting among charge zones

    Employee
    Posted 04-29-2013 10:24

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rboccuzzi

    Theo, my apologies for taking a bit of time to get to this question. In the future, if you can post a graph (instead of code and a written list of fields) along with your question, that could be helpful (and you might get someone else to response quicker). I have attached a graph I spent a bit of time creating based on your above description, and I am not sure what your issue is, as it seems to work as designed.

    I took your code above, and cleaned it up a bit, fixed indents that get lost when pasting into the forum directly, and fixed a few spaces in odd places (not sure if this was introduced into the pasting into the forum or if this was actually in your code), and created a stub of data fields you listed. If this isn't showing you what you need, if you can in the future attach a graph similar to the one I have attached, with sample data that is not behaving as you think it should, might make it easier to show your problem.

    If you aren't aware, you can open up a data pin in the BrdViewer and highlight a row or two of data, and select "Copy as Static Data" from the edit menu (or press Ctrl-D). You can then go back to BRE and paste that into BRE, and you will now have a Static Data node with all the fields and a sample of the data. You can then modify and obfuscate so that you aren't revealing anything inappropriate, but wire it up to show the issue you are having, can give us here in the community something we can work with to help you more efficiently.

    Cheers
    Rich
    Attachments:
    TestPeak.brg


  • 4.  RE: Help with BRAINscript fragment concerning call duration splitting among charge zones

    Employee
    Posted 05-01-2013 05:30

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Theo

    Dear Rich,
    sorry for the long code that I posted instead of the node itself.
    Also, I am pretty sure that the random blanks appearing were created due to the "Paste" command during the thread creation.

    Eventually my problem was nothing more but a simple "==" instead of "=" , thus prohibiting the variable to change values every time, rather keeping only the initial one.
    (This can be located in the last "else" branch of the above code)

    Once again, sorry for the false alarm.
    Cheers