Jump to content

Prorate Calculation with renew date


Blesta Addons

Recommended Posts

we have a issue that we have not understand what happen and how it was calculated. the case as the fallowing :

Package for domain that has the fallowing terms :

1 year term (200dh Without Tax)
2 years term (380dh Without Tax)
3 years term (540dh Without Tax)

Tax 20% .
Proforma enabled .
Logs Rotation to 10 Days .

a domain (service) that was expiration date Jul 03, 2018 for 1 year term (200dh Without Tax) , it was already a invoice generated by blesta for renewing it was generated in 4-7-2018 [Domain .MA - (Jul 03, 2018 - Jul 03, 2019)] amount (200DH without TAX)

Until here all thing are good an d normal .

Now a client from his client area want to renew the domain for two years, and he changed the domain terms from 1  to 2 years from client area, a new invoice was generated that has a amount of 9.85DH Without TAX !! the invoice line was as the fallowing :

Prorated Domain .MA (Jul 04, 2018 - Jul 03, 2019)

the client has payed the first invoice in  Jul 04, 2018 12:44:14 PM and the domain was renewed for 3 years (from the registrar logs it was renewed for 3 years in one renew command (not 2 and then 1) at Jul 04, 2018 12:45 . then he paid the second invoice in Jul 04, 2018 12:51:19 PM . 

the renew date in Blesta for this domain is  Jul 03, 2019 , the expiration date in the registry is Jul 03, 2021 .

now the client has extended his domain from 3 years with amount of 209.85dh Without TAX !!!!

Any one can explain to me what happen ?!

Link to comment
Share on other sites

This sounds like 2 potential issues:

  1. The invoice renewed for 3 years instead of 2 (this may be an issue with the module?)
  2. The amount due on the invoice for the renewal was prorated to a smaller amount than expected for the service length

Can you duplicate this behavior with other services? How about duplicating the issue just for the renewal pricing? If you can provide steps to duplicate the issue in Blesta, perhaps with services using the None module, I may be able to see if this is an issue with prorating service upgrades.

Link to comment
Share on other sites

duplicating the issue in the same server we can't now, i need to prepare other server test for this .

the first issue has not thing related with the module, i have checked and it very clear and the module we are working with it more than 3 years without any issue in renew until this case . the renew code is :

 

		$data = $response->data();
		$vars = ['years' => 1];
		
        if (empty($data['infData']['exDate'])) {
            unset($epp_client);
			$message = "RenewDomain: unable to parse response";
			$this->Input->setErrors(array('errors' => (array)$message));
			return;
        }

		foreach ($package->pricing as $pricing) {
			if ($pricing->id == $service->pricing_id) {
				$vars['years'] = $pricing->term;
				break;
			}
		}

		// Only process renewal if adding years today will add time to the expiry date
		if (strtotime("+" . $vars['years'] . " years") > $data['infData']['exDate']) {
			$vars['years'] = $vars['years']."y";
			// Renew Domain 1 year
			$frame = new  AfriCC\EPP\Frame\Command\Renew\Domain;		
			$frame->setDomain($fields->{'domain'});
			$frame->setCurrentExpirationDate(date('Y-m-d', strtotime($data['infData']['exDate'])));
			$frame->setPeriod($vars['years']);
			$response = $epp_client->request($frame);
			$this->last_request = array('url' => "Renew\Domain - renewService ". $fields->{'domain'} ,'args' => $frame);
			unset($frame);
			$this->processResponse($response);
		}

from the code i can't see any thing related to the 3 years bug .

Link to comment
Share on other sites

Does your module set the new domain expiration date as a number of years from today or from the current expiration date? For example, if there are 2 years remaining, and you are renewing for 3 years, does it set the expiration dato to (3 years - 2 years remaining = 1) one year or (3 years + 2 years remaining = 5) five years from now? From your example, it seems like the latter since they renewed it to expire in 1 year but then upgraded to 2 years and the result was (1 year from now + 2 years = 3) three years from now (2018 to 2021). If that is indeed the case, I would think your domain module would need to set $vars['years'] to the difference of the years remaining and the years added.

 

Link to comment
Share on other sites

Hello tyson, i'm tottaly certain that the module or the code in the renew has nothing with this issue, as the domain is sending the request as it should . if you make a look to the domain you can understand it cleary .

first we initialize the renew yaers with 1 year.

$vars = ['years' => 1];

we do a loop to get the service term  the same function in all your domains registrar module (logicboxes ect ..)

		foreach ($package->pricing as $pricing) {
			if ($pricing->id == $service->pricing_id) {
				$vars['years'] = $pricing->term;
				break;
			}
		}

We check if the renew date will add a new year, this will prevent renewing domain if it was already renewed manually

	// Only process renewal if adding years today will add time to the expiry date
		if (strtotime("+" . $vars['years'] . " years") > $data['infData']['exDate']) {
			$vars['years'] = $vars['years']."y";
			// Renew Domain 1 year
			$frame = new  AfriCC\EPP\Frame\Command\Renew\Domain;		
			$frame->setDomain($fields->{'domain'});
			$frame->setCurrentExpirationDate(date('Y-m-d', strtotime($data['infData']['exDate'])));
			$frame->setPeriod($vars['years']);
			$response = $epp_client->request($frame);
			$this->last_request = array('url' => "Renew\Domain - renewService ". $fields->{'domain'} ,'args' => $frame);
			unset($frame);
			$this->processResponse($response);
		}

so the module is not making any calculation he get the years from service pricing id, if not he use the default '1' .

from where coming this 3 years?

just to note the service term is set now for 2 years after the payment.

Link to comment
Share on other sites

When I was referring to the expiration date calculation, I meant the service the module is integrating with, not the module code you wrote for Blesta. From your module source, yes, you are simply setting the years to the number of years for the term from the package pricing, i.e.:

$vars['years'] = $vars['years']."y";

That is totally fine. What I was wondering is that once that API request is made, how does their service handle the expiration date? If "$vars['years'] = 2;", you will send 2 years to the API, but will they interpret that as adding 2 years from today, July 19, 2018, or will they add 2 years onto the current domain expiry date? If the current expiry date is February 1, 2020, will setting 2 years make it February 1, 2022 or July 19, 2020?

Link to comment
Share on other sites

the renew date in the is add X years from the expiration date . so if expiry date is February 1, 2020 , then after the renew for two years it become February 1, 2022, this logic is the unified renew process for all domain registrar, i'm not aware of any registry that renew will lead to a new expiry date July 19, 2020 .

Link to comment
Share on other sites

13 hours ago, Blesta Addons said:

the renew date in the is add X years from the expiration date . so if expiry date is February 1, 2020 , then after the renew for two years it become February 1, 2022, this logic is the unified renew process for all domain registrar, i'm not aware of any registry that renew will lead to a new expiry date July 19, 2020 .

I can confirm. This is one reason it's important for Blesta to sync renew dates.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...