Skip to content

Commit

Permalink
Kusurattan kaynaklanan faturayi tahsil edildi yapamama sorunu giderildi
Browse files Browse the repository at this point in the history
  • Loading branch information
trsalyangoz committed Feb 23, 2017
1 parent 0322d5f commit fb1ea55
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Marketplace/N11.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
{
Expand Down
19 changes: 14 additions & 5 deletions src/Services/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,38 @@ 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);

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")
{
Expand Down

0 comments on commit fb1ea55

Please sign in to comment.