Dostlar merhaba Bir array'im var içeriği bu şekilde https://prnt.sc/I-i7HVHYavcq ben bunu foreach'e sokup obje olarak ulaşmaya çalıştığım da değerlere ulaşamıyorum. true yazıyor ekrana bastığım da foreach ile çıkan değeri
https://prnt.sc/IqHNb7c4xNan
Bu kod bloğu daha önce çalışıyordu. Fatura kesimi için verileri turkcell'e göndermem gerekiyor fakat patlıyor foreach'e girince
Hata bu https://prnt.sc/vMQOR5IbhMEy
foreach sanki array olan veriyi döndürmüyor gibi. Bunu tam olarak nasıl çözebilirim
foreach ($lines as $lineKey => $line) {
/** @var PaymentProduct $paymentProduct */
$invoiceLine = new InvoiceLineModel();
$invoiceLine->setDisableVatExemption(true);
$invoiceLine->setInventoryCard($line->product->name);
$invoiceLine->setAmount($line->qty ? $line->qty : 1);
$invoiceLine->setUnitPrice($line->item_data['main_price']);
$invoiceLine->setUnitCode('C62');
$invoiceLine->setVatRate($line->tax);
$invoiceLine->setLineAmount($line->grand_total);
$amount = $line->grand_total;
$invoiceCount = $line->qty ? $line->qty : 1;
$totalDiscountAmount = 0;
if ($line->discount) {
$totalDiscountAmount = $line->discount;
$invoiceLine->setDiscountAmount($line->discount);
$invoiceLine->setDiscountRate($line->discount * 100 / $amount);
}
if($line->discountCode) {
$price = $line->item_data['main_price'];
if( $line->item_data['discount_type'] == '%' ) {
$discountTotal = (($price * $line->discountCode->amount) / 100)*$invoiceCount;
$totalDiscountAmount = $discountTotal;
$invoiceLine->setDiscountAmount($discountTotal);
$invoiceLine->setDiscountRate($line->discountCode->amount);
}else if( $line->item_data['discount_type'] == 'TL' ) {
$totalDiscountAmount = ($line->discountCode->amount)*$invoiceCount;
$invoiceLine->setDiscountAmount($totalDiscountAmount);
$discountRate = (100 * $line->discountCode->amount) / ($price + $line->discountCode->amount);
$invoiceLine->setDiscountRate($discountRate);
}
}
if($line->wallet_status) {
$price = $line->item_data['main_price'];
$totalDiscountAmount = $totalDiscountAmount + $line->wallet_status;
$discountRate = (100 * $totalDiscountAmount) / ($price + $totalDiscountAmount);
$invoiceLine->setDiscountAmount($totalDiscountAmount);
$invoiceLine->setDiscountRate($discountRate);
}
// $subtotal = $amount - $line->grand_total;
$invoiceLines[] = $invoiceLine->getJsonObject();
}