1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

minor fixes

This commit is contained in:
David Bomba 2024-09-25 10:27:14 +10:00
parent 9d6d6c2254
commit aca1f3c413
3 changed files with 115 additions and 2 deletions

View File

@ -390,6 +390,7 @@ class BaseImport
try {
$invoice_data = $invoice_transformer->transform($raw_invoice);
$invoice_data['user_id'] = $this->company->owner()->id;
$invoice_data['line_items'] = $this->cleanItems(
$invoice_data['line_items'] ?? []

View File

@ -83,6 +83,11 @@ class QbClient implements SyncInterface
{
}
public function sync(string $id, string $last_updated): void
{
}
private function findClient(string $key): ?Client
{
$search = Client::query()

View File

@ -41,16 +41,123 @@ class QuickbooksTest extends TestCase
elseif(Company::whereNotNull('quickbooks')->count() == 0){
$this->markTestSkipped('No need to run this test on Travis');
}
$this->makeTestData();
}
public function testCreateInvoiceInQb()
public function testCreateCustomerInQb()
{
$c = Company::whereNotNull('quickbooks')->first();
$qb = new QuickbooksService($c);
$customerData = [
"DisplayName" => $this->client->present()->name(), // Required and must be unique
"PrimaryEmailAddr" => [
"Address" => $this->client->present()->email(),
],
"PrimaryPhone" => [
"FreeFormNumber" => $this->client->present()->phone()
],
"CompanyName" => $this->client->present()->name(),
"BillAddr" => [
"Line1" => $this->client->address1 ?? '',
"City" => $this->client->city ?? '',
"CountrySubDivisionCode" => $this->client->state ?? '',
"PostalCode" => $this->client->postal_code ?? '',
"Country" => $this->client->country->iso_3166_3
],
"ShipAddr" => [
"Line1" => $this->client->shipping_address1 ?? '',
"City" => $this->client->shipping_city ?? '',
"CountrySubDivisionCode" => $this->client->shipping_state ?? '',
"PostalCode" => $this->client->shipping_postal_code ?? '',
"Country" => $this->client->shipping_country->iso_3166_3
],
"GivenName" => $this->client->present()->first_name(),
"FamilyName" => $this->client->present()->last_name(),
"PrintOnCheckName" => $this->client->present()->primary_contact_name(),
"Notes" => $this->client->public_notes,
// "TaxIdentifier" => $this->client->vat_number ?? '', // Federal Employer Identification Number (EIN)
"BusinessNumber" => $this->client->id_number ?? '',
"Active" => $this->client->deleted_at ? false : true,
"V4IDPseudonym" => $this->client->client_hash,
"WebAddr" => $this->client->website ?? '',
];
$customer = \QuickBooksOnline\API\Facades\Customer::create($customerData);
// $customer = $qb->sdk->createCustomer($customerData);
$this->assertNotNull($customer);
nlog($customer);
// Send the create request to QuickBooks
$resultingCustomerObj = $qb->sdk->Add($customer);
// Check for errors
$error = $qb->sdk->getLastError();
if ($error) {
$this->fail("The Customer could not be created: " . $error->getResponseBody());
}
nlog($resultingCustomerObj);
}
// public function testCreateInvoiceInQb()
// {
// $c = Company::whereNotNull('quickbooks')->first();
// $qb = new QuickbooksService($c);
// //create QB customer
// //create ninja invoice
// //create QB invoice
// }
public function stubData()
{
// Inside the create method
$lineItems = [
[
"Amount" => 100.00,
"DetailType" => "SalesItemLineDetail",
"SalesItemLineDetail" => [
"ItemRef" => [
"value" => "1", // Replace with actual Item ID from QuickBooks
"name" => "Services"
]
]
]
];
$invoiceData = [
"Line" => $lineItems,
"CustomerRef" => [
"value" => "1", // Replace with actual Customer ID from QuickBooks
],
"BillEmail" => [
"Address" => "customer@example.com"
],
"DueDate" => "2023-12-31",
"TotalAmt" => 100.00,
"DocNumber" => "INV-001"
];
$invoice = QbInvoice::create($invoiceData);
}
}