Gutschriften manuell hinzufügen, Yard 0& tax
This commit is contained in:
parent
e670b92f5d
commit
c02fffd883
24 changed files with 497 additions and 68 deletions
|
|
@ -43,7 +43,6 @@ class MembershipController extends Controller
|
|||
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_order')->get()->last();
|
||||
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->get()->last();
|
||||
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
|
||||
|
||||
$data = [
|
||||
'user' => $user,
|
||||
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
|
||||
|
|
@ -100,8 +99,8 @@ class MembershipController extends Controller
|
|||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$qty = Request::get('qty') ? Request::get('qty') : 1;
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
Yard::instance('shopping')->setGlobalTaxRate(0);
|
||||
/*
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ class ModalController extends Controller
|
|||
$value = [];
|
||||
$ret = view("admin.modal.add_pay_credit", compact('value', 'data'))->render();
|
||||
}
|
||||
if($data['action'] === 'add-user-credit'){
|
||||
$value = [];
|
||||
$ret = view("admin.modal.add_credit", compact('value', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-credit-status'){
|
||||
$value = UserCredit::find($data['id']); //current user form order
|
||||
|
|
|
|||
|
|
@ -2,13 +2,19 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Models\UserCreditMargin as ModelsUserCreditMargin;
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Services\Util;
|
||||
use App\Services\Credit;
|
||||
use App\Services\Payment;
|
||||
use App\Models\UserCredit;
|
||||
use App\Models\ShoppingOrderMargin;
|
||||
use App\Models\UserCreditMargin;
|
||||
use App\Repositories\CreditRepository;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class PaymentCreditController extends Controller
|
||||
{
|
||||
|
|
@ -30,39 +36,40 @@ class PaymentCreditController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
$this->setActiveYears();
|
||||
$date1 = Carbon::parse('01.01.'.$this->activeYear." 00:00:00")->format('Y-m-d H:i:s');
|
||||
$date2 = Carbon::parse('31.12.'.$this->activeYear." 23:59:59")->toDateString();
|
||||
|
||||
$data = $this->makeData();
|
||||
return view('admin.payment.credit.index', $data);
|
||||
}
|
||||
|
||||
$ShoppingOrderMargins = ShoppingOrderMargin::join('users', 'm_sponsor_id', '=', 'users.id')
|
||||
->groupBy('m_sponsor_id')
|
||||
->join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.id as user_id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->wherePaid(true)
|
||||
->whereCancellation(false)
|
||||
->wherePartnerCommissionPaid(false)
|
||||
->where('partner_commission_pending_to', '<', Carbon::now())
|
||||
->get();
|
||||
|
||||
$ShoppingOrderMarginPendings = ShoppingOrderMargin::join('users', 'm_sponsor_id', '=', 'users.id')
|
||||
->groupBy('m_sponsor_id')
|
||||
->join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.id as user_id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->wherePaid(true)
|
||||
->whereCancellation(false)
|
||||
->wherePartnerCommissionPaid(false)
|
||||
->where('partner_commission_pending_to', '>=', Carbon::now())
|
||||
->get();
|
||||
|
||||
|
||||
$data = [
|
||||
'years' => $this->rangeYears,
|
||||
'active_year' => $this->activeYear,
|
||||
'ShoppingOrderMargins' => $ShoppingOrderMargins,
|
||||
'ShoppingOrderMarginPendings' => $ShoppingOrderMarginPendings,
|
||||
];
|
||||
return view('admin.payment.credit.index', $data);
|
||||
public function store(){
|
||||
$data = Request::all();
|
||||
|
||||
if(isset($data['action']) && $data['action'] === 'add-user-credit'){
|
||||
$add_credit_error = false;
|
||||
if(!isset($data['member_id']) || !$user = User::find($data['member_id'])){
|
||||
$add_credit_error = 'Vertriebspartner nicht gefunden';
|
||||
}
|
||||
if(!isset($data['credit'])){
|
||||
$add_credit_error = 'Bitte Betrag eingeben';
|
||||
}
|
||||
if(!isset($data['message'])){
|
||||
$add_credit_error = 'Bitte Mitteilung eingeben';
|
||||
}
|
||||
if($add_credit_error){
|
||||
$data = $this->makeData();
|
||||
$data['add_credit_error'] = $add_credit_error;
|
||||
return view('admin.payment.credit.index', $data);
|
||||
}
|
||||
|
||||
$credit = Util::reFormatNumber($data['credit']);
|
||||
$credit = number_format($credit, 2, '.', '');
|
||||
|
||||
Payment::addUserCreditMargin($user, $credit, 3, $data['message']);
|
||||
\Session()->flash('alert-success', "Guthaben hinzugefügt");
|
||||
}
|
||||
|
||||
return redirect(route('admin_payments_credit'));
|
||||
}
|
||||
|
||||
public function create(){
|
||||
|
|
@ -86,8 +93,67 @@ class PaymentCreditController extends Controller
|
|||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function makeData(){
|
||||
$this->setActiveYears();
|
||||
//$date1 = Carbon::parse('01.01.'.$this->activeYear." 00:00:00")->format('Y-m-d H:i:s');
|
||||
//$date2 = Carbon::parse('31.12.'.$this->activeYear." 23:59:59")->toDateString();
|
||||
|
||||
$ShoppingOrderMargins = ShoppingOrderMargin::join('users', 'm_sponsor_id', '=', 'users.id')
|
||||
->groupBy('m_sponsor_id')
|
||||
->join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.id as user_id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->wherePaid(true)
|
||||
->whereCancellation(false)
|
||||
->wherePartnerCommissionPaid(false)
|
||||
->where('partner_commission_pending_to', '<', Carbon::now())
|
||||
->get();
|
||||
|
||||
$ShoppingOrderMarginPendings = ShoppingOrderMargin::join('users', 'm_sponsor_id', '=', 'users.id')
|
||||
->groupBy('m_sponsor_id')
|
||||
->join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.id as user_id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->wherePaid(true)
|
||||
->whereCancellation(false)
|
||||
->wherePartnerCommissionPaid(false)
|
||||
->where('partner_commission_pending_to', '>=', Carbon::now())
|
||||
->get();
|
||||
|
||||
$UserCreditMargins = UserCreditMargin::wherePaid(false)->get();
|
||||
$ShoppingOrderMarginUserIds = ShoppingOrderMargin::select('m_sponsor_id')->groupBy('m_sponsor_id')
|
||||
->wherePaid(true)
|
||||
->whereCancellation(false)
|
||||
->wherePartnerCommissionPaid(false)
|
||||
->where('partner_commission_pending_to', '<', Carbon::now())
|
||||
->get()->pluck('m_sponsor_id')->toArray();
|
||||
|
||||
$onlyUserCreditMargins = [];
|
||||
foreach($UserCreditMargins as $key => $UserCreditMargin){
|
||||
if(!in_array($UserCreditMargin->user_id, $ShoppingOrderMarginUserIds)){
|
||||
if(isset($onlyUserCreditMargins[$UserCreditMargin->user_id])){
|
||||
$onlyUserCreditMargins[$UserCreditMargin->user_id]['sum'] += $UserCreditMargin->credit;
|
||||
$onlyUserCreditMargins[$UserCreditMargin->user_id]['entries'][$UserCreditMargin->id] = $UserCreditMargin;
|
||||
}else{
|
||||
$onlyUserCreditMargins[$UserCreditMargin->user_id] = [
|
||||
'user_id' => $UserCreditMargin->user->id,
|
||||
'first_name' => $UserCreditMargin->user->account->first_name,
|
||||
'last_name' => $UserCreditMargin->user->account->last_name,
|
||||
'email' => $UserCreditMargin->user->email,
|
||||
'sum' => $UserCreditMargin->credit,
|
||||
'entries' => [$UserCreditMargin->id => $UserCreditMargin],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'years' => $this->rangeYears,
|
||||
'active_year' => $this->activeYear,
|
||||
'ShoppingOrderMargins' => $ShoppingOrderMargins,
|
||||
'ShoppingOrderMarginPendings' => $ShoppingOrderMarginPendings,
|
||||
'onlyUserCreditMargins' => $onlyUserCreditMargins,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function setActiveYears(){
|
||||
|
|
@ -96,6 +162,20 @@ class PaymentCreditController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function delete($id, $del){
|
||||
|
||||
if($del === 'user_credit_margin'){
|
||||
$UserCreditMargin = UserCreditMargin::findOrFail($id);
|
||||
if($deleteTime = $UserCreditMargin->deleteTime()){
|
||||
$UserCreditMargin->delete();
|
||||
\Session()->flash('alert-success', "Guthaben ist gelöscht");
|
||||
}else{
|
||||
\Session()->flash('alert-error', "Guthaben kann nicht gelöscht werden");
|
||||
}
|
||||
}
|
||||
return redirect(route('admin_payments_credit'));
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$this->setActiveYears();
|
||||
|
|
@ -121,6 +201,12 @@ class PaymentCreditController extends Controller
|
|||
$ret .= $user_margin->firstname."/".$user_margin->lastname."/".$user_margin->reference."/".$user_margin->created_at."<br>";
|
||||
}
|
||||
}
|
||||
if($UserCredit->user_credits){
|
||||
foreach($UserCredit->user_credits as $user_credit){
|
||||
$ret .= nl2br($user_credit->message)." / ".$user_credit->created_at."<br>";
|
||||
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
})
|
||||
/* ->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ namespace App\Http\Controllers;
|
|||
use Carbon;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use App\Services\Util;
|
||||
use App\Models\UserPayCredit;
|
||||
use App\Services\Payment;
|
||||
|
|
@ -43,7 +42,6 @@ class PaymentPayCreditController extends Controller
|
|||
|
||||
if(isset($data['action']) && $data['action'] === 'add-user-pay-credit'){
|
||||
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$add_credit_error = false;
|
||||
if(!isset($data['member_id']) || !$user = User::find($data['member_id'])){
|
||||
$add_credit_error = 'Vertriebspartner nicht gefunden';
|
||||
|
|
@ -67,7 +65,7 @@ class PaymentPayCreditController extends Controller
|
|||
$credit = number_format($credit, 2, '.', '');
|
||||
|
||||
Payment::addUserPayCredits($user, $credit, 3, $data['message']);
|
||||
\Session()->flash('alert-success', "Guthaben aufgeladen");
|
||||
\Session()->flash('alert-success', "Einkaufsguthaben aufgeladen");
|
||||
}
|
||||
|
||||
return redirect(route('admin_payments_paycredit'));
|
||||
|
|
@ -87,7 +85,6 @@ class PaymentPayCreditController extends Controller
|
|||
}else{
|
||||
\Session()->flash('alert-error', "Guthaben kann nicht gelöscht werden");
|
||||
}
|
||||
|
||||
return redirect(route('admin_payments_paycredit'));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -295,19 +295,18 @@ class CheckoutController extends Controller
|
|||
$pay->setPersonalData();
|
||||
return $pay->ResponseData($identifier);
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function final($transactionId, $reference, $identifier) {
|
||||
|
||||
$payt = PaymentTransaction::findOrFail($transactionId);
|
||||
if($payt->shopping_payment->reference != $reference){
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
||||
Yard::instance('shopping')->destroy();
|
||||
$this->destroy();
|
||||
|
||||
|
|
@ -552,8 +551,9 @@ class CheckoutController extends Controller
|
|||
|
||||
$shopping_order->txaction = 'open';
|
||||
$shopping_order->save();
|
||||
|
||||
|
||||
if($shopping_payment){
|
||||
|
||||
if($payt->status === 'vor'){
|
||||
$shopping_payment->txaction = 'open';
|
||||
$shopping_order->txaction = 'open';
|
||||
|
|
@ -563,7 +563,7 @@ class CheckoutController extends Controller
|
|||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||
$shopping_payment->txaction = 'open';
|
||||
$shopping_order->txaction = 'open';
|
||||
}
|
||||
}
|
||||
$shopping_payment->save();
|
||||
}
|
||||
|
||||
|
|
@ -576,6 +576,7 @@ class CheckoutController extends Controller
|
|||
];
|
||||
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ class Product extends Model
|
|||
}
|
||||
public function setTaxAttribute( $value ) {
|
||||
|
||||
$this->attributes['tax'] = $value ? Util::reFormatNumber($value) : null;
|
||||
$this->attributes['tax'] = $value != "" ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setPriceOldAttribute( $value ) {
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property \Illuminate\Support\Carbon|null $shipped_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereInvoice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereShippedAt($value)
|
||||
* @property string|null $invoice_number
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereInvoiceNumber($value)
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property-read User|null $m_sponsor
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPaid($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPendingTo($value)
|
||||
* @property int|null $user_credit_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereUserCreditId($value)
|
||||
*/
|
||||
class ShoppingOrderMargin extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUserMargins($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $credit_number
|
||||
* @property string|null $date
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCreditNumber($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereDate($value)
|
||||
*/
|
||||
class UserCredit extends Model
|
||||
{
|
||||
|
|
@ -60,7 +64,8 @@ class UserCredit extends Model
|
|||
'cancellation' => 'bool',
|
||||
'status' => 'int',
|
||||
'credit' => 'array',
|
||||
'user_margins' => 'object'
|
||||
'user_margins' => 'object',
|
||||
'user_credits' => 'object'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
|
|
@ -73,6 +78,7 @@ class UserCredit extends Model
|
|||
'date',
|
||||
'credit',
|
||||
'user_margins',
|
||||
'user_credits',
|
||||
'paid_out',
|
||||
'cancellation',
|
||||
'status'
|
||||
|
|
|
|||
76
app/Models/UserCreditMargin.php
Normal file
76
app/Models/UserCreditMargin.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class UserCreditMargin
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property float|null $credit
|
||||
* @property string|null $message
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property User $user
|
||||
* @package App\Models
|
||||
* @property bool|null $paid
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereCredit($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereMessage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin wherePaid($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereUserId($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserCreditMargin extends Model
|
||||
{
|
||||
|
||||
public $statusType = [
|
||||
1 => 'manually added margin',
|
||||
];
|
||||
|
||||
protected $table = 'user_credit_margins';
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'credit' => 'float',
|
||||
'status' => 'int',
|
||||
'paid' => 'bool',
|
||||
'user_credit_id' => 'int',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'credit',
|
||||
'message',
|
||||
'status',
|
||||
'paid',
|
||||
'user_credit_id',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User','user_id');
|
||||
}
|
||||
|
||||
public function deleteTime(){
|
||||
$time = '+100 min';
|
||||
if(Carbon::parse($this->created_at)->modify($time)->gt(Carbon::now())){
|
||||
return Carbon::now()->diffInMinutes(Carbon::parse($this->created_at)->modify($time));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class UserPayCredit
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property float|null $credit
|
||||
|
|
@ -22,11 +22,23 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property int|null $shopping_order_id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property ShoppingOrder|null $shopping_order
|
||||
* @property User $user
|
||||
*
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereCredit($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereMessage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereNewCreditTotal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereOldCreditTotal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereShoppingOrderId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereUserId($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserPayCredit extends Model
|
||||
{
|
||||
|
|
@ -34,6 +46,8 @@ class UserPayCredit extends Model
|
|||
public $statusType = [
|
||||
1 => 'add from payment',
|
||||
2 => 'deduction from payment',
|
||||
3 => 'manually added credit',
|
||||
|
||||
];
|
||||
protected $table = 'user_pay_credits';
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class CreditRepository extends BaseRepository {
|
|||
'date' => $credit_date,
|
||||
'credit' => $credit_file,
|
||||
'user_margins' => $user_credits->margins,
|
||||
'user_credits' => $user_credits->credits,
|
||||
]);
|
||||
|
||||
|
||||
|
|
@ -91,15 +92,21 @@ class CreditRepository extends BaseRepository {
|
|||
$ShoppingOrderMargin->partner_commission_paid = true;
|
||||
$ShoppingOrderMargin->user_credit_id = $user_credit->id;
|
||||
$ShoppingOrderMargin->save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$UserCreditMargins = UserMarign::getUserCreditMarginByID($this->model->id);
|
||||
foreach($UserCreditMargins as $UserCreditMargin){
|
||||
$UserCreditMargin->paid = true;
|
||||
$UserCreditMargin->user_credit_id = $user_credit->id;
|
||||
$UserCreditMargin->save();
|
||||
}
|
||||
}
|
||||
private function makeUserCredit(){
|
||||
|
||||
$ret = new \stdClass();
|
||||
$ret->net = 0;
|
||||
$ret->margins = [];
|
||||
$ret->credits = [];
|
||||
$ShoppingOrderMargins = UserMarign::getOrderFromPartnerCommissionByID($this->model->id);
|
||||
foreach($ShoppingOrderMargins as $ShoppingOrderMargin){
|
||||
$margin = new \stdClass();
|
||||
|
|
@ -112,12 +119,24 @@ class CreditRepository extends BaseRepository {
|
|||
$ret->margins[] = $margin;
|
||||
$ret->net += $ShoppingOrderMargin->net_partner_commission;
|
||||
}
|
||||
|
||||
$UserCreditMargins = UserMarign::getUserCreditMarginByID($this->model->id);
|
||||
foreach($UserCreditMargins as $UserCreditMargin){
|
||||
$credit = new \stdClass();
|
||||
$credit->id = $UserCreditMargin->id;
|
||||
$credit->net = $UserCreditMargin->credit;
|
||||
$credit->message = $UserCreditMargin->message;
|
||||
$credit->created_at = $UserCreditMargin->created_at->format("d.m.Y");
|
||||
$ret->credits[] = $credit;
|
||||
$ret->net += $UserCreditMargin->credit;
|
||||
}
|
||||
|
||||
/* taxable_sales //user tax
|
||||
1 //umsatzsteuerpflichtig
|
||||
2 // nicht umsatzsteuerpflichtig
|
||||
*/
|
||||
if($this->model->account){
|
||||
$ret->taxable = $this->model->account->taxable_sales == 2 ? false : false;
|
||||
$ret->taxable = $this->model->account->taxable_sales == 2 ? false : true;
|
||||
if($ret->taxable){
|
||||
$ret->tax_rate = config('app.main_tax_number');
|
||||
$ret->total = round($ret->net * config('app.main_tax'), 2);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class ProductRepository extends BaseRepository {
|
|||
$data['active'] = isset($data['active']) ? 1 : 0;
|
||||
$data['single_commission'] = isset($data['single_commission']) ? 1 : 0;
|
||||
$data['amount_commission'] = isset($data['amount_commission']) ? 1 : 0;
|
||||
|
||||
if($data['id'] === "new"){
|
||||
$this->model = Product::create($data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Mail\MailCheckout;
|
|||
use App\Models\Setting;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\UserCreditMargin;
|
||||
use App\Models\UserPayCredit;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
|
@ -93,7 +94,6 @@ class Payment
|
|||
}
|
||||
|
||||
public static function addUserPayCredits(User $user, $credit, $status, $message, $shopping_order_id = null){
|
||||
|
||||
UserPayCredit::create([
|
||||
'user_id' => $user->id,
|
||||
'credit' => $credit,
|
||||
|
|
@ -105,7 +105,16 @@ class Payment
|
|||
]);
|
||||
$user->payment_credit = $user->payment_credit + $credit;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
|
||||
public static function addUserCreditMargin(User $user, $credit, $status, $message){
|
||||
UserCreditMargin::create([
|
||||
'user_id' => $user->id,
|
||||
'credit' => $credit,
|
||||
'message' => $message,
|
||||
'status' => $status,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){
|
||||
|
|
@ -121,7 +130,6 @@ class Payment
|
|||
foreach($shopping_order->shopping_order_items as $shopping_order_item){
|
||||
if($shopping_order_item->product){
|
||||
if($shopping_order_item->product->action){
|
||||
|
||||
$user = User::findOrFail($shopping_order->auth_user_id);
|
||||
$user->save();
|
||||
$send_link = true;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ namespace App\Services;
|
|||
|
||||
|
||||
use App\Models\ShoppingOrderMargin;
|
||||
use App\Models\UserCreditMargin;
|
||||
use App\User;
|
||||
use Carbon;
|
||||
|
||||
|
|
@ -101,11 +102,10 @@ class UserMarign
|
|||
if($format){
|
||||
$sum_net_amount = Util::formatNumber($sum_net_amount);
|
||||
}
|
||||
|
||||
return $sum_net_amount;
|
||||
}
|
||||
|
||||
public static function getMontlyPartnerCommissionOpenByID($user_id, $date = null, $format = false){
|
||||
public static function getMontlyPartnerCommissionOpenByID($user_id, $date = null, $format = false, $addUserCreditMargin = false){
|
||||
|
||||
$sum_net_amount = ShoppingOrderMargin::whereMSponsorId($user_id)
|
||||
->wherePaid(true)
|
||||
|
|
@ -113,6 +113,13 @@ class UserMarign
|
|||
->wherePartnerCommissionPaid(false)
|
||||
->where('partner_commission_pending_to', '<', Carbon::now())
|
||||
->sum('net_partner_commission');
|
||||
if($addUserCreditMargin){
|
||||
$sum_net_credit = UserCreditMargin::whereUserId($user_id)
|
||||
->wherePaid(false)
|
||||
->sum('credit');
|
||||
$sum_net_amount += $sum_net_credit;
|
||||
}
|
||||
|
||||
if($format){
|
||||
$sum_net_amount = Util::formatNumber($sum_net_amount);
|
||||
}
|
||||
|
|
@ -170,6 +177,15 @@ class UserMarign
|
|||
return $ShoppingOrderMargins;
|
||||
}
|
||||
|
||||
public static function getUserCreditMarginByID($user_id){
|
||||
|
||||
$UserCreditMargin = UserCreditMargin::whereUserId($user_id)
|
||||
->wherePaid(false)
|
||||
->get();
|
||||
|
||||
return $UserCreditMargin;
|
||||
}
|
||||
|
||||
public static function getOrderFromPartnerCommissionPendingByID($user_id){
|
||||
|
||||
$ShoppingOrderMargins = ShoppingOrderMargin::whereMSponsorId($user_id)
|
||||
|
|
|
|||
|
|
@ -32,12 +32,13 @@ class Yard extends Cart
|
|||
private $yard_commission;
|
||||
private $yard_margin;
|
||||
|
||||
private $global_tax_rate = 19;
|
||||
private $global_tax_rate = 0;
|
||||
|
||||
public function __construct(SessionManager $session, Dispatcher $events)
|
||||
{
|
||||
$this->ysession = $session;
|
||||
$this->yinstance = sprintf('%s.%s', 'cart', 'shipping_extras');
|
||||
|
||||
if($this->getYardExtra('shipping_price')){
|
||||
$this->shipping_price = (float) ($this->getYardExtra('shipping_price'));
|
||||
}
|
||||
|
|
@ -80,6 +81,11 @@ class Yard extends Cart
|
|||
if($this->getYardExtra('yard_margin')){
|
||||
$this->yard_margin = $this->getYardExtra('yard_margin');
|
||||
}
|
||||
if($this->getYardExtra('global_tax_rate') || $this->getYardExtra('global_tax_rate') === 0.0){
|
||||
$this->global_tax_rate = $this->getYardExtra('global_tax_rate');
|
||||
}else{
|
||||
$this->global_tax_rate = config('cart.tax');
|
||||
}
|
||||
|
||||
/*if($this->getYardExtra('num_comp')){
|
||||
$this->num_comp = $this->getYardExtra('num_comp');
|
||||
|
|
@ -104,6 +110,13 @@ class Yard extends Cart
|
|||
{
|
||||
return config('cart.tax');
|
||||
}
|
||||
|
||||
public function setGlobalTaxRate($value){
|
||||
|
||||
$this->global_tax_rate = floatval($value);
|
||||
$this->putYardExtra('global_tax_rate', $this->global_tax_rate);
|
||||
|
||||
}
|
||||
|
||||
public function putYardExtra($key, $value){
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue