This is not strictly a Clojure question, but I'll ask it here since I am 
solving it in Clojure. I have already made one solution which works, but I 
am interested in whether there are other and better approaches.

I have a number of different products and some are dependant on others:

A <- B 
B <- C 
D

(B is depending on A, C is depending on B, D has no dependencies)

There might also be a required service or product for the above, lets 
denote them by lower case letters, which should be available at the same 
time or before the main product, and it cannot be billed after. It could be 
a modem for an internet connection.

Finally there might be a fee, lets call them fX e.g. fA if it is a fee for 
A. These should be billed at the same time as the main product but can be 
billed after.

So when you bill the customer you want to make sure that the product and 
the products it depends on are usable, delivered, provisioned (or whatever 
the case). For this we calculate a date from which we bill the customer for 
each of the products based on the date he requested the product.

So the customer might have placed the following order:

Product | Req. date | Bill date (calculated)
========================
A       | 3         | 3
fA      | 3         | 3
B       | 2         | 4
b       | 4         | 4
C       | 1         | 4
fC      | 1         | 4
D       | 1         | 1

B and C are bumped to time 3, because they depend on A (B directly, C 
indirectly) while D stays at 1 because it has no dependencies. However 
because b was only available at 4 (maybe due being out of stock), B and 
therefore C and fC are bumped to 4

What we are currently doing is looking at this as a tree of dependencies 
and transfer the dates from the dependencies to the product if the date is 
bigger (done per product in topological order to get the right 
propagation). The problem here are the required services that need to be 
able to bump the date of the main product but also not be billed after, 
this is modeled as B -> b and then having a post action to bump b up to B 
if it was before (but this feels like a hack). There cannot be a dependency 
in both directions as the topological order then cannot be found due to a 
circular dependency.

(I hope this is making sense, I am finding it a bit hard to explain)

So my question is, what other approaches are there? 

The ones that come to mind are:
 - core.logic, however I can't figure out how to get propagation through 
multiple dependencies.
 - rule engine of some sort, like clara-rules, but again can't get the 
propagation going.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to