last changes since 6-2023
This commit is contained in:
parent
0341c9c189
commit
04d677d37a
142 changed files with 7895 additions and 2855 deletions
|
|
@ -51,7 +51,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUserShopId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereWeight($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $payment_for
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder wherePaymentFor($value)
|
||||
* @property int|null $member_id
|
||||
|
|
@ -94,6 +93,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereApiNotice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereApiStatus($value)
|
||||
* @property-read \App\Models\ShoppingCollectOrder|null $shopping_collect_order
|
||||
* @property array|null $net_split
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereNetSplit($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
{
|
||||
|
|
@ -117,6 +119,7 @@ class ShoppingOrder extends Model
|
|||
'subtotal_ws',
|
||||
'tax',
|
||||
'tax_split',
|
||||
'net_split',
|
||||
'total_shipping',
|
||||
'points',
|
||||
'weight',
|
||||
|
|
@ -133,6 +136,8 @@ class ShoppingOrder extends Model
|
|||
protected $casts = [
|
||||
'api_notice' => 'array',
|
||||
'tax_split' => 'array',
|
||||
'net_split' => 'array',
|
||||
|
||||
];
|
||||
|
||||
public static $shippedTypes = [
|
||||
|
|
@ -419,107 +424,158 @@ class ShoppingOrder extends Model
|
|||
public function makeHomepartyTaxSplit()
|
||||
{
|
||||
$tax_split = [];
|
||||
$net_split = [];
|
||||
|
||||
if($this->homeparty){
|
||||
foreach($this->homeparty->homeparty_order_items as $item){
|
||||
$tax_rate = intval($item->tax_rate);
|
||||
if($tax_rate > 0){
|
||||
$vk_tax = round((($item->price - $item->price_net) * $item->qty), 2);
|
||||
$ek_tax = round((($item->ek_price - $item->ek_price_net) * $item->qty), 2);
|
||||
$vk_net = round(($item->price_net * $item->qty), 2);
|
||||
$ek_net = round(($item->ek_price_net * $item->qty), 2);
|
||||
if(isset($tax_split[$tax_rate])){
|
||||
$tax_split[$tax_rate]['vk_tax'] = round($tax_split[$tax_rate]['vk_tax'] + $vk_tax, 2);
|
||||
$tax_split[$tax_rate]['ek_tax'] = round($tax_split[$tax_rate]['ek_tax'] + $ek_tax, 2);
|
||||
|
||||
$net_split[$tax_rate]['vk_net'] = round($net_split[$tax_rate]['vk_net'] + $vk_net, 2);
|
||||
$net_split[$tax_rate]['ek_net'] = round($net_split[$tax_rate]['ek_net'] + $ek_net, 2);
|
||||
}else{
|
||||
$tax_split[$tax_rate] = ['vk_tax' => $vk_tax, 'ek_tax' => $ek_tax];
|
||||
$net_split[$tax_rate] = ['vk_net' => $vk_net, 'ek_net' => $ek_net];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_vk_tax = 0;
|
||||
$order_ek_tax = 0;
|
||||
$order_vk_net = 0;
|
||||
$order_ek_net = 0;
|
||||
|
||||
if($this->homeparty->order){
|
||||
if(isset($this->homeparty->order['ek_price_net'])){
|
||||
$order_vk_tax = round((($this->homeparty->order['price'] - $this->homeparty->order['price_net'])), 2);
|
||||
$order_ek_tax = round((($this->homeparty->order['ek_price'] - $this->homeparty->order['ek_price_net'])), 2);
|
||||
$order_vk_net = $this->homeparty->order['price_net'];
|
||||
$order_ek_net = $this->homeparty->order['ek_price_net'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($tax_split[16])){
|
||||
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
$net_split[16] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
|
||||
}
|
||||
if(isset($tax_split[19])){
|
||||
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
$net_split[19] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
|
||||
}
|
||||
|
||||
if(isset($tax_split[5])){
|
||||
if(!isset($tax_split[16])){
|
||||
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
$net_split[16] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
|
||||
}
|
||||
$tax_split[16]['vk_tax'] = round($tax_split[16]['vk_tax'] - $tax_split[5]['vk_tax'], 2);
|
||||
$tax_split[16]['ek_tax'] = round($tax_split[16]['ek_tax'] - $tax_split[5]['ek_tax'], 2);
|
||||
$net_split[16]['vk_net'] = round($net_split[16]['vk_net'] - $net_split[5]['vk_net'], 2);
|
||||
$net_split[16]['ek_net'] = round($net_split[16]['ek_net'] - $net_split[5]['ek_net'], 2);
|
||||
}
|
||||
if(isset($tax_split[7])){
|
||||
if(!isset($tax_split[19])){
|
||||
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
$net_split[19] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
|
||||
}
|
||||
$tax_split[19]['vk_tax'] = round($tax_split[19]['vk_tax'] - $tax_split[7]['vk_tax'], 2);
|
||||
$tax_split[19]['ek_tax'] = round($tax_split[19]['ek_tax'] - $tax_split[7]['ek_tax'], 2);
|
||||
$net_split[19]['vk_net'] = round($net_split[19]['vk_net'] - $net_split[7]['vk_net'], 2);
|
||||
$net_split[19]['ek_net'] = round($net_split[19]['ek_net'] - $net_split[7]['ek_net'], 2);
|
||||
}
|
||||
|
||||
|
||||
foreach($tax_split as $key=>$value){
|
||||
$tax_split[$key]['vk_tax'] = number_format($value['vk_tax'], 2);
|
||||
$tax_split[$key]['ek_tax'] = number_format($value['ek_tax'], 2);
|
||||
}
|
||||
|
||||
foreach($net_split as $key=>$value){
|
||||
$net_split[$key]['vk_net'] = number_format($value['vk_net'], 2);
|
||||
$net_split[$key]['ek_net'] = number_format($value['ek_net'], 2);
|
||||
}
|
||||
}
|
||||
if(!isset($tax_split[16]) && !isset($tax_split[19])){
|
||||
$tax_split = NULL;
|
||||
}
|
||||
}
|
||||
if(!isset($net_split[16]) && !isset($net_split[19])){
|
||||
$net_split = NULL;
|
||||
}
|
||||
|
||||
|
||||
$this->tax_split = $tax_split;
|
||||
$this->net_split = $net_split;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function makeTaxSplit()
|
||||
{
|
||||
$tax_split = NULL;
|
||||
$net_split = NULL;
|
||||
|
||||
if($this->tax > 0){
|
||||
$tax_split = [];
|
||||
$net_split = [];
|
||||
|
||||
foreach($this->shopping_order_items as $item){
|
||||
$tax_rate = intval($item->tax_rate);
|
||||
if($tax_rate > 0){
|
||||
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ?
|
||||
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ?
|
||||
round($tax_split[$tax_rate] + ($item->tax * $item->qty), 2) :
|
||||
round(($item->tax * $item->qty), 2);
|
||||
|
||||
$net_split[$tax_rate] = isset($net_split[$tax_rate]) ?
|
||||
round($net_split[$tax_rate] + ($item->price_net * $item->qty), 2) :
|
||||
round(($item->price_net * $item->qty), 2);
|
||||
|
||||
}
|
||||
}
|
||||
if(isset($tax_split[16])){
|
||||
$tax_split[16] = $this->tax;
|
||||
$net_split[16] = $this->subtotal_ws;
|
||||
|
||||
}
|
||||
if(isset($tax_split[19])){
|
||||
$tax_split[19] = $this->tax;
|
||||
$net_split[19] = $this->subtotal_ws;
|
||||
}
|
||||
|
||||
if(isset($tax_split[5])){
|
||||
if(!isset($tax_split[16])){
|
||||
$tax_split[16] = $this->tax;
|
||||
$net_split[16] = $this->subtotal_ws;
|
||||
|
||||
}
|
||||
$tax_split[16] = round($tax_split[16] - $tax_split[5], 2);
|
||||
$net_split[16] = round($net_split[16] - $net_split[5], 2);
|
||||
}
|
||||
if(isset($tax_split[7])){
|
||||
if(!isset($tax_split[19])){
|
||||
$tax_split[19] = $this->tax;
|
||||
$net_split[19] = $this->subtotal_ws;
|
||||
|
||||
}
|
||||
$tax_split[19] = round($tax_split[19] - $tax_split[7], 2);
|
||||
|
||||
$net_split[19] = round($net_split[19] - $net_split[7], 2);
|
||||
}
|
||||
|
||||
foreach($tax_split as $key=>$value){
|
||||
$tax_split[$key] = number_format($value, 2);
|
||||
}
|
||||
foreach($net_split as $key=>$value){
|
||||
$net_split[$key] = number_format($value, 2);
|
||||
}
|
||||
}
|
||||
$this->tax_split = $tax_split;
|
||||
$this->net_split = $net_split;
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue