[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: fix years_to_pay calculations
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: fix years_to_pay calculations |
Date: |
Sun, 11 Jul 2021 13:15:45 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new db06bb6 fix years_to_pay calculations
db06bb6 is described below
commit db06bb64d0e0aba4f00269b7af9b44b943ae838f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Jul 11 13:15:43 2021 +0200
fix years_to_pay calculations
---
src/backend/anastasis-httpd_policy_upload.c | 8 ++++++--
src/backend/anastasis-httpd_truth_upload.c | 6 ++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/backend/anastasis-httpd_policy_upload.c
b/src/backend/anastasis-httpd_policy_upload.c
index 9104b3b..500ad32 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -534,15 +534,19 @@ begin_payment (struct PolicyUploadContext *puc)
{
char *order_id;
struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Relative rem;
unsigned int years_to_pay;
struct TALER_Amount upload_fee;
now = GNUNET_TIME_absolute_get ();
if (puc->paid_until.abs_value_us < now.abs_value_us)
puc->paid_until = now;
- years_to_pay = (puc->end_date.abs_value_us
- - puc->paid_until.abs_value_us)
+ rem = GNUNET_TIME_absolute_get_difference (puc->paid_until,
+ puc->end_date);
+ years_to_pay = rem.rel_value_us
/ GNUNET_TIME_UNIT_YEARS.rel_value_us;
+ if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us))
+ years_to_pay++;
if (0 >
TALER_amount_multiply (&upload_fee,
&AH_annual_fee,
diff --git a/src/backend/anastasis-httpd_truth_upload.c
b/src/backend/anastasis-httpd_truth_upload.c
index 6038bd5..b2cf07c 100644
--- a/src/backend/anastasis-httpd_truth_upload.c
+++ b/src/backend/anastasis-httpd_truth_upload.c
@@ -689,12 +689,14 @@ AH_handler_truth_post (
(paid_until.abs_value_us < desired_until.abs_value_us) )
{
struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Relative rem;
now = GNUNET_TIME_absolute_get ();
if (paid_until.abs_value_us < now.abs_value_us)
paid_until = now;
- tuc->years_to_pay = (desired_until.abs_value_us
- - paid_until.abs_value_us)
+ rem = GNUNET_TIME_absolute_get_difference (paid_until,
+ desired_until);
+ tuc->years_to_pay = rem.rel_value_us
/ GNUNET_TIME_UNIT_YEARS.rel_value_us;
if (0 >
TALER_amount_multiply (&tuc->upload_fee,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: fix years_to_pay calculations,
gnunet <=