2a10f9af38
**Shiplogic API Integration:**
- Fixed API base URL configuration (removed /api suffix)
- Implemented comprehensive request/response logging for rates and shipments endpoints
- Fixed PDF fetching: API returns S3 URLs, now downloads actual PDFs from S3
- Added tests and mock API responses for local development (routes/shiplogic-mock.php)
**Courier Service Enhancements:**
- Added redownloadShipmentPdfs() public method for re-downloading corrupted PDFs
- Enhanced error logging with full request/response bodies for debugging
- Proper binary PDF storage using Laravel Storage facade
- URL and S3 download handling for Shiplogic API responses
**Workflow & Operations:**
- Changed to manual "Ready for Collection" button instead of automatic move
- Operators now: scan QR → apply labels → click "Ready for Collection" → moves to Awaiting Collection
- Removed duplicate PDF attachments to Trello (was adding twice from two listeners)
- Fixed NotifySlackOnShipmentCreated to only handle Slack notifications
**Mobile-Optimized Ops Page:**
- Removed QR code display from order detail page
- Implemented responsive single-column layout for mobile phones
- Large touch-friendly buttons (full width, increased padding)
- Bold typography for better readability on small screens
- Larger input fields and tracking number displays
- Clear step-by-step instructions for warehouse operators
- Re-download PDF button for damaged/corrupted labels
**New Features:**
- POST /ops/orders/{uuid}/ready-for-collection endpoint
- Re-download PDFs functionality accessible from awaiting_collection and in_transit states
- Full audit logging for all operations via ops interface
- Proper error handling and user feedback
**Testing:**
- Added ShipmentCreationTest with mock HTTP client
- Created comprehensive testing guide (SHIPLOGIC_TESTING.md)
- Mock API routes for local development without hitting live API
137 lines
3.2 KiB
PHP
137 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class CustomOrder extends Model
|
|
{
|
|
protected $fillable = [
|
|
'user_id',
|
|
'uuid',
|
|
'order_number',
|
|
'type',
|
|
'status',
|
|
'design_fee',
|
|
'library_discount_applied',
|
|
'material_cost',
|
|
'total_cost',
|
|
'deposit_amount',
|
|
'balance_amount',
|
|
'deposit_status',
|
|
'balance_status',
|
|
'yoco_checkout_id',
|
|
'yoco_redirect_url',
|
|
'yoco_checkout_response',
|
|
'customer_brief',
|
|
'admin_notes',
|
|
'submitted_at',
|
|
'approved_at',
|
|
'rejected_at',
|
|
'completed_at',
|
|
'proof_approved',
|
|
'proof_approved_at',
|
|
'packing_width',
|
|
'packing_length',
|
|
'packing_height',
|
|
'packing_weight',
|
|
'packing_completed_at',
|
|
'packed_by',
|
|
'courier_waybill_id',
|
|
'courier_tracking_number',
|
|
'courier_status',
|
|
'delivered_at',
|
|
'delivery_failure_reason',
|
|
'trello_card_id',
|
|
'qr_token',
|
|
'qr_generated_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'library_discount_applied' => 'boolean',
|
|
'proof_approved' => 'boolean',
|
|
'design_fee' => 'decimal:2',
|
|
'material_cost' => 'decimal:2',
|
|
'total_cost' => 'decimal:2',
|
|
'deposit_amount' => 'decimal:2',
|
|
'balance_amount' => 'decimal:2',
|
|
'submitted_at' => 'datetime',
|
|
'approved_at' => 'datetime',
|
|
'rejected_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
'proof_approved_at' => 'datetime',
|
|
'packing_completed_at' => 'datetime',
|
|
'delivered_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* Boot method for model
|
|
*/
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::creating(function ($model) {
|
|
$model->uuid = \Illuminate\Support\Str::uuid();
|
|
$model->order_number = 'CUSTOM-' . now()->format('Ymd') . '-' . strtoupper(uniqid());
|
|
$model->submitted_at = now();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get the user that owns this custom order
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* Get the specifications for this custom order
|
|
*/
|
|
public function specifications(): HasOne
|
|
{
|
|
return $this->hasOne(CustomOrderSpecification::class);
|
|
}
|
|
|
|
/**
|
|
* Get the files uploaded for this custom order
|
|
*/
|
|
public function files(): HasMany
|
|
{
|
|
return $this->hasMany(CustomOrderFile::class);
|
|
}
|
|
|
|
/**
|
|
* Get the proofs uploaded for this custom order
|
|
*/
|
|
public function proofs(): HasMany
|
|
{
|
|
return $this->hasMany(CustomOrderProof::class);
|
|
}
|
|
|
|
/**
|
|
* Get route key name for implicit route binding
|
|
*/
|
|
public function getRouteKeyName()
|
|
{
|
|
return 'uuid';
|
|
}
|
|
|
|
public function packedBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'packed_by');
|
|
}
|
|
|
|
/**
|
|
* Check if this is a custom order
|
|
*/
|
|
public function isCustomOrder(): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|