Sales subscription with variable amounts

sales subscription with variable amounts

Rational

“sale_subscription” only deals with subscriptions on fixed amounts (fixed quantities and fixed unit prices). For our needs and customer needs we want to invoice according to third party data in Tryton.

Some examples :

  • Make a subscription on the management, the quantity corresponds to a time consumed / spent on a project.
  • Charge commission, my customer provides direct sales service from theses customers to theses suppliers. The unit price is calculated according to the amount invoiced in the period by theses suppliers, it can be fixed, indexed on a rate or linked to a conversion grid.
  • Quantity to invoice is provided by an external API (Marketplace, website, …)

Proposition

I propose to modify the “sable_subscription” module or to add an additional module in order to be able to add in the subscriptions the possibility of defining unit quantities and / or prices via third-party models / APIs.

It would be far too complicated to have a fully configurable system, there are too many possible cases. I propose to add 2 hooks via selection fields. One to fix the quantity when creating consumption lines. the second to set the unit price when creating the invoice line. The values of the selection fields are the responsibility of the modules offering the third party.

By default the selection fields use the quantity and unit price found on the subscription line, maintaining the current behavior.

Implementation

Future

  • Add in the module timesheet the hook to get the quantity depending on the time cosummed
  • Add the implementation of the commission on the sale or the invoice in function of the rate or a conversion grid.

I do not see why you could not just define no consumption recurrence on the lines and have a custom process to create them. The invoice process will use those consumption to create the invoice.
To change the unit price, you can change it on the line which will modify for the next invoice created. But I think we could benefit to use a function on consumption to provide the unit price (which is by default the price on the line).

I understand your point of view. I would have liked to make it more configurable and that directly via sale_subscription