1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fixes for Purchase Order Filters

This commit is contained in:
David Bomba 2023-01-19 10:23:42 +11:00
parent 05b3518fb7
commit 7b40340047
4 changed files with 41 additions and 5 deletions

View File

@ -70,7 +70,7 @@ class PurchaseOrderFilters extends QueryFilters
if(count($status_parameters) >=1) {
$query->whereIn('status_id', $status_parameters);
}
})
});
return $this->builder;
}

View File

@ -567,6 +567,12 @@ class BillingPortalPurchasev2 extends Component
}
/**
* Starts the trial
*
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
*/
public function handleTrial()
{
return $this->subscription->service()->startTrial([
@ -578,6 +584,12 @@ class BillingPortalPurchasev2 extends Component
]);
}
/**
* When the subscription total comes to $0 we
* pass back a $0 Invoice.
*
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
*/
public function handlePaymentNotRequired()
{
@ -600,7 +612,7 @@ class BillingPortalPurchasev2 extends Component
->save();
$invoice->number = null;
$invoice->service()
->markPaid()
->save();

View File

@ -1291,7 +1291,12 @@ class SubscriptionService
}
private function getDaysInFrequency()
/**
* Get the number of days in the currency frequency
*
* @return int Number of days
*/
private function getDaysInFrequency() :int
{
switch ($this->subscription->frequency_id) {
@ -1325,7 +1330,15 @@ class SubscriptionService
}
public function getNextDateForFrequency($date, $frequency)
/**
* Get the next date by frequency_id
*
* @param Carbon $date The current carbon date
* @param int $frequency The frequncy_id of the subscription
*
* @return ?Carbon The next date carbon object
*/
public function getNextDateForFrequency($date, $frequency) :?Carbon
{
switch ($frequency) {
case RecurringInvoice::FREQUENCY_DAILY:
@ -1353,7 +1366,7 @@ class SubscriptionService
case RecurringInvoice::FREQUENCY_THREE_YEARS:
return $date->addYears(3);
default:
return 0;
return null;
}
}
@ -1363,6 +1376,7 @@ class SubscriptionService
* @param Invoice $invoice The Invoice
* @param array $bundle The bundle array
* @param ClientContact $contact The Client Contact
*
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
*/
public function handleNoPaymentFlow(Invoice $invoice, $bundle, ClientContact $contact)

View File

@ -40,6 +40,16 @@ class PurchaseOrderTest extends TestCase
$this->makeTestData();
}
public function testPurchaseOrderGetWithClientStatus()
{
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get('/api/v1/purchase_orders?client_status=sent'.$this->encodePrimaryKey($this->purchase_order->id));
$response->assertStatus(200);
}
public function testPostNewPurchaseOrderPdf()
{
$purchase_order = [