Added temporary script to create Contracts from Orders

This commit is contained in:
Frank Schubert
2023-05-11 13:09:35 +02:00
parent ed4c6ad738
commit d6e2f71c9f
4 changed files with 137 additions and 8 deletions

View File

@@ -54,6 +54,58 @@ class ContractModel {
return $model;
}
public static function createFromOrderproduct($op) {
$log = mfLoghandler::singleton();
if(!$op->id) {
$log->warning(__METHOD__."(): Invalid OrderProduct object");
return false;
}
$order = $op->order;
$product = $op->product;
if(!$order->id || !$product->id) {
$log->warning(__METHOD__."(): Invalid Order or Product");
return false;
}
if(!$order->finish_date || $order->finish_date > date("U")) {
$log->warning(__METHOD__."(): Order not finished yet");
return false;
}
$data = [];
$data["orderproduct_id"] = $op->id;
$data["owner_id"] = $order->owner_id;
$data["billingaddress_id"] = $order->billingaddress_id;
$data["termination_id"] = ($op->termination_id) ? $op->termination_id : null;
$data["product_id"] = $op->product_id;
$data["product_name"] = $product->name;
$data["product_info"] = $product->description;
$data["amount"] = $op->amount;
$data["sla_id"] = $product->sla_id;
$data["produt_external"] = ($product->external) ? $product->external : 0;
$data["product_external_id"] = ($product->external) ? $product->external_id : null;
$data["price"] = $op->price;
$data["price_setup"] = $op->price_setup;
$data["price_nne"] = $op->price_nne;
$data["price_nbe"] = $op->price_nbe;
$data["billing_delay"] = $op->billing_delay;
$data["billing_period"] = $op->billing_period;
$data["order_date"] = $order->order_date;
$data["finish_date"] = $order->finish_date;
$data["finish_date_by"] = 1;
$data["note"] = $order->note;
$contract = ContractModel::create($data);
$contract->matchcode = $contract->generateMatchcode();
//var_dump($contract);exit;
return $contract;
}
public static function getAll() {
$items = [];