Added prune logic for transaction models
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled

This commit is contained in:
dhanabalan
2026-01-29 19:01:02 +05:30
parent c4153169eb
commit 1b1a02a565
21 changed files with 326 additions and 171 deletions

View File

@@ -2,13 +2,15 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class CharacteristicValue extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
@@ -45,4 +47,9 @@ class CharacteristicValue extends Model
{
return $this->belongsTo(Machine::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,12 +2,15 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class ClassCharacteristic extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
@@ -179,4 +182,9 @@ class ClassCharacteristic extends Model
{
return $this->belongsTo(Machine::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,12 +2,15 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class EbReading extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
@@ -66,4 +69,9 @@ class EbReading extends Model
{
return $this->belongsTo(Plant::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,12 +2,15 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class InvoiceDataValidation extends Model
{
use Prunable;
use SoftDeletes;
protected $dates = ['deleted_at'];
@@ -32,4 +35,9 @@ class InvoiceDataValidation extends Model
{
return $this->belongsTo(Plant::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,45 +2,53 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class InvoiceInTransit extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
"plant_id",
"receiving_plant",
"receiving_plant_name",
"invoice_number",
"invoice_date",
"item_code",
"description",
"quantity",
"transport_name",
"lr_bl_aw_number",
"lr_bl_aw_date",
"pending_days",
"obd_number",
"obd_date",
"shipment_weight",
"unit_price",
"net_value",
"total_item_amount",
"tax_amount",
"transport_mode",
"vehicle_number",
"e_waybill_number",
"created_at",
"created_by",
"updated_by",
"updated_at"
'plant_id',
'receiving_plant',
'receiving_plant_name',
'invoice_number',
'invoice_date',
'item_code',
'description',
'quantity',
'transport_name',
'lr_bl_aw_number',
'lr_bl_aw_date',
'pending_days',
'obd_number',
'obd_date',
'shipment_weight',
'unit_price',
'net_value',
'total_item_amount',
'tax_amount',
'transport_mode',
'vehicle_number',
'e_waybill_number',
'created_at',
'created_by',
'updated_by',
'updated_at',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,12 +2,15 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class InvoiceOutValidation extends Model
{
use Prunable;
use SoftDeletes;
// protected $dates = ['deleted_at'];
@@ -27,4 +30,9 @@ class InvoiceOutValidation extends Model
{
return $this->belongsTo(Plant::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,18 +2,21 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class InvoiceValidation extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
'sticker_master_id',
'plant_id',
'invoice_number',
'invoice_number',
'serial_number',
'motor_scanned_status',
'pump_scanned_status',
@@ -44,5 +47,8 @@ class InvoiceValidation extends Model
return $this->belongsTo(StickerMaster::class, 'sticker_master_id');
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,32 +2,40 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class LocatorInvoiceValidation extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
'plant_id',
'invoice_number',
'invoice_number',
'serial_number',
'pallet_number',
'locator_number',
'scanned_status',
'upload_status',
'created_at',
'updated_at',
'scanned_at',
'created_by',
'scanned_by',
'updated_by',
'pallet_number',
'locator_number',
'scanned_status',
'upload_status',
'created_at',
'updated_at',
'scanned_at',
'created_by',
'scanned_by',
'updated_by',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,39 +2,42 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class MfmReading extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
'plant_id',
'mfm_meter_id',
'apparent_energy_received',
'apparent_energy_received',
'reactive_energy_received',
'active_energy_received',
'active_power_r',
'active_power_y',
'active_power_b',
'active_power_y',
'active_power_b',
'active_power_total',
'voltage_ry',
'voltage_yb',
'voltage_ry',
'voltage_yb',
'voltage_br',
'current_r',
'current_y',
'current_y',
'current_b',
'current_n',
'voltage_r_n',
'voltage_y_n',
'voltage_r_n',
'voltage_y_n',
'voltage_b_n',
'frequency',
'power_factor_r',
'frequency',
'power_factor_r',
'power_factor_y',
'power_factor_b',
'power_factor_total',
'power_factor_total',
'created_at',
'updated_at',
];
@@ -48,4 +51,9 @@ class MfmReading extends Model
{
return $this->belongsTo(MfmMeter::class, 'mfm_meter_id');
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,31 +2,39 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class PalletValidation extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
'plant_id',
'pallet_number',
'pallet_number',
'serial_number',
'pallet_status',
'locator_number',
'pallet_status',
'locator_number',
'locator_quantity',
'created_at',
'updated_at',
'scanned_at',
'created_by',
'scanned_by',
'updated_by',
'created_at',
'updated_at',
'scanned_at',
'created_by',
'scanned_by',
'updated_by',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,12 +2,15 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class ProcessOrder extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
@@ -24,8 +27,8 @@ class ProcessOrder extends Model
'rework_status',
'created_at',
'created_by',
'updated_by',
'updated_at',
'updated_by',
];
public function plant(): BelongsTo
@@ -42,4 +45,9 @@ class ProcessOrder extends Model
{
return $this->belongsTo(Item::class, 'item_id');
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,24 +2,29 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class ProductionLineStop extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
"plant_id",
"shift_id",
"line_id",
"linestop_id",
"from_datetime",
"to_datetime",
"stop_hour",
"stop_min",
"operator_id",
'plant_id',
'line_id',
'shift_id',
'linestop_id',
'from_datetime',
'to_datetime',
'stop_hour',
'stop_min',
'operator_id',
'created_at',
'updated_at',
];
public function plant(): BelongsTo
@@ -48,5 +53,8 @@ class ProductionLineStop extends Model
// return $this->belongsTo(LineStop::class, 'linestop_id');
// }
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,22 +2,26 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class ProductionPlan extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
"plant_id",
"shift_id",
"created_at",
"line_id",
"plan_quantity",
"production_quantity",
"operator_id",
'plant_id',
'shift_id',
'line_id',
'plan_quantity',
'production_quantity',
'operator_id',
'created_at',
'updated_at',
];
public function plant(): BelongsTo
@@ -34,4 +38,9 @@ class ProductionPlan extends Model
{
return $this->belongsTo(Line::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -4,30 +4,33 @@ namespace App\Models;
use Carbon\Carbon;
use Filament\Facades\Filament;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class ProductionQuantity extends Model
{
use Prunable;
use SoftDeletes;
public static $importing = false; // Add this flag
protected $fillable = [
"plant_id",
"shift_id",
"line_id",
"item_id",
"serial_number",
"production_order",
"operator_id",
'plant_id',
'shift_id',
'line_id',
'item_id',
'serial_number',
'production_order',
'operator_id',
// "success_status",
// "notok_at",
// "no_of_employee",
// "list_of_employee",
"created_at",
"updated_at"
'created_at',
'updated_at',
];
public function plant(): BelongsTo
@@ -66,8 +69,7 @@ class ProductionQuantity extends Model
->latest()
->first();
if (!$productionPlan)
{
if (! $productionPlan) {
$productionPlan = ProductionPlan::where('plant_id', $productionQuantity->plant_id)
->where('shift_id', $productionQuantity->shift_id)
->where('line_id', $productionQuantity->line_id)
@@ -88,4 +90,9 @@ class ProductionQuantity extends Model
}
});
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,19 +2,22 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class QualityValidation extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
'sticker_master_id',
'plant_id',
'plant_id',
'line_id',
'production_order',
'production_order',
'serial_number_motor',
'serial_number_pump',
'serial_number_pumpset',
@@ -56,4 +59,9 @@ class QualityValidation extends Model
{
return $this->belongsTo(Line::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,12 +2,15 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class RequestCharacteristic extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
@@ -48,7 +51,6 @@ class RequestCharacteristic extends Model
return $this->belongsTo(Item::class);
}
public function machine(): BelongsTo
{
return $this->belongsTo(Machine::class);
@@ -91,9 +93,8 @@ class RequestCharacteristic extends Model
);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,30 +2,33 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class ReworkLocatorInvoiceValidation extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
'plant_id',
'invoice_number',
'serial_number',
'pallet_number',
'locator_number',
'scanned_status',
'upload_status',
'created_by',
'scanned_by',
'updated_by',
'reworked_by',
'created_at',
'updated_at',
'scanned_at',
'reworked_at',
'invoice_number',
'serial_number',
'pallet_number',
'locator_number',
'scanned_status',
'upload_status',
'created_by',
'scanned_by',
'updated_by',
'reworked_by',
'created_at',
'updated_at',
'scanned_at',
'reworked_at',
];
public function plant(): BelongsTo
@@ -33,4 +36,8 @@ class ReworkLocatorInvoiceValidation extends Model
return $this->belongsTo(Plant::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,19 +2,21 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class SerialValidation extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
'sticker_master_id',
'plant_id',
'invoice_number',
'invoice_number',
'serial_number',
'motor_scanned_status',
'pump_scanned_status',
@@ -44,4 +46,9 @@ class SerialValidation extends Model
{
return $this->belongsTo(StickerMaster::class, 'sticker_master_id');
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,14 +2,15 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class StickerPrinting extends Model
{
//
use Prunable;
use SoftDeletes;
protected $fillable = [
@@ -26,4 +27,9 @@ class StickerPrinting extends Model
{
return $this->belongsTo(Plant::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,21 +2,24 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class TempLiveReading extends Model
{
use SoftDeletes;
use Prunable;
use SoftDeletes;
protected $fillable = [
'plant_id',
'mfm_meter_id',
'register_data',
'register_data',
'created_at',
'updated_at',
'created_by',
'updated_at',
'created_by',
];
public function plant(): BelongsTo
@@ -28,4 +31,9 @@ class TempLiveReading extends Model
{
return $this->belongsTo(MfmMeter::class, 'mfm_meter_id');
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}

View File

@@ -2,66 +2,69 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class TestingPanelReading extends Model
{
use Prunable;
use SoftDeletes;
protected $fillable = [
'plant_id',
'line_id',
'motor_testing_master_id',
'machine_id',
'output',
'serial_number',
'line_id',
'motor_testing_master_id',
'machine_id',
'output',
'serial_number',
'winded_serial_number',
'before_fr_volt',
'before_fr_cur',
'before_fr_pow',
'before_fr_res_ry',
'before_fr_res_yb',
'before_fr_res_br',
'before_fr_ir',
'before_fr_ir_r',
'before_fr_ir_y',
'before_fr_ir_b',
'before_fr_freq',
'before_fr_speed',
'after_fr_vol',
'after_fr_cur',
'after_fr_pow',
'after_fr_ir_hot',
'after_fr_ir_hot_r',
'after_fr_ir_hot_y',
'after_fr_ir_hot_b',
'after_fr_ir_cool',
'after_fr_ir_cool_r',
'after_fr_ir_cool_y',
'after_fr_ir_cool_b',
'after_fr_freq',
'after_fr_speed',
'after_fr_leak_cur',
'locked_rt_volt',
'locked_rt_cur',
'locked_rt_pow',
'no_load_pickup_volt',
'room_temperature',
'hv_test',
'batch_number',
'batch_count',
'result',
'remark',
'rework_count',
'before_fr_volt',
'before_fr_cur',
'before_fr_pow',
'before_fr_res_ry',
'before_fr_res_yb',
'before_fr_res_br',
'before_fr_ir',
'before_fr_ir_r',
'before_fr_ir_y',
'before_fr_ir_b',
'before_fr_freq',
'before_fr_speed',
'after_fr_vol',
'after_fr_cur',
'after_fr_pow',
'after_fr_ir_hot',
'after_fr_ir_hot_r',
'after_fr_ir_hot_y',
'after_fr_ir_hot_b',
'after_fr_ir_cool',
'after_fr_ir_cool_r',
'after_fr_ir_cool_y',
'after_fr_ir_cool_b',
'after_fr_freq',
'after_fr_speed',
'after_fr_leak_cur',
'locked_rt_volt',
'locked_rt_cur',
'locked_rt_pow',
'no_load_pickup_volt',
'room_temperature',
'hv_test',
'batch_number',
'batch_count',
'result',
'remark',
'rework_count',
'update_count',
'output_flag',
'tested_by',
'updated_by',
'tested_by',
'updated_by',
'created_at',
'updated_at',
'scanned_at',
'scanned_at',
];
public function plant(): BelongsTo
@@ -69,10 +72,11 @@ class TestingPanelReading extends Model
return $this->belongsTo(Plant::class);
}
public function line(): BelongsTo
public function line(): BelongsTo
{
return $this->belongsTo(Line::class);
}
public function machine(): BelongsTo
{
return $this->belongsTo(Machine::class);
@@ -83,8 +87,13 @@ class TestingPanelReading extends Model
return $this->belongsTo(Item::class);
}
public function motorTestingMaster()
public function motorTestingMaster()
{
return $this->belongsTo(MotorTestingMaster::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
}
}