Skip to content

Commit

Permalink
feat: annual field for charges table
Browse files Browse the repository at this point in the history
  • Loading branch information
seka19 committed Nov 6, 2023
1 parent e78bbf9 commit 3ab5c58
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ShopifyApp/Models/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @property int $id
* @property int $charge_id
* @property bool $test
* @property bool $annual
* @property string $status
* @property string $name
* @property string $terms
Expand Down Expand Up @@ -83,6 +84,7 @@ class Charge extends Model
protected $casts = [
'type' => 'int',
'test' => 'bool',
'annual' => 'bool',
'charge_id' => 'string',
'shop_id' => 'int',
'capped_amount' => 'float',
Expand Down Expand Up @@ -149,7 +151,7 @@ public function retrieve()
*/
public function isTest()
{
return (bool) $this->test;
return (bool)$this->test;
}

/**
Expand All @@ -161,7 +163,7 @@ public function isTest()
*/
public function isType(int $type)
{
return (int) $this->type === $type;
return (int)$this->type === $type;
}

/**
Expand Down Expand Up @@ -228,7 +230,7 @@ public function remainingTrialDaysFromCancel()
*/
public function periodBeginDate()
{
$pastPeriods = (int) (Carbon::parse($this->activated_on)->diffInDays(Carbon::today()) / 30);
$pastPeriods = (int)(Carbon::parse($this->activated_on)->diffInDays(Carbon::today()) / 30);
$periodBeginDate = Carbon::parse($this->activated_on)->addDays(30 * $pastPeriods)->toDateString();

return $periodBeginDate;
Expand Down Expand Up @@ -372,9 +374,9 @@ public function isOngoing()
/**
* Cancels this charge.
*
* @return self
* @throws Exception
*
* @return self
*/
public function cancel()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddAnnualToBillingChargesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('billing_charges', function (Blueprint $table) {
$table->boolean('annual')->default(false)->after('test');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('billing_charges', function (Blueprint $table) {
$table->dropColumn('annual');
});
}
}

0 comments on commit 3ab5c58

Please sign in to comment.