From dd0e26122e670b29a2495322698a177bc381c5b4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 24 May 2024 17:42:16 +1000 Subject: [PATCH] Stubs for paypal imports --- .../Sources/PayPalBalanceAffecting.php | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/app/DataMapper/Sources/PayPalBalanceAffecting.php b/app/DataMapper/Sources/PayPalBalanceAffecting.php index b2ced838972d..ad11c0340bb6 100644 --- a/app/DataMapper/Sources/PayPalBalanceAffecting.php +++ b/app/DataMapper/Sources/PayPalBalanceAffecting.php @@ -144,7 +144,7 @@ class PayPalBalanceAffecting $item->quantity = 1; return [ - 'number' => $this->invoiceNumber ?? $this->transactionId, + 'number' => trim($this->invoiceNumber ?? $this->transactionId), 'date' => str_replace('/','-', $this->date ?? ''), 'line_items' => [$item], 'name' => $this->name ?? '', @@ -213,3 +213,66 @@ class PayPalBalanceAffecting return $this->type == 'Website Payment'; } } + + + +// $csv = Reader::createFromString($csvFile); +// // $csvdelimiter = self::detectDelimiter($csvfile); +// $csv->setDelimiter(","); +// $stmt = new Statement(); +// $data = iterator_to_array($stmt->process($csv)); + +// $header = $data[0]; +// $arr = []; + +// foreach($data as $key => $value) { + + +// if($key == 0) { +// continue; +// } + +// $arr[] = array_combine($header, $value); + +// } + +// $arr; + +// $company = Company::find(3358); +// $owner = $company->owner(); +// $client_repo = new ClientRepository(new ClientContactRepository()); +// $invoice_repo = new InvoiceRepository(); + +// foreach($arr as $pp) { + +// $p = new PayPalBalanceAffecting($pp); +// $p->run(); + + +// if(!$p->isInvoiceType()) { +// continue; +// } + +// $import_c = $p->getClient(); +// $import_i = $p->getInvoice(); + + +// $contact = ClientContact::where('company_id', 3358)->where('email', $import_c['email'])->first(); + + +// if(!$contact) { + +// $cc = ClientFactory::create($company->id, $owner->id); + +// $client = $client_repo->save($import_c, $cc); + +// } else { +// $client = $contact->client; +// } + +// $i = InvoiceFactory::create($company->id, $owner->id); +// $i->client_id = $client->id; +// $invoice_repo->save($import_i, $i); + + +// }