From fb1ea55aaa34440182544dcbd5324cc3c9734cce Mon Sep 17 00:00:00 2001 From: trsalyangoz Date: Thu, 23 Feb 2017 19:07:35 +0300 Subject: [PATCH] Kusurattan kaynaklanan faturayi tahsil edildi yapamama sorunu giderildi --- src/Marketplace/N11.php | 4 ++-- src/Services/Push.php | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Marketplace/N11.php b/src/Marketplace/N11.php index a304b84..a482955 100644 --- a/src/Marketplace/N11.php +++ b/src/Marketplace/N11.php @@ -134,7 +134,7 @@ protected function processSale($sale) $taxNumber = $sale->buyer->taxId; $taxOffice = $sale->buyer->taxOffice; $tc = self::fillTc($sale->buyer->tcId); - $name2 = $sale->buyer->fullName ?: $sale->shippingAddress->fullname; + $name2 = isset($sale->buyer->fullName) ? $sale->buyer->fullName : $sale->shippingAddress->fullname; $pull = new Pull($this->marketplace); $pull->createCustomer($contactType, $sale->buyer->id, $sale->billingAddress->fullName, @@ -145,7 +145,7 @@ protected function processSale($sale) $createdAt = Carbon::createFromFormat('d/m/Y H:i',$sale->createDate); - $pull->createOrder($sale->orderNumber, $sale->billingTemplate->sellerInvoiceAmount, "N11 ".$invoiceDescription, $createdAt); + $pull->createOrder($sale->orderNumber, $sale->billingTemplate->sellerInvoiceAmount - $sale->billingTemplate->totalServiceItemOriginalPrice, "N11 ".$invoiceDescription, $createdAt); foreach ($sale->itemList as $item) { diff --git a/src/Services/Push.php b/src/Services/Push.php index d47140c..e4c9698 100644 --- a/src/Services/Push.php +++ b/src/Services/Push.php @@ -72,17 +72,21 @@ private function pushInvoice(Order $order) 'contact_id' => $order->customer->parasut_id ]; + $total = 0; foreach ($order->orderProduct()->get() as $item) { + + $price = ($item->price) / (1 + 0.18); $details['details_attributes'][] = [ 'product_id' => $this->pushProduct($item->product), 'quantity' => $item->quantity, 'discount_value' => 0, 'discount_type' => 'amount', - 'unit_price' => ($item->price) / (1 + 0.18), + 'unit_price' => $price, 'vat_rate' => 0.18 * 100, ]; + } $invoice = $this->parasut->make('sale')->create($details); @@ -90,11 +94,16 @@ private function pushInvoice(Order $order) if($invoiceID = $invoice['sales_invoice']['id']) { try{ - $status = $this->parasut->make('sale')->paid($invoiceID, - ["amount" => $order->amount, + $invoice = $this->parasut->make('sale')->find($invoiceID); + + if($invoice['sales_invoice']['remaining'] > 0) { + $status = $this->parasut->make('sale')->paid($invoiceID, + ["amount" => $invoice['sales_invoice']['remaining'], "date" => date('Y-m-d'), - "account_id"=> Config('pazaryeri-parasut.parasut_account_id')] - ); + "account_id"=> Config('pazaryeri-parasut.parasut_account_id')]); + }else{ + $status['status'] = "success"; + } if($status['status'] == "success") {