Tax Period Tests
This commit is contained in:
parent
0fb63dec60
commit
00e93582ea
|
|
@ -22,6 +22,7 @@ class BlackListRule implements ValidationRule
|
||||||
{
|
{
|
||||||
/** Bad domains +/- disposable email domains */
|
/** Bad domains +/- disposable email domains */
|
||||||
private array $blacklist = [
|
private array $blacklist = [
|
||||||
|
"moonfee.com",
|
||||||
"edus2.us",
|
"edus2.us",
|
||||||
"educj.org",
|
"educj.org",
|
||||||
"edu0.org",
|
"edu0.org",
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@ use App\Models\Invoice;
|
||||||
use App\Models\TransactionEvent;
|
use App\Models\TransactionEvent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use App\DataMapper\TransactionEventMetadata;
|
use App\DataMapper\TransactionEventMetadata;
|
||||||
|
/**
|
||||||
|
* Handles entries for invoices.
|
||||||
|
* Used for end of month aggregation of accrual accounting.
|
||||||
|
*/
|
||||||
class InvoiceTransactionEventEntry
|
class InvoiceTransactionEventEntry
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,17 +13,14 @@
|
||||||
namespace App\Listeners\Invoice;
|
namespace App\Listeners\Invoice;
|
||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Activity;
|
|
||||||
use App\Models\TransactionEvent;
|
use App\Models\TransactionEvent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use App\DataMapper\TaxReport\TaxDetail;
|
|
||||||
use App\DataMapper\TaxReport\TaxReport;
|
|
||||||
use App\DataMapper\TaxReport\TaxSummary;
|
|
||||||
use App\Repositories\ActivityRepository;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use App\DataMapper\TransactionEventMetadata;
|
use App\DataMapper\TransactionEventMetadata;
|
||||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles entries for vanilla payments on an invoice.
|
||||||
|
* Used for end of month aggregation of cash payments.
|
||||||
|
*/
|
||||||
class InvoiceTransactionEventEntryCash
|
class InvoiceTransactionEventEntryCash
|
||||||
{
|
{
|
||||||
private Collection $payments;
|
private Collection $payments;
|
||||||
|
|
@ -91,95 +88,9 @@ class InvoiceTransactionEventEntryCash
|
||||||
return round($amount * $this->paid_ratio, 2);
|
return round($amount * $this->paid_ratio, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Existing tax details are not deleted, but pending taxes are set to 0
|
|
||||||
*
|
|
||||||
* @param mixed $invoice
|
|
||||||
*/
|
|
||||||
// private function getCancelledMetaData($invoice)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// $calc = $invoice->calc();
|
|
||||||
|
|
||||||
// $details = [];
|
|
||||||
|
|
||||||
// $taxes = array_merge($calc->getTaxMap()->merge($calc->getTotalTaxMap())->toArray());
|
|
||||||
|
|
||||||
// foreach ($taxes as $tax) {
|
|
||||||
// $tax_detail = [
|
|
||||||
// 'tax_name' => $tax['name'],
|
|
||||||
// 'tax_rate' => $tax['tax_rate'],
|
|
||||||
// 'taxable_amount' => $tax['base_amount'] ?? $calc->getNetSubtotal(),
|
|
||||||
// 'tax_amount' => $this->calculateRatio($tax['total']),
|
|
||||||
// 'tax_amount_paid' => $this->calculateRatio($tax['total']),
|
|
||||||
// 'tax_amount_remaining' => 0,
|
|
||||||
// ];
|
|
||||||
// $details[] = $tax_detail;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return new TransactionEventMetadata([
|
|
||||||
// 'tax_report' => [
|
|
||||||
// 'tax_details' => $details,
|
|
||||||
// 'payment_history' => $this->payments->toArray(),
|
|
||||||
// 'tax_summary' => [
|
|
||||||
// 'total_taxes' => $invoice->total_taxes,
|
|
||||||
// 'total_paid' => $this->getTotalTaxPaid($invoice),
|
|
||||||
// 'status' => 'cancelled',
|
|
||||||
// ],
|
|
||||||
// ],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set all tax details to 0
|
|
||||||
*
|
|
||||||
* @param mixed $invoice
|
|
||||||
*/
|
|
||||||
// private function getDeletedMetaData($invoice)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// $calc = $invoice->calc();
|
|
||||||
|
|
||||||
// $details = [];
|
|
||||||
|
|
||||||
// $taxes = array_merge($calc->getTaxMap()->merge($calc->getTotalTaxMap())->toArray());
|
|
||||||
|
|
||||||
// foreach ($taxes as $tax) {
|
|
||||||
// $tax_detail = [
|
|
||||||
// 'tax_name' => $tax['name'],
|
|
||||||
// 'tax_rate' => $tax['tax_rate'],
|
|
||||||
// 'taxable_amount' => $tax['base_amount'] ?? $calc->getNetSubtotal(),
|
|
||||||
// 'tax_amount' => $tax['total'],
|
|
||||||
// 'tax_amount_paid' => $this->calculateRatio($tax['total']),
|
|
||||||
// 'tax_amount_remaining' => 0,
|
|
||||||
// ];
|
|
||||||
// $details[] = $tax_detail;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return new TransactionEventMetadata([
|
|
||||||
// 'tax_report' => [
|
|
||||||
// 'tax_details' => $details,
|
|
||||||
// 'payment_history' => $this->payments->toArray(),
|
|
||||||
// 'tax_summary' => [
|
|
||||||
// 'total_taxes' => $invoice->total_taxes,
|
|
||||||
// 'total_paid' => $this->getTotalTaxPaid($invoice),0,
|
|
||||||
// 'status' => 'deleted',
|
|
||||||
// ],
|
|
||||||
// ],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
private function getMetadata($invoice)
|
private function getMetadata($invoice)
|
||||||
{
|
{
|
||||||
|
|
||||||
// if ($invoice->status_id == Invoice::STATUS_CANCELLED) {
|
|
||||||
// return $this->getCancelledMetaData($invoice);
|
|
||||||
// } elseif ($invoice->is_deleted) {
|
|
||||||
// return $this->getDeletedMetaData($invoice);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$calc = $invoice->calc();
|
$calc = $invoice->calc();
|
||||||
|
|
||||||
$details = [];
|
$details = [];
|
||||||
|
|
@ -206,6 +117,9 @@ class InvoiceTransactionEventEntryCash
|
||||||
'total_taxes' => $invoice->total_taxes,
|
'total_taxes' => $invoice->total_taxes,
|
||||||
'total_paid' => $this->getTotalTaxPaid($invoice),
|
'total_paid' => $this->getTotalTaxPaid($invoice),
|
||||||
'status' => 'updated',
|
'status' => 'updated',
|
||||||
|
'taxable_amount' => $calc->getNetSubtotal(),
|
||||||
|
'adjustment' => 0,
|
||||||
|
'tax_adjustment' => 0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -173,8 +173,10 @@ class PaymentTransactionEventEntry implements ShouldQueue
|
||||||
'tax_summary' => [
|
'tax_summary' => [
|
||||||
'total_taxes' => $invoice->total_taxes,
|
'total_taxes' => $invoice->total_taxes,
|
||||||
'total_paid' => $this->getTotalTaxPaid($invoice),
|
'total_paid' => $this->getTotalTaxPaid($invoice),
|
||||||
'adjustment' => round($invoice->total_taxes - $this->getTotalTaxPaid($invoice), 2) * -1,
|
'tax_adjustment' => round($invoice->total_taxes - $this->getTotalTaxPaid($invoice), 2) * -1,
|
||||||
'status' => 'adjustment',
|
'status' => 'adjustment',
|
||||||
|
'taxable_amount' => $calc->getNetSubtotal(),
|
||||||
|
'adjustment' => 0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
@ -197,7 +199,6 @@ class PaymentTransactionEventEntry implements ShouldQueue
|
||||||
|
|
||||||
foreach ($taxes as $tax) {
|
foreach ($taxes as $tax) {
|
||||||
|
|
||||||
|
|
||||||
$base_amount = $tax['base_amount'] ?? $calc->getNetSubtotal();
|
$base_amount = $tax['base_amount'] ?? $calc->getNetSubtotal();
|
||||||
|
|
||||||
if($this->invoice_adjustment > 0)
|
if($this->invoice_adjustment > 0)
|
||||||
|
|
@ -226,7 +227,9 @@ class PaymentTransactionEventEntry implements ShouldQueue
|
||||||
'tax_summary' => [
|
'tax_summary' => [
|
||||||
'total_taxes' => $invoice->total_taxes,
|
'total_taxes' => $invoice->total_taxes,
|
||||||
'total_paid' => $this->getTotalTaxPaid($invoice),
|
'total_paid' => $this->getTotalTaxPaid($invoice),
|
||||||
'adjustment' => round($invoice->total_taxes - $this->getTotalTaxPaid($invoice), 2) * -1,
|
'taxable_amount' => $calc->getNetSubtotal(),
|
||||||
|
'adjustment' => 0,
|
||||||
|
'tax_adjustment' => round($invoice->total_taxes - $this->getTotalTaxPaid($invoice), 2) * -1,
|
||||||
'status' => 'adjustment',
|
'status' => 'adjustment',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -498,4 +498,9 @@ class TaxPeriodReportTest extends TestCase
|
||||||
|
|
||||||
// Updated invoices with payments in the same period
|
// Updated invoices with payments in the same period
|
||||||
// Updated invoices with payments in the next period
|
// Updated invoices with payments in the next period
|
||||||
|
|
||||||
|
//cash accounting.
|
||||||
|
|
||||||
|
// What happens when a payment is deleted?
|
||||||
|
// What happens when a paid invoice is deleted?
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue