Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: SpeeDee Delivery Integration #97

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
151 changes: 151 additions & 0 deletions common/models/SpeedeeManifest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php

namespace common\models;

use Yii;

/**
* This is the model class for table "speedee_manifests".
*
* @property int $id
* @property int $order_id
* @property int $customer_id
* @property string $ship_from_shipper_number
* @property string $ship_from_bane
cdwieber marked this conversation as resolved.
Show resolved Hide resolved
* @property string $ship_from_attention
* @property string $ship_from_address_1
* @property string $ship_from_address_2
* @property string $ship_from_city
* @property int $ship_from_zip
* @property string $ship_from_country
* @property string $ship_from_email
* @property string $ship_from_phone
* @property string $ship_to_import_field
* @property string $ship_to_shipper_number
* @property string $ship_to_name
* @property string $ship_to_attention
* @property string $ship_to_address_1
* @property string $ship_to_address_2
* @property string $ship_to_city
* @property string $ship_to_country
* @property string $ship_to_email
* @property string $ship_to_phone
* @property string $reference_1
* @property string $reference_2
* @property string $reference_3
* @property string $reference_4
* @property int $weight
* @property int $length
* @property int $width
* @property int $height
* @property string $barcode
* @property int $oversized
* @property int $pickup_tag
* @property int $aod
* @property int $aod_option
* @property int $cod
* @property int $cod_value
* @property int $declared_value
* @property int $package_handling
* @property int $apply_package_handling
* @property string $ship_date
* @property string $bill_to_shipper_number
* @property int $unboxed
*
* @property Customer $customer
* @property Order $order
*/
class SpeedeeManifest extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'speedee_manifests';
}

/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['order_id', 'customer_id', 'ship_from_zip', 'weight', 'length', 'width', 'height', 'oversized', 'pickup_tag', 'aod', 'aod_option', 'cod', 'cod_value', 'declared_value', 'package_handling', 'apply_package_handling', 'unboxed'], 'integer'],
[['ship_date'], 'safe'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we ensure a data format?

[['ship_from_shipper_number', 'ship_to_shipper_number', 'bill_to_shipper_number'], 'string', 'max' => 6],
[['ship_from_bane', 'ship_from_attention', 'ship_from_address_1', 'ship_from_address_2', 'ship_from_city', 'ship_from_country', 'ship_from_email', 'ship_from_phone', 'ship_to_import_field', 'ship_to_name', 'ship_to_attention', 'ship_to_address_1', 'ship_to_address_2', 'ship_to_city', 'ship_to_country', 'ship_to_email', 'ship_to_phone', 'reference_1', 'reference_2', 'reference_3', 'reference_4', 'barcode'], 'string', 'max' => 255],
[['customer_id'], 'exist', 'skipOnError' => true, 'targetClass' => Customer::class, 'targetAttribute' => ['customer_id' => 'id']],
[['order_id'], 'exist', 'skipOnError' => true, 'targetClass' => Order::class, 'targetAttribute' => ['order_id' => 'id']],
];
}

/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'order_id' => 'Order ID',
'customer_id' => 'Customer ID',
'ship_from_shipper_number' => 'Ship From Shipper Number',
'ship_from_bane' => 'Ship From Bane',
cdwieber marked this conversation as resolved.
Show resolved Hide resolved
'ship_from_attention' => 'Ship From Attention',
'ship_from_address_1' => 'Ship From Address 1',
'ship_from_address_2' => 'Ship From Address 2',
'ship_from_city' => 'Ship From City',
'ship_from_zip' => 'Ship From Zip',
'ship_from_country' => 'Ship From Country',
'ship_from_email' => 'Ship From Email',
'ship_from_phone' => 'Ship From Phone',
'ship_to_import_field' => 'Ship To Import Field',
'ship_to_shipper_number' => 'Ship To Shipper Number',
'ship_to_name' => 'Ship To Name',
'ship_to_attention' => 'Ship To Attention',
'ship_to_address_1' => 'Ship To Address 1',
'ship_to_address_2' => 'Ship To Address 2',
'ship_to_city' => 'Ship To City',
'ship_to_country' => 'Ship To Country',
'ship_to_email' => 'Ship To Email',
'ship_to_phone' => 'Ship To Phone',
'reference_1' => 'Reference 1',
'reference_2' => 'Reference 2',
'reference_3' => 'Reference 3',
'reference_4' => 'Reference 4',
'weight' => 'Weight',
'length' => 'Length',
'width' => 'Width',
'height' => 'Height',
'barcode' => 'Barcode',
'oversized' => 'Oversized',
'pickup_tag' => 'Pickup Tag',
'aod' => 'Aod',
'aod_option' => 'Aod Option',
'cod' => 'Cod',
'cod_value' => 'Cod Value',
'declared_value' => 'Declared Value',
'package_handling' => 'Package Handling',
'apply_package_handling' => 'Apply Package Handling',
'ship_date' => 'Ship Date',
'bill_to_shipper_number' => 'Bill To Shipper Number',
'unboxed' => 'Unboxed',
];
}

/**
* @return \yii\db\ActiveQuery
*/
public function getCustomer()
{
return $this->hasOne('common\models\Customer', ['id' => 'customer_id']);
}

/**
* @return \yii\db\ActiveQuery
*/
public function getOrder()
{
return $this->hasOne('common\models\Order', ['id' => 'order_id']);
}
}
66 changes: 66 additions & 0 deletions common/models/shipping/extension/wsdl/SpeeDeePlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace common\models\shipping\extension;

use common\models\shipping\ShipmentPlugin;

class SpeeDeePlugin extends ShipmentPlugin
{
/**
* Plugin Name
*
* @var string Constant
*/
const PLUGIN_NAME = "SpeeDee";

private string $hostProd = '66.191.64.52';
cdwieber marked this conversation as resolved.
Show resolved Hide resolved
private string $hostDev = '';
private string $ftpUser = '';
private string $frpPassword = '';
cdwieber marked this conversation as resolved.
Show resolved Hide resolved


public function autoload($customerId = null)
{
// TODO: Implement autoload() method.
cdwieber marked this conversation as resolved.
Show resolved Hide resolved
// Shipper Id comes in from settings?
}

public function getPluginName()
{
return self::PLUGIN_NAME;
}

/**
*
* @return mixed|void
*/
protected function ratePrepare()
{
// TODO: Implement ratePrepare() method.
}

protected function rateExecute()
{
// TODO: Implement rateExecute() method.
}

protected function rateProcess()
{
// TODO: Implement rateProcess() method.
}

protected function shipmentPrepare()
{
// TODO: Implement shipmentPrepare() method.
}

protected function shipmentExecute()
{
// TODO: Implement shipmentExecute() method.
}

protected function shipmentProcess()
{
// TODO: Implement shipmentProcess() method.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

use yii\db\Migration;

/**
* Handles the creation of table `{{%speedee_manifests}}`.
*/
class m221227_200815_create_speedee_manifests_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%speedee_manifests}}', [
'id' => $this->primaryKey(),
'order_id' => $this->integer(),
'customer_id' => $this->integer(),
'ship_from_shipper_number' => $this->string(6),
'ship_from_bane' => $this->string(),
cdwieber marked this conversation as resolved.
Show resolved Hide resolved
'ship_from_attention' => $this->string()->null(),
'ship_from_address_1' => $this->string(),
'ship_from_address_2' => $this->string()->null(),
'ship_from_city' => $this->string(),
'ship_from_zip' => $this->integer(5),
'ship_from_country' => $this->string()->null(),
'ship_from_email' => $this->string()->null(),
'ship_from_phone' => $this->string(),
'ship_to_import_field' => $this->string(), // Destination Company Identification Number/String
'ship_to_shipper_number' => $this->string(6)->null(),
'ship_to_name' => $this->string(),
'ship_to_attention' => $this->string()->null(),
'ship_to_address_1' => $this->string(),
'ship_to_address_2' => $this->string()->null(),
'ship_to_city' => $this->string(),
'ship_to_country' => $this->string(),
'ship_to_email' => $this->string()->null(),
'ship_to_phone' => $this->string()->null(),
'reference_1' => $this->string()->null(), // Additional Reference Field (Usually Invoice Number)
'reference_2' => $this->string()->null(),
'reference_3' => $this->string()->null(),
'reference_4' => $this->string()->null(),
'weight' => $this->integer(),
'length' => $this->integer()->null(),
'width' => $this->integer()->null(),
'height' => $this->integer()->null(),
'barcode' => $this->string(),
'oversized' => $this->boolean()->defaultValue(false),
'pickup_tag' => $this->boolean()->defaultValue(false),
'aod' => $this->boolean()->defaultValue(false), // Package Requires an Acknowledgement of Delivery
'aod_option' => $this->integer()->defaultValue(0), // See SDS spreadsheet cell N11
'cod' => $this->boolean()->defaultValue(false),
'cod_value' => $this->integer()->null(), // Amount to collect for COD (cents)
'declared_value' => $this->integer(), // Declared value for insurance purposes (cents)
'package_handling' => $this->integer(), // Package handling - flat amount
'apply_package_handling' => $this->boolean()->defaultValue(false),
'ship_date' => $this->date(), // Date package was picked up by driver; default is to use processing date
cdwieber marked this conversation as resolved.
Show resolved Hide resolved
'bill_to_shipper_number' => $this->string(6), // currently same as ship_to number
'unboxed' => $this->boolean()->defaultValue(false),
]);

$this->addForeignKey(
'fk-speedee-manifest-order-id',
'speedee_manifests',
'order_id',
'orders',
'id'
);

$this->addForeignKey(
'fk-speedee-manifest-customer-id',
'speedee_manifests',
'customer_id',
'customers',
'id'
);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('fk-speedee-manifest-order-id', 'speedee_manifests');
$this->dropForeignKey('fk-speedee-manifest-customer-id', 'speedee_manifests');

$this->dropTable('{{%speedee_manifests}}');
}
}