A complex architectural problem with recurring payments and future events

I am looking for guidance on creating an elegant solution to what has become a bit of a challenge. Although I use Ruby (and Rails), I think that my problem is largely architectural, although my choice of language clearly affects suggestions related to libraries, etc. Therefore, the language remains relevant.

In any case, in short: my application contains objects representing memberships that belong to people who are members of fitness centers. Membership contains a number of recurring payments. Some memberships are automatically renewed at the end of the term, while others are not.

So, for example, you may have a membership that is for an initial period of one year and then renewed a month after that. In an application, creating this type creates 12 recurring payments. When the last month expires, so does membership. The daily cron task is responsible for the expiration of the membership based on payments made. If the membership is configured to auto-renew, then the same cron task will update the membership.

You may also have a membership that does not have a start date, and just do months or a week to a week. They work in a similar way, minus the initial payment planning.

So far so good. The complexity is complicated by additional requirements:

  • Administrators
  • "" ( ) , (, , ). , , - , ( : , ).

  • , , . ( .)

  • , , .

- . , "" , , , . . , , (, , , ), - .

, , "freeze_on" "thaw_on" . , , , , .

, , . , . , ( " " ). .

, , ( , , ), .

, , . , - . , ?

, , , (.. ) , ( , ), ( ) , . , , , , .

- scanlife, qr

toronto,

: ( ):

:

  • , , , . .

  • , - ​​ . , , . , - , 1 15 . , , "" .

, , ?

. , - 12, 52 - , .. , "", "", "" "".

, , - , . , , , . , . , . ?

Arsen7:

, . , ( , , ASAP), , .

, , , , , . , , , , ?

, , , . , , , , , , ?

+5
2

, , ? () , , , : " ?"

, . ( , ) : " ? ? , , - -".

( ) . " ", , .

:

def process(day)
  raise "Already processed or missed a day" unless day == last_processed_day + 1

  check_expiration day
  check_frozen day
  check_anything day
  #...

  self.last_processed_day = day
  self.save!
end

:

, , , , , . , , , , ?

, , , . , , , , , , ?

, .

"": ( ), ( , ) .

"" . - , , , .

(, , ), "" . : () - ().

, , , , .

(, ), , , . "" , X $, Y $, .

, , , . ( ) .

+3

:

  • ?
  • , ? ?

, , .

. , . 52 . , , , , .

, . , . , , , .

, , . .

, , . , , , .

, , , "" , . , , , .

- . , - .

+1

All Articles