CutCodeDown

Web Development => PHP => Topic started by: GrumpyYoungMan on 23 Nov 2022, 07:18:17 am

Title: Trying to predict where we are in the (tax) year...
Post by: GrumpyYoungMan on 23 Nov 2022, 07:18:17 am
Code: [Select]
$start = strtotime("now") > strtotime("April 6th") ? date("Y") : date("Y")+1;
$end = strtotime("now") > strtotime("April 6th") ? date("Y")+1 : date("Y");
Which will then be used to do something like:
Code: [Select]
echo '<hr><table>
    <thead>
    <tr>
        <th>Expense Type</th>
        <th>Date</th>
        <th>Invoice #</th>
        <th>Supplier</th>
        <th>Total</th>
    </tr>
    </thead>
    <tbody>';

$inInvoices = $db->prepare("
                        SELECT
                            *
                        FROM
                            ".SQL_TBL_PREFIX."suppliers
                        WHERE
                            `Date` BETWEEN ? AND ?
                    ");
   
    $inInvoices->execute([ $start.'-04-06', $end.'-04-05' ]);


    while( $r = $inInvoices->fetch() ) {
    echo '<tr>
        <td>', $r['Expenses Type'],'</td>
        <td>', $r['Date'],'</td>
        <td>', $r['Invoice #'],'</td>
        <td>', $r['Supplier Name'],'</td>
        <td>', number_format($r['Total Paid'], 2), '</td>
       
       
    </tr>';
    }

    echo '</tbody>
</table>';


As I am trying to predict the tax year(s) by using the above code... Is it really that easy?

At a later stage we may be able to change the tax year to calculate other years from the DB...
Title: Re: Trying to predict where we are in the (tax) year...
Post by: Jason Knight on 23 Nov 2022, 11:16:43 pm
Considering tax years are either calendar years or arbitrary "fiscal years" ending on the last day of a particular month, I'm not sure why you're checking for the filing due date which should be completely unrelated when looking at customer invoices.
Title: Re: Trying to predict where we are in the (tax) year...
Post by: GrumpyYoungMan on 24 Nov 2022, 02:24:40 pm
Considering tax years are either calendar years or arbitrary "fiscal years" ending on the last day of a particular month, I'm not sure why you're checking for the filing due date which should be completely unrelated when looking at customer invoices.
In the UK the tax year starts April 6th and runs until the following April 05th… don’t ask me why… they are also now forcing all businesses to change to this too…

This is only going to generate a year report of sales/expenses