Hi,
I have one app where I want to implement a subscription system like this:
-customers has their subscriptions which are billed in a specific day of the month,
- the billing cycle is monthly
- the billing period can be: Previous month, Current Month, Next Month
What I want to accomplish:
IF the billing day is the 15th day of the month than:
---FOR billed_period = Previous Month ------>the result should be Begin_of_billed_period=01.08.2014 -----------End_of_billed_period=31.08.2014 (i took as example 15.09.2014)
---FOR billed_period = Current Month ------> the result should be Begin_of_billed_period=01.09.2014 -----------End_of_billed_period=30.09.2014)
---FOR billed_period = Next Month ------> the result should be Begin_of_billed_period=01.10.2014 -----------End_of_billed_period=31.10.2014)
For this I added this in attribute in BO:
Begin_of_billed_period
End_of_billed_period
Attr_Billing_Cycle (with option: Monthly)
Billed_Month (with options: Previous Month, Current Month, Next Month)
the rule for Previous month is like this:
If Bo.Attr_Billing_Cycle='Monthly' AND BO.Billed_Month='Previous Month' Then
BO.Begin_of_Billed_period=DATE(FIRST_DAY_OF_PREV_MONTH(CURRENT_DATE),MONTH(MONT_ADD(CURRENT_DATE,-1)),YEAR(MONTH_ADD(CURRENT_DATE,-1)))
BO.End_of_Billed_period=DATE(LAST_DAY_OF_PREV_MONTH(CURRENT_DATE),MONTH(MONT_ADD(CURRENT_DATE,-1)),YEAR(MONTH_ADD(CURRENT_DATE,-1)))
the rule for current month is like this:
If Bo.Attr_Billing_Cycle='Monthly' AND BO.Billed_Month='Current Month' Then
BO.Begin_of_Billed_period=DATE(FIRST_DAY_OF_CURRENT_MONTH(CURRENT_DATE),MONTH(MONT_ADD(CURRENT_DATE,-1)),YEAR(MONTH_ADD(CURRENT_DATE,-1)))
BO.End_of_Billed_period=DATE(LAST_DAY_OF_CURRENT_MONTH(CURRENT_DATE),MONTH(MONT_ADD(CURRENT_DATE,-1)),YEAR(MONTH_ADD(CURRENT_DATE,-1)))
the rule for next month is like this:
If Bo.Attr_Billing_Cycle='Monthly' AND BO.Billed_Month='Next Month' Then
BO.Begin_of_Billed_period=DATE(FIRST_DAY_OF_NEXT_MONTH(CURRENT_DATE),MONTH(MONT_ADD(CURRENT_DATE,-1)),YEAR(MONTH_ADD(CURRENT_DATE,-1)))
BO.End_of_Billed_period=DATE(LAST_DAY_OF_NEXT_MONTH(CURRENT_DATE),MONTH(MONT_ADD(CURRENT_DATE,-1)),YEAR(MONTH_ADD(CURRENT_DATE,-1)))
These rules are not working because nothing is happening. Maybe my logic is wrong.
If someone developed such a system, please give me some advice,
Any help will be greatly appreciated.
Thank you [/b]