-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #775 from bakaphp/price-history
Price history
- Loading branch information
Showing
16 changed files
with
261 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
database/migrations/Inventory/2024_01_02_162441_create-channel-price-history.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class () extends Migration { | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('products_variants_warehouse_channel_price_history', function (Blueprint $table) { | ||
$table->bigInteger('products_variants_id')->unsigned(); | ||
$table->bigInteger('channels_id')->unsigned(); | ||
$table->bigInteger('product_variants_warehouse_id')->unsigned(); | ||
$table->float('price', 10, 2); | ||
$table->dateTime('from_date'); | ||
$table->timestamp('created_at')->useCurrent(); | ||
$table->boolean('is_deleted')->default(0); | ||
$table->foreign('products_variants_id', 'variants_price_ref')->references('id')->on('products_variants'); | ||
$table->foreign('channels_id', 'channels_price_ref')->references('id')->on('channels'); | ||
$table->foreign('product_variants_warehouse_id', 'variant_warehouse_channel_price_ref')->references('id')->on('products_variants_warehouses'); | ||
}); | ||
|
||
Schema::dropIfExists('products_variants_warehouse_price_history'); | ||
|
||
Schema::create('products_variants_warehouses_price_history', function (Blueprint $table) { | ||
$table->bigInteger('product_variants_warehouse_id')->unsigned(); | ||
$table->float('price', 10, 2); | ||
$table->dateTime('from_date'); | ||
$table->timestamp('created_at')->useCurrent(); | ||
$table->boolean('is_deleted')->default(0); | ||
$table->foreign('product_variants_warehouse_id', 'variant_warehouse_price_ref')->references('id')->on('products_variants_warehouses'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
// | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/Domains/Inventory/Channels/Actions/CreatePriceHistoryAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kanvas\Inventory\Channels\Actions; | ||
|
||
use Kanvas\Inventory\Channels\Models\Channels; | ||
use Kanvas\Inventory\Variants\Models\VariantsWarehouses; | ||
use Kanvas\Inventory\Channels\Models\VariantChannelPriceHistory; | ||
|
||
class CreatePriceHistoryAction | ||
{ | ||
/** | ||
* __construct. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct( | ||
protected VariantsWarehouses $variantsWarehouses, | ||
protected Channels $channel, | ||
protected Float $price | ||
) { | ||
} | ||
|
||
/** | ||
* execute. | ||
* | ||
* @return VariantChannelPriceHistory | ||
*/ | ||
public function execute(): VariantChannelPriceHistory | ||
{ | ||
return VariantChannelPriceHistory::firstOrCreate( | ||
[ | ||
'product_variants_warehouse_id' => $this->variantsWarehouses->getId(), | ||
'channels_id' => $this->channel->getId(), | ||
'products_variants_id' => $this->variantsWarehouses->products_variants_id, | ||
'price' => $this->price | ||
], | ||
[ | ||
'from_date' => date('Y-m-d H:i:s'), | ||
] | ||
); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/Domains/Inventory/Channels/Models/VariantChannelPriceHistory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kanvas\Inventory\Channels\Models; | ||
|
||
use Baka\Traits\NoAppRelationshipTrait; | ||
use Baka\Traits\NoCompanyRelationshipTrait; | ||
use Kanvas\Inventory\Models\BaseModel; | ||
|
||
/** | ||
* Class Variants Price Channel History. | ||
* | ||
* @property int $channel_id | ||
* @property int $products_variants_id | ||
* @property int $product_variants_warehouse_id | ||
* @property int $price | ||
* @property string $from_date | ||
* @property string $created_at | ||
* @property bool $is_deleted | ||
*/ | ||
class VariantChannelPriceHistory extends BaseModel | ||
{ | ||
use NoAppRelationshipTrait; | ||
use NoCompanyRelationshipTrait; | ||
|
||
protected $table = 'products_variants_warehouse_channel_price_history'; | ||
public $timestamps = false; | ||
protected $guarded = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
src/Domains/Inventory/Variants/Models/VariantsWarehousePriceHistory.php
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/Domains/Inventory/Variants/Models/VariantsWarehousesPriceHistory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kanvas\Inventory\Variants\Models; | ||
|
||
use Baka\Traits\NoAppRelationshipTrait; | ||
use Baka\Traits\NoCompanyRelationshipTrait; | ||
use Kanvas\Inventory\Models\BaseModel; | ||
|
||
/** | ||
* Class Variants Price History. | ||
* | ||
* @property int $product_variants_warehouse_id | ||
* @property int $price | ||
* @property string $from_date | ||
* @property string $created_at | ||
* @property bool $is_deleted | ||
*/ | ||
class VariantsWarehousesPriceHistory extends BaseModel | ||
{ | ||
use NoAppRelationshipTrait; | ||
use NoCompanyRelationshipTrait; | ||
|
||
protected $table = 'products_variants_warehouses_price_history'; | ||
public $timestamps = false; | ||
protected $guarded = []; | ||
} |
Oops, something went wrong.