On Tue, 10 Jul 2012 08:24:08 +0100 n...@hush.com wrote:
>On Tue, 10 Jul 2012 00:59:32 +0100 Paul Yasi <p...@citrusdb.org> 
>wrote:
>>The next billing dates are all based on the from date.  
>....
>>After
>>the monthly invoices is created it inserts new next billing 
>dates,
>>from dates, and payment due dates by adding a month to the from 
>>date
>>of the invoice it just created.
>>
>
>Thank you for replying, Paul.
>You seem to be saying that what it is doing is correct.
>But roll forward from your example: I issue an invoice on
>2012-01-01. This must be for whatever the customer used
>in the previous month, i.e., December. So the From Date
>for that invoice must be 2011.12.1. So the From Date of
>the next invoice must be 2012.1.1. That's OK. But from
>what you say, the Payment Due Date for the next invoice
>must be the same as the From Date of that invoice. So
>when I send an invoice for the month of January, i.e,
>>From Jan 1 To Jan 31 - which I can do no sooner than
>February 1 - the payment is put down as having been due
>on January 1.
...
>Why do you not simply add a month to the payment due date
>of the previous invoice to get the new payment due date?
>Michael

FYI I corrected this problem in a modified invoicing script.
The relevant parts are:

$query = "SELECT DISTINCT invoice_number, billing_id FROM 
billing_details
    WHERE batch = '$batchid'";
$DB->SetFetchMode(ADODB_FETCH_ASSOC);
$result = $DB->Execute($query) or die ("$l_queryfailed");
$billing_ids = array();
...
while ($myresult = $result->FetchRow()) {
    ...
    $billing_ids[] = $myresult['billing_id'];
}

...
foreach($billing_ids as $billing_id) {
    $query = "UPDATE billing SET payment_due_date=DATE_ADD(" .
            "(SELECT payment_due_date FROM billing_history WHERE " 
.
            "billing_id=$billing_id ORDER BY id DESC LIMIT 1), " .
            "INTERVAL 1 MONTH) WHERE id=$billing_id";
    $DB->Execute($query) or die ("$l_queryfailed '$query'");
}



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Citrusdb-users mailing list
Citrusdb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/citrusdb-users

Reply via email to