Discussion:
[Citrusdb-users] reviced get_nextbillingdate...
Eric Cho
2010-05-29 19:08:53 UTC
Permalink
Hi. Folks-

Today I found weird date problem.

July 2010 and Aug 2010 has same 31 days.

So, citrusDB's billing date will be mixed horribly.

(also, I thought from_date should be set as to_date when we roll up to next month)

Basically, I found that prev_billing_date column in billing table didn't be use from anywhere.

So, I'm use this column as original date that is same with from_date when user edited billing info.

Here are some codes-

[include/billing.inc.php]

line 767 -
$myOrigdate = $billingresult['b_prev_date'];

// double frequency to add to the to_date
$doublefreq = $mybillingfreq * 2;

// insert the new next_billing_date, from_date,
// to_date, and payment_due_date to next from_date
$query = "UPDATE billing ".
"SET next_billing_date = to_date, from_date = to_date, ".
"payment_due_date = to_date, ".
"to_date = DATE_ADD('$myOrigdate', ".
"INTERVAL PERIOD_DIFF(DATE_FORMAT(to_date, '%Y%m'), ". date('Ym', strtotime($billingresult['b_prev_date'])). ")+1 MONTH) ".
"WHERE id = '$mybilling_id'";
$updateresult = $DB->Execute($query) or die ("Query Failed");


(add above selection query - line 740) b.prev_billing_date b_prev_date,


[module/billing/edit.php]

line 187, line 239 - (not be exact)

"prev_billing_date = '$next_billing_date',". // 2010-05-29 for month adding, original column


finished.

take a look these codes, and please let me know if you find any wrong part.
Paul Yasi
2010-05-30 15:40:11 UTC
Permalink
I'm not sure I understand the issue. Citrus primarily uses the
DATE_ADD function from MySQL which should not have a problem adding to
any calendar date correctly.

You are right that the prev_billing_date column is not used anywhere,
it's a left over field from pre-release days.

Paul
Post by Eric Cho
Hi. Folks-
Today I found weird date problem.
July 2010 and Aug 2010 has same 31 days.
So, citrusDB's billing date will be mixed horribly.
(also, I thought from_date should be set as to_date when we roll up to next month)
Basically, I found that prev_billing_date column in billing table didn't be
use from anywhere.
So, I'm use this column as original date that is same with from_date when
user edited billing info.
Here are some codes-
[include/billing.inc.php]
line 767 -
$myOrigdate = $billingresult['b_prev_date'];
    // double frequency to add to the to_date
    $doublefreq = $mybillingfreq * 2;
    // insert the new next_billing_date, from_date,
    // to_date, and payment_due_date to next from_date
    $query = "UPDATE billing ".
        "SET next_billing_date = to_date, from_date = to_date, ".
      "payment_due_date = to_date, ".
      "to_date = DATE_ADD('$myOrigdate', ".
      "INTERVAL PERIOD_DIFF(DATE_FORMAT(to_date, '%Y%m'), ". date('Ym',
strtotime($billingresult['b_prev_date'])). ")+1 MONTH) ".
      "WHERE id = '$mybilling_id'";
    $updateresult = $DB->Execute($query) or die ("Query Failed");
(add above selection query - line 740)  b.prev_billing_date b_prev_date,
[module/billing/edit.php]
line 187, line 239 - (not be exact)
      "prev_billing_date = '$next_billing_date',". // 2010-05-29 for month
adding, original column
finished.
take a look these codes, and please let me know if you find any wrong part.
------------------------------------------------------------------------------
_______________________________________________
Citrusdb-users mailing list
https://lists.sourceforge.net/lists/listinfo/citrusdb-users
--
The CitrusDB Project | http://www.citrusdb.org
Open Source Customer Care & Billing System
Loading...