don't put to tbl_transactions if customer redeem voucher code Created by Voucher Device

This commit is contained in:
Ibnu Maksum 2024-08-08 14:58:04 +07:00
parent 9ad9ba45b1
commit 630f20094a
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
2 changed files with 67 additions and 53 deletions

View File

@ -299,36 +299,40 @@ class Package
$b->save(); $b->save();
} }
// insert table transactions if($gateway == 'Voucher' && User::isUserVoucher($channel)){
$t = ORM::for_table('tbl_transactions')->create(); // maybe someday i will do something in here
$t->invoice = $inv = "INV-" . Package::_raid(); }else{
$t->username = $c['username']; // insert table transactions
$t->plan_name = $p['name_plan']; $t = ORM::for_table('tbl_transactions')->create();
if ($p['validity_unit'] == 'Period') { $t->invoice = $inv = "INV-" . Package::_raid();
// Postpaid price from field $t->username = $c['username'];
$add_inv = User::getAttribute("Invoice", $id_customer); $t->plan_name = $p['name_plan'];
if (empty($add_inv) or $add_inv == 0) { if ($p['validity_unit'] == 'Period') {
$t->price = $p['price'] + $add_cost; // Postpaid price from field
$add_inv = User::getAttribute("Invoice", $id_customer);
if (empty($add_inv) or $add_inv == 0) {
$t->price = $p['price'] + $add_cost;
} else {
$t->price = $add_inv + $add_cost;
}
} else { } else {
$t->price = $add_inv + $add_cost; $t->price = $p['price'] + $add_cost;
} }
} else { $t->recharged_on = $date_only;
$t->price = $p['price'] + $add_cost; $t->recharged_time = $time_only;
$t->expiration = $date_exp;
$t->time = $time;
$t->method = "$gateway - $channel";
$t->routers = $router_name;
$t->note = $note;
$t->type = $p['type'];
if ($admin) {
$t->admin_id = ($admin['id']) ? $admin['id'] : '0';
} else {
$t->admin_id = '0';
}
$t->save();
} }
$t->recharged_on = $date_only;
$t->recharged_time = $time_only;
$t->expiration = $date_exp;
$t->time = $time;
$t->method = "$gateway - $channel";
$t->routers = $router_name;
$t->note = $note;
$t->type = $p['type'];
if ($admin) {
$t->admin_id = ($admin['id']) ? $admin['id'] : '0';
} else {
$t->admin_id = '0';
}
$t->save();
if ($p['validity_unit'] == 'Period') { if ($p['validity_unit'] == 'Period') {
// insert price to fields for invoice next month // insert price to fields for invoice next month
@ -407,33 +411,38 @@ class Package
} }
$d->save(); $d->save();
} }
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create(); if($gateway == 'Voucher' && User::isUserVoucher($channel)){
$t->invoice = $inv = "INV-" . Package::_raid(); // maybe someday i will do something in here
$t->username = $c['username']; }else{
$t->plan_name = $p['name_plan']; // insert table transactions
if ($p['validity_unit'] == 'Period') { $t = ORM::for_table('tbl_transactions')->create();
// Postpaid price always zero for first time $t->invoice = $inv = "INV-" . Package::_raid();
$note = ''; $t->username = $c['username'];
$bills = []; $t->plan_name = $p['name_plan'];
$t->price = 0; if ($p['validity_unit'] == 'Period') {
} else { // Postpaid price always zero for first time
$t->price = $p['price'] + $add_cost; $note = '';
$bills = [];
$t->price = 0;
} else {
$t->price = $p['price'] + $add_cost;
}
$t->recharged_on = $date_only;
$t->recharged_time = $time_only;
$t->expiration = $date_exp;
$t->time = $time;
$t->method = "$gateway - $channel";
$t->note = $note;
$t->routers = $router_name;
if ($admin) {
$t->admin_id = ($admin['id']) ? $admin['id'] : '0';
} else {
$t->admin_id = '0';
}
$t->type = $p['type'];
$t->save();
} }
$t->recharged_on = $date_only;
$t->recharged_time = $time_only;
$t->expiration = $date_exp;
$t->time = $time;
$t->method = "$gateway - $channel";
$t->note = $note;
$t->routers = $router_name;
if ($admin) {
$t->admin_id = ($admin['id']) ? $admin['id'] : '0';
} else {
$t->admin_id = '0';
}
$t->type = $p['type'];
$t->save();
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) { if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
// insert price to fields for invoice next month // insert price to fields for invoice next month

View File

@ -196,6 +196,11 @@ class User
return $d; return $d;
} }
public static function isUserVoucher($kode) {
$regex = '/^GC\d+C.{10}$/';
return preg_match($regex, $kode);
}
public static function _billing($id = 0) public static function _billing($id = 0)
{ {
if (!$id) { if (!$id) {