Merge pull request #8522 from turbo124/v5-develop

Add expense categories if they do not exist on import
This commit is contained in:
David Bomba 2023-05-25 13:35:48 +10:00 committed by GitHub
commit 77004e9272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 1115 additions and 65 deletions

View File

@ -1 +1 @@
5.5.120
5.5.121

View File

@ -119,6 +119,8 @@ class BaseRule implements RuleInterface
public mixed $invoice;
private bool $should_calc_tax = true;
public function __construct()
{
}
@ -128,6 +130,10 @@ class BaseRule implements RuleInterface
return $this;
}
public function shouldCalcTax(): bool
{
return $this->should_calc_tax;
}
/**
* Initializes the tax rule for the entity.
*
@ -176,7 +182,7 @@ class BaseRule implements RuleInterface
* Destination - Client Tax Data
*
*/
// $tax_data = new Response([]);
$tax_data = false;
if($this->seller_region == 'US' && $this->client_region == 'US'){
@ -184,13 +190,11 @@ class BaseRule implements RuleInterface
$company = $this->invoice->company;
/** If no company tax data has been configured, lets do that now. */
if(!$company->origin_tax_data && \DB::transactionLevel() == 0)
/** We should never encounter this scenario */
if(!$company->origin_tax_data)
{
$tp = new TaxProvider($company);
$tp->updateCompanyTaxData();
$company->fresh();
$this->should_calc_tax = false;
return $this;
}
/** If we are in a Origin based state, force the company tax here */
@ -202,14 +206,15 @@ class BaseRule implements RuleInterface
else{
/** Ensures the client tax data has been updated */
if(!$this->client->tax_data && \DB::transactionLevel() == 0) {
// if(!$this->client->tax_data && \DB::transactionLevel() == 0) {
$tp = new TaxProvider($company, $this->client);
$tp->updateClientTaxData();
$this->client->fresh();
}
// $tp = new TaxProvider($company, $this->client);
// $tp->updateClientTaxData();
// $this->client->fresh();
// }
$tax_data = $this->client->tax_data;
if($this->client->tax_data)
$tax_data = $this->client->tax_data;
}
@ -218,7 +223,7 @@ class BaseRule implements RuleInterface
/** Applies the tax data to the invoice */
if($this->invoice instanceof Invoice && $tax_data) {
$this->invoice->tax_data = $tax_data ;
$this->invoice->tax_data = $tax_data;
if(\DB::transactionLevel() == 0)
$this->invoice->saveQuietly();

View File

@ -161,13 +161,15 @@ class Rule extends BaseRule implements RuleInterface
if($this->tax_data?->stateSalesTax == 0) {
$this->tax_rate1 = $this->invoice->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
$this->tax_name1 = $this->invoice->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
$this->tax_name1 = "Sales Tax";
// $this->tax_name1 = $this->invoice->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
return $this;
}
$this->tax_rate1 = $this->tax_data->taxSales * 100;
$this->tax_name1 = "{$this->tax_data->geoState} Sales Tax";
// $this->tax_name1 = "{$this->tax_data->geoState} Sales Tax";
$this->tax_name1 = "Sales Tax";
return $this;
}

View File

@ -170,7 +170,7 @@ class InvoiceItemSum
private function shouldCalculateTax(): self
{
if (!$this->invoice->company->calculate_taxes || !$this->invoice->company->account->isFreeHostedClient()) {
if (!$this->invoice->company->calculate_taxes || $this->invoice->company->account->isFreeHostedClient()) {
$this->calc_tax = false;
return $this;
}
@ -188,7 +188,7 @@ class InvoiceItemSum
->setEntity($this->invoice)
->init();
$this->calc_tax = true;
$this->calc_tax = $this->rule->shouldCalcTax();
return $this;
}

View File

@ -600,6 +600,8 @@ class BaseTransformer
*/
public function getExpenseCategoryId($name)
{
/** @var \App\Models\ExpenseCategory $ec */
$ec = ExpenseCategory::where('company_id', $this->company->id)
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
@ -607,6 +609,13 @@ class BaseTransformer
])
->first();
if($ec)
return $ec->id;
$ec = \App\Factory\ExpenseCategoryFactory::create($this->company->id, $this->company->owner()->id);
$ec->name = $name;
$ec->save();
return $ec ? $ec->id : null;
}

View File

@ -11,16 +11,17 @@
namespace App\Jobs\Client;
use App\DataProviders\USStates;
use App\Models\Client;
use App\Models\Company;
use App\Libraries\MultiDB;
use Illuminate\Bus\Queueable;
use App\DataProviders\USStates;
use App\Utils\Traits\MakesHash;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\Middleware\WithoutOverlapping;
class UpdateTaxData implements ShouldQueue
{
@ -59,7 +60,6 @@ class UpdateTaxData implements ShouldQueue
$tax_provider->updateClientTaxData();
if (!$this->client->state && $this->client->postal_code) {
$this->client->state = USStates::getState($this->client->postal_code);
@ -73,6 +73,11 @@ class UpdateTaxData implements ShouldQueue
nlog("problem getting tax data => ".$e->getMessage());
}
}
public function middleware()
{
return [new WithoutOverlapping($this->company->id)];
}
}

View File

@ -0,0 +1,77 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Jobs\Company;
use App\Models\Client;
use App\Models\Company;
use App\Libraries\MultiDB;
use Illuminate\Bus\Queueable;
use App\Jobs\Client\UpdateTaxData;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use App\Services\Tax\Providers\TaxProvider;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\Middleware\WithoutOverlapping;
class CompanyTaxRate implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 1;
/**
* Create a new job instance.
*
* @param Company $company
*/
public function __construct(public Company $company)
{
}
public function handle()
{
if(!config('services.tax.zip_tax.key')) {
return;
}
MultiDB::setDB($this->company->db);
$tp = new TaxProvider($this->company);
$tp->updateCompanyTaxData();
$tp = null;
Client::query()
->where('company_id', $this->company->id)
->where('is_deleted', false)
->where('country_id', 840)
->whereNotNull('postal_code')
->whereNull('tax_data')
->where('is_tax_exempt', false)
->cursor()
->each(function ($client) {
(new UpdateTaxData($client, $this->company))->handle();
});
}
public function middleware()
{
return [new WithoutOverlapping($this->company->id)];
}
}

View File

@ -904,4 +904,18 @@ class Company extends BaseModel
return $item->id == $this->getSetting('date_format_id');
})->first()->format;
}
public function getInvoiceCert()
{
if($this->e_invoice_certificate)
return base64_decode($this->e_invoice_certificate);
return false;
}
public function getSslPassPhrase()
{
return $this->e_invoice_certificate_passphrase;
}
}

View File

@ -24,7 +24,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property int|null $created_at
* @property int|null $updated_at
* @property int|null $deleted_at
* @property int $is_deleted
* @property bool $is_deleted
* @property string $color
* @property int|null $bank_category_id
* @property-read \App\Models\Expense|null $expense

View File

@ -12,20 +12,21 @@
namespace App\PaymentDrivers\Authorize;
use App\Exceptions\PaymentFailed;
use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\Models\Payment;
use App\Models\SystemLog;
use App\Models\GatewayType;
use App\Models\PaymentHash;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\AuthorizePaymentDriver;
use App\Jobs\Util\SystemLogger;
use App\Utils\Traits\MakesHash;
use net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest;
use App\Exceptions\PaymentFailed;
use App\Models\ClientGatewayToken;
use App\PaymentDrivers\AuthorizePaymentDriver;
use App\PaymentDrivers\Authorize\AuthorizeTransaction;
use net\authorize\api\contract\v1\DeleteCustomerProfileRequest;
use net\authorize\api\controller\DeleteCustomerPaymentProfileController;
use net\authorize\api\controller\DeleteCustomerProfileController;
use net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest;
use net\authorize\api\controller\DeleteCustomerPaymentProfileController;
/**
* Class AuthorizeCreditCard.
@ -68,19 +69,26 @@ class AuthorizeCreditCard
$gateway_customer_reference = $authorise_create_customer->create($data);
$authorise_payment_method = new AuthorizePaymentMethod($this->authorize);
$payment_profile = $authorise_payment_method->addPaymentMethodToClient($gateway_customer_reference, $data);
$payment_profile_id = $payment_profile->getPaymentProfile()->getCustomerPaymentProfileId();
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile_id, $data['amount_with_fee']);
if ($request->has('store_card') && $request->input('store_card') === true) {
$authorise_payment_method = new AuthorizePaymentMethod($this->authorize);
$payment_profile = $authorise_payment_method->addPaymentMethodToClient($gateway_customer_reference, $data);
$payment_profile_id = $payment_profile->getPaymentProfile()->getCustomerPaymentProfileId();
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile_id, $data['amount_with_fee']);
$authorise_payment_method->payment_method = GatewayType::CREDIT_CARD;
$client_gateway_token = $authorise_payment_method->createClientGatewayToken($payment_profile, $gateway_customer_reference);
} else {
//remove the payment profile if we are not storing tokens in our system
$this->removePaymentProfile($gateway_customer_reference, $payment_profile_id);
$authorise_transaction = new AuthorizeTransaction($this->authorize);
$data = $authorise_transaction->chargeCustomer($gateway_customer_reference, $data);
$transaction_id = $data['transaction_id'];
nlog($transaction_id);
}
return $this->handleResponse($data, $request);

View File

@ -0,0 +1,154 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\Authorize;
use App\Models\Invoice;
use App\Utils\Traits\MakesHash;
use net\authorize\api\contract\v1\OrderType;
use App\PaymentDrivers\AuthorizePaymentDriver;
use net\authorize\api\contract\v1\PaymentType;
use net\authorize\api\contract\v1\SettingType;
use net\authorize\api\contract\v1\OpaqueDataType;
use net\authorize\api\contract\v1\ExtendedAmountType;
use net\authorize\api\contract\v1\PaymentProfileType;
use net\authorize\api\contract\v1\TransactionRequestType;
use net\authorize\api\contract\v1\CreateTransactionRequest;
use net\authorize\api\contract\v1\CustomerProfilePaymentType;
use net\authorize\api\controller\CreateTransactionController;
/**
* Class AuthorizeTransaction.
*/
class AuthorizeTransaction
{
use MakesHash;
public function __construct(public AuthorizePaymentDriver $authorize)
{
$this->authorize = $authorize;
}
public function chargeCustomer(string $profile_id, array $data)
{
$this->authorize->init();
// Set the transaction's refId
$refId = 'ref'.time();
$op = new OpaqueDataType();
$op->setDataDescriptor($data['dataDescriptor']);
$op->setDataValue($data['dataValue']);
$paymentOne = new PaymentType();
$paymentOne->setOpaqueData($op);
$amount = $data['amount_with_fee'];
$invoice_numbers = '';
$po_numbers = '';
$taxAmount = 0;
$invoiceTotal = 0;
$invoiceTaxes = 0;
if ($this->authorize->payment_hash->data) {
$invoice_numbers = collect($this->authorize->payment_hash->data->invoices)->pluck('invoice_number')->implode(',');
$invObj = Invoice::whereIn('id', $this->transformKeys(array_column($this->authorize->payment_hash->invoices(), 'invoice_id')))->withTrashed()->get();
$po_numbers = $invObj->pluck('po_number')->implode(',');
$invoiceTotal = round($invObj->pluck('amount')->sum(), 2);
$invoiceTaxes = round($invObj->pluck('total_taxes')->sum(), 2);
if ($invoiceTotal != $amount) {
$taxRatio = $amount / $invoiceTotal;
$taxAmount = round($invoiceTaxes * $taxRatio, 2);
} else {
$taxAmount = $invoiceTaxes;
}
}
$description = "Invoices: {$invoice_numbers} for {$amount} for client {$this->authorize->client->present()->name()}";
$order = new OrderType();
$order->setInvoiceNumber(substr($invoice_numbers, 0, 19));
$order->setDescription(substr($description, 0, 255));
$order->setSupplierOrderReference(substr($po_numbers, 0, 19));// 04-03-2023
$tax = new ExtendedAmountType();
$tax->setName('tax');
$tax->setAmount($taxAmount);
// Add values for transaction settings
$duplicateWindowSetting = new SettingType();
$duplicateWindowSetting->setSettingName("duplicateWindow");
$duplicateWindowSetting->setSettingValue("60");
$transactionRequestType = new TransactionRequestType();
$transactionRequestType->setTransactionType('authCaptureTransaction');
$transactionRequestType->setAmount($amount);
$transactionRequestType->setTax($tax);
$transactionRequestType->setTaxExempt(empty($taxAmount));
$transactionRequestType->setOrder($order);
$transactionRequestType->addToTransactionSettings($duplicateWindowSetting);
$transactionRequestType->setPayment($paymentOne);
// $transactionRequestType->setProfile($profileToCharge);
$transactionRequestType->setCurrencyCode($this->authorize->client->currency()->code);
$request = new CreateTransactionRequest();
$request->setMerchantAuthentication($this->authorize->merchant_authentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequestType);
$controller = new CreateTransactionController($request);
$response = $controller->executeWithApiResponse($this->authorize->mode());
if ($response != null && $response->getMessages()->getResultCode() == 'Ok') {
$tresponse = $response->getTransactionResponse();
if ($tresponse != null && $tresponse->getMessages() != null) {
nlog(' Transaction Response code : '.$tresponse->getResponseCode());
nlog(' Charge Customer Profile APPROVED :');
nlog(' Charge Customer Profile AUTH CODE : '.$tresponse->getAuthCode());
nlog(' Charge Customer Profile TRANS ID : '.$tresponse->getTransId());
nlog(' Code : '.$tresponse->getMessages()[0]->getCode());
nlog(' Description : '.$tresponse->getMessages()[0]->getDescription());
nlog(print_r($tresponse->getMessages()[0], 1));
} else {
nlog('Transaction Failed ');
if ($tresponse->getErrors() != null) {
nlog(' Error code : '.$tresponse->getErrors()[0]->getErrorCode());
nlog(' Error message : '.$tresponse->getErrors()[0]->getErrorText());
nlog(print_r($tresponse->getErrors()[0], 1));
}
}
} else {
nlog('Transaction Failed ');
$tresponse = $response->getTransactionResponse();
if ($tresponse != null && $tresponse->getErrors() != null) {
nlog(' Error code : '.$tresponse->getErrors()[0]->getErrorCode());
nlog(' Error message : '.$tresponse->getErrors()[0]->getErrorText());
nlog(print_r($tresponse->getErrors()[0], 1));
} else {
nlog(' Error code : '.$response->getMessages()->getMessage()[0]->getCode());
nlog(' Error message : '.$response->getMessages()->getMessage()[0]->getText());
}
}
return [
'response' => $tresponse,
'amount' => $amount,
'profile_id' => $profile_id,
'transaction_id' => $tresponse->getTransId()
// 'payment_profile_id' => $payment_profile_id,
];
}
}

View File

@ -174,9 +174,9 @@ class FacturaEInvoice extends AbstractService
$disk = config('filesystems.default');
if (!Storage::disk($disk)->exists($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()))) {
Storage::makeDirectory($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()));
}
// if (!Storage::disk($disk)->exists($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()))) {
// Storage::makeDirectory($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()));
// }
$this->fac->export(Storage::disk($disk)->path($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xsig")));
@ -386,9 +386,12 @@ class FacturaEInvoice extends AbstractService
private function signDocument(): self
{
// $ssl_cert = file_get_contents(base_path('e_invoice_cert.p12'));
// $this->fac->sign($ssl_cert, null, "SuperSecretPassword");
$ssl_cert = $this->invoice->company->getInvoiceCert();
$ssl_passphrase = $this->invoice->company->getSslPassPhrase();
if($ssl_cert)
$this->fac->sign($ssl_cert, null, $ssl_passphrase);
return $this;
}

View File

@ -56,7 +56,12 @@ class TaxProvider
{
}
/**
* updateCompanyTaxData
*
* @return self
*/
public function updateCompanyTaxData(): self
{
$this->configureProvider($this->provider, $this->company->country()->iso_3166_2); //hard coded for now to one provider, but we'll be able to swap these out later
@ -83,7 +88,12 @@ class TaxProvider
return $this;
}
/**
* updateClientTaxData
*
* @return self
*/
public function updateClientTaxData(): self
{
$this->configureProvider($this->provider, $this->client->country->iso_3166_2); //hard coded for now to one provider, but we'll be able to swap these out later
@ -106,8 +116,9 @@ class TaxProvider
'country_id' => $this->client->shipping_country_id,
];
$tax_provider = new $this->provider($billing_details);
$taxable_address = $this->taxShippingAddress() ? $shipping_details : $billing_details;
$tax_provider = new $this->provider($taxable_address);
$tax_provider->setApiCredentials($this->api_credentials);
@ -120,7 +131,29 @@ class TaxProvider
return $this;
}
/**
* taxShippingAddress
*
* @return bool
*/
private function taxShippingAddress(): bool
{
if($this->client->shipping_country_id == "840" && strlen($this->client->shipping_postal_code) > 3)
return true;
return false;
}
/**
* configureProvider
*
* @param string $provider
* @param string $country_code
* @return self
*/
private function configureProvider(?string $provider, string $country_code): self
{
@ -159,21 +192,36 @@ class TaxProvider
return $this;
}
/**
* configureEuTax
*
* @return self
*/
private function configureEuTax(): self
{
$this->provider = EuTax::class;
return $this;
}
/**
* noTaxRegionDefined
*
* @return void
*/
private function noTaxRegionDefined()
{
throw new \Exception("No tax region defined for this country");
// return $this;
}
/**
* configureZipTax
*
* @return self
*/
private function configureZipTax(): self
{

View File

@ -15,6 +15,7 @@ use stdClass;
use App\Utils\Ninja;
use App\Models\Company;
use App\DataMapper\CompanySettings;
use App\Jobs\Company\CompanyTaxRate;
/**
* Class CompanySettingsSaver.
@ -78,15 +79,23 @@ trait CompanySettingsSaver
$entity->settings = $company_settings;
if(Ninja::isHosted() && array_key_exists('settings', $entity->getDirty()))
if( $entity?->calculate_taxes && $company_settings->country_id == "840" && array_key_exists('settings', $entity->getDirty()))
{
$old_settings = $entity->getOriginal()['settings'];
if($settings->name != $old_settings->name) {
nlog("name change {$old_settings->name} -> {$settings->name} ");
/** Monitor changes of the Postal code */
if($old_settings->postal_code != $company_settings->postal_code)
{
nlog("postal code change");
CompanyTaxRate::dispatch($entity);
}
}
elseif( $entity?->calculate_taxes && $company_settings->country_id == "840" && array_key_exists('calculate_taxes', $entity->getDirty()) && $entity->getOriginal('calculate_taxes') == 0)
{
nlog("calc taxes change");
nlog($entity->getOriginal('calculate_taxes'));
CompanyTaxRate::dispatch($entity);
}

View File

@ -15,8 +15,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => '5.5.120',
'app_tag' => '5.5.120',
'app_version' => '5.5.121',
'app_tag' => '5.5.121',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),

View File

@ -11940,7 +11940,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/FillableInvoice"
$ref: "#/components/schemas/InvoiceRequest"
responses:
200:
description: "Returns the saved invoice entity"
@ -15300,7 +15300,11 @@ components:
description: 'An array of objects which define the line items of the invoice'
items:
$ref: '#/components/schemas/InvoiceItem'
invitations:
type: array
description: 'An array of objects which define the invitations of the invoice'
items:
$ref: '#/components/schemas/InvoiceInvitation'
amount:
description: 'The invoice amount'
type: number
@ -17089,6 +17093,66 @@ components:
type: string
example: google
type: object
InvoiceInvitationRequest:
required:
- client_contact_id
properties:
id:
description: 'The entity invitation hashed id'
type: string
example: Opnel5aKBz
readOnly: true
client_contact_id:
description: 'The client contact hashed id'
type: string
example: Opnel5aKBz
key:
description: 'The invitation key'
type: string
example: Opnel5aKBz4343343566236gvbb
readOnly: true
link:
description: 'The invitation link'
type: string
example: 'https://www.example.com/invitations/Opnel5aKBz4343343566236gvbb'
readOnly: true
sent_date:
description: 'The invitation sent date'
type: string
format: date-time
readOnly: true
viewed_date:
description: 'The invitation viewed date'
type: string
format: date-time
readOnly: true
opened_date:
description: 'The invitation opened date'
type: string
format: date-time
readOnly: true
updated_at:
description: 'Timestamp'
type: number
format: integer
example: '1434342123'
readOnly: true
archived_at:
description: 'Timestamp'
type: number
format: integer
example: '1434342123'
readOnly: true
email_error:
description: 'The email error'
type: string
example: 'The email error'
readOnly: true
email_status:
description: 'The email status'
type: string
readOnly: true
ClientRequest:
required:
- contacts
@ -18632,6 +18696,64 @@ components:
format: integer
example: '1434342123'
type: object
InvoiceInvitation:
properties:
id:
description: 'The entity invitation hashed id'
type: string
example: Opnel5aKBz
readOnly: true
client_contact_id:
description: 'The client contact hashed id'
type: string
example: Opnel5aKBz
key:
description: 'The invitation key'
type: string
example: Opnel5aKBz4343343566236gvbb
readOnly: true
link:
description: 'The invitation link'
type: string
example: 'https://www.example.com/invitations/Opnel5aKBz4343343566236gvbb'
readOnly: true
sent_date:
description: 'The invitation sent date'
type: string
format: date-time
readOnly: true
viewed_date:
description: 'The invitation viewed date'
type: string
format: date-time
readOnly: true
opened_date:
description: 'The invitation opened date'
type: string
format: date-time
readOnly: true
updated_at:
description: 'Timestamp'
type: number
format: integer
example: '1434342123'
readOnly: true
archived_at:
description: 'Timestamp'
type: number
format: integer
example: '1434342123'
readOnly: true
email_error:
description: 'The email error'
type: string
example: 'The email error'
readOnly: true
email_status:
description: 'The email status'
type: string
readOnly: true
RecurringQuote:
properties:
id:
@ -19249,6 +19371,243 @@ components:
type: object
InvoiceRequest:
required:
- client_id
properties:
id:
description: 'The invoice hashed id'
type: string
example: Opnel5aKBz
readOnly: true
user_id:
description: 'The user hashed id'
type: string
example: Opnel5aKBz
assigned_user_id:
description: 'The assigned user hashed id'
type: string
example: Opnel5aKBz
company_id:
description: 'The company hashed id'
type: string
example: Opnel5aKBz
readOnly: true
client_id:
description: 'The client hashed id'
type: string
example: Opnel5aKBz
status_id:
description: 'The invoice status variable'
type: string
example: '4'
readOnly: true
number:
description: 'The invoice number - is a unique alpha numeric number per invoice per company'
type: string
example: INV_101
po_number:
description: 'The purchase order associated with this invoice'
type: string
example: PO-1234
terms:
description: 'The invoice terms'
type: string
example: 'These are invoice terms'
public_notes:
description: 'The public notes of the invoice'
type: string
example: 'These are some public notes'
private_notes:
description: 'The private notes of the invoice'
type: string
example: 'These are some private notes'
footer:
description: 'The invoice footer notes'
type: string
example: ''
custom_value1:
description: 'A custom field value'
type: string
example: '2022-10-01'
custom_value2:
description: 'A custom field value'
type: string
example: 'Something custom'
custom_value3:
description: 'A custom field value'
type: string
example: ''
custom_value4:
description: 'A custom field value'
type: string
example: ''
tax_name1:
description: 'The tax name'
type: string
example: ''
tax_name2:
description: 'The tax name'
type: string
example: ''
tax_rate1:
description: 'The tax rate'
type: number
format: float
example: '10.00'
tax_rate2:
description: 'The tax rate'
type: number
format: float
example: '10.00'
tax_name3:
description: 'The tax name'
type: string
example: ''
tax_rate3:
description: 'The tax rate'
type: number
format: float
example: '10.00'
total_taxes:
description: 'The total taxes for the invoice'
type: number
format: float
example: '10.00'
readOnly:
line_items:
type: array
description: 'An array of objects which define the line items of the invoice'
items:
$ref: '#/components/schemas/InvoiceItem'
invitations:
type: array
description: 'An array of objects which define the invitations of the invoice'
items:
$ref: '#/components/schemas/InvoiceInvitationRequest'
amount:
description: 'The invoice amount'
type: number
format: float
example: '10.00'
readOnly: true
balance:
description: 'The invoice balance'
type: number
format: float
example: '10.00'
readOnly: true
paid_to_date:
description: 'The amount paid on the invoice to date'
type: number
format: float
example: '10.00'
readOnly: true
discount:
description: 'The invoice discount, can be an amount or a percentage'
type: number
format: float
example: '10.00'
partial:
description: 'The deposit/partial amount'
type: number
format: float
example: '10.00'
is_amount_discount:
description: 'Flag determining if the discount is an amount or a percentage'
type: boolean
example: true
is_deleted:
description: 'Defines if the invoice has been deleted'
type: boolean
example: true
readOnly: true
uses_inclusive_taxes:
description: 'Defines the type of taxes used as either inclusive or exclusive'
type: boolean
example: true
date:
description: 'The Invoice Date'
type: string
format: date
example: '1994-07-30'
last_sent_date:
description: 'The last date the invoice was sent out'
type: string
format: date
example: '1994-07-30'
readOnly: true
next_send_date:
description: 'The Next date for a reminder to be sent'
type: string
format: date
example: '1994-07-30'
readOnly: true
partial_due_date:
description: 'The due date for the deposit/partial amount'
type: string
format: date
example: '1994-07-30'
due_date:
description: 'The due date of the invoice'
type: string
format: date
example: '1994-07-30'
last_viewed:
description: Timestamp
type: number
format: integer
example: '1434342123'
readOnly: true
updated_at:
description: Timestamp
type: number
format: integer
example: '1434342123'
readOnly: true
archived_at:
description: Timestamp
type: number
format: integer
example: '1434342123'
readOnly: true
custom_surcharge1:
description: 'First Custom Surcharge'
type: number
format: float
example: '10.00'
custom_surcharge2:
description: 'Second Custom Surcharge'
type: number
format: float
example: '10.00'
custom_surcharge3:
description: 'Third Custom Surcharge'
type: number
format: float
example: '10.00'
custom_surcharge4:
description: 'Fourth Custom Surcharge'
type: number
format: float
example: '10.00'
custom_surcharge_tax1:
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
custom_surcharge_tax2:
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
custom_surcharge_tax3:
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
custom_surcharge_tax4:
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
type: object
ClientContact:
properties:
id:

View File

@ -101,7 +101,11 @@
description: 'An array of objects which define the line items of the invoice'
items:
$ref: '#/components/schemas/InvoiceItem'
invitations:
type: array
description: 'An array of objects which define the invitations of the invoice'
items:
$ref: '#/components/schemas/InvoiceInvitation'
amount:
description: 'The invoice amount'
type: number

View File

@ -0,0 +1,57 @@
InvoiceInvitation:
properties:
id:
description: 'The entity invitation hashed id'
type: string
example: Opnel5aKBz
readOnly: true
client_contact_id:
description: 'The client contact hashed id'
type: string
example: Opnel5aKBz
key:
description: 'The invitation key'
type: string
example: Opnel5aKBz4343343566236gvbb
readOnly: true
link:
description: 'The invitation link'
type: string
example: 'https://www.example.com/invitations/Opnel5aKBz4343343566236gvbb'
readOnly: true
sent_date:
description: 'The invitation sent date'
type: string
format: date-time
readOnly: true
viewed_date:
description: 'The invitation viewed date'
type: string
format: date-time
readOnly: true
opened_date:
description: 'The invitation opened date'
type: string
format: date-time
readOnly: true
updated_at:
description: 'Timestamp'
type: number
format: integer
example: '1434342123'
readOnly: true
archived_at:
description: 'Timestamp'
type: number
format: integer
example: '1434342123'
readOnly: true
email_error:
description: 'The email error'
type: string
example: 'The email error'
readOnly: true
email_status:
description: 'The email status'
type: string
readOnly: true

View File

@ -0,0 +1,59 @@
InvoiceInvitationRequest:
required:
- client_contact_id
properties:
id:
description: 'The entity invitation hashed id'
type: string
example: Opnel5aKBz
readOnly: true
client_contact_id:
description: 'The client contact hashed id'
type: string
example: Opnel5aKBz
key:
description: 'The invitation key'
type: string
example: Opnel5aKBz4343343566236gvbb
readOnly: true
link:
description: 'The invitation link'
type: string
example: 'https://www.example.com/invitations/Opnel5aKBz4343343566236gvbb'
readOnly: true
sent_date:
description: 'The invitation sent date'
type: string
format: date-time
readOnly: true
viewed_date:
description: 'The invitation viewed date'
type: string
format: date-time
readOnly: true
opened_date:
description: 'The invitation opened date'
type: string
format: date-time
readOnly: true
updated_at:
description: 'Timestamp'
type: number
format: integer
example: '1434342123'
readOnly: true
archived_at:
description: 'Timestamp'
type: number
format: integer
example: '1434342123'
readOnly: true
email_error:
description: 'The email error'
type: string
example: 'The email error'
readOnly: true
email_status:
description: 'The email status'
type: string
readOnly: true

View File

@ -0,0 +1,237 @@
InvoiceRequest:
required:
- client_id
properties:
id:
description: 'The invoice hashed id'
type: string
example: Opnel5aKBz
readOnly: true
user_id:
description: 'The user hashed id'
type: string
example: Opnel5aKBz
assigned_user_id:
description: 'The assigned user hashed id'
type: string
example: Opnel5aKBz
company_id:
description: 'The company hashed id'
type: string
example: Opnel5aKBz
readOnly: true
client_id:
description: 'The client hashed id'
type: string
example: Opnel5aKBz
status_id:
description: 'The invoice status variable'
type: string
example: '4'
readOnly: true
number:
description: 'The invoice number - is a unique alpha numeric number per invoice per company'
type: string
example: INV_101
po_number:
description: 'The purchase order associated with this invoice'
type: string
example: PO-1234
terms:
description: 'The invoice terms'
type: string
example: 'These are invoice terms'
public_notes:
description: 'The public notes of the invoice'
type: string
example: 'These are some public notes'
private_notes:
description: 'The private notes of the invoice'
type: string
example: 'These are some private notes'
footer:
description: 'The invoice footer notes'
type: string
example: ''
custom_value1:
description: 'A custom field value'
type: string
example: '2022-10-01'
custom_value2:
description: 'A custom field value'
type: string
example: 'Something custom'
custom_value3:
description: 'A custom field value'
type: string
example: ''
custom_value4:
description: 'A custom field value'
type: string
example: ''
tax_name1:
description: 'The tax name'
type: string
example: ''
tax_name2:
description: 'The tax name'
type: string
example: ''
tax_rate1:
description: 'The tax rate'
type: number
format: float
example: '10.00'
tax_rate2:
description: 'The tax rate'
type: number
format: float
example: '10.00'
tax_name3:
description: 'The tax name'
type: string
example: ''
tax_rate3:
description: 'The tax rate'
type: number
format: float
example: '10.00'
total_taxes:
description: 'The total taxes for the invoice'
type: number
format: float
example: '10.00'
readOnly:
line_items:
type: array
description: 'An array of objects which define the line items of the invoice'
items:
$ref: '#/components/schemas/InvoiceItem'
invitations:
type: array
description: 'An array of objects which define the invitations of the invoice'
items:
$ref: '#/components/schemas/InvoiceInvitationRequest'
amount:
description: 'The invoice amount'
type: number
format: float
example: '10.00'
readOnly: true
balance:
description: 'The invoice balance'
type: number
format: float
example: '10.00'
readOnly: true
paid_to_date:
description: 'The amount paid on the invoice to date'
type: number
format: float
example: '10.00'
readOnly: true
discount:
description: 'The invoice discount, can be an amount or a percentage'
type: number
format: float
example: '10.00'
partial:
description: 'The deposit/partial amount'
type: number
format: float
example: '10.00'
is_amount_discount:
description: 'Flag determining if the discount is an amount or a percentage'
type: boolean
example: true
is_deleted:
description: 'Defines if the invoice has been deleted'
type: boolean
example: true
readOnly: true
uses_inclusive_taxes:
description: 'Defines the type of taxes used as either inclusive or exclusive'
type: boolean
example: true
date:
description: 'The Invoice Date'
type: string
format: date
example: '1994-07-30'
last_sent_date:
description: 'The last date the invoice was sent out'
type: string
format: date
example: '1994-07-30'
readOnly: true
next_send_date:
description: 'The Next date for a reminder to be sent'
type: string
format: date
example: '1994-07-30'
readOnly: true
partial_due_date:
description: 'The due date for the deposit/partial amount'
type: string
format: date
example: '1994-07-30'
due_date:
description: 'The due date of the invoice'
type: string
format: date
example: '1994-07-30'
last_viewed:
description: Timestamp
type: number
format: integer
example: '1434342123'
readOnly: true
updated_at:
description: Timestamp
type: number
format: integer
example: '1434342123'
readOnly: true
archived_at:
description: Timestamp
type: number
format: integer
example: '1434342123'
readOnly: true
custom_surcharge1:
description: 'First Custom Surcharge'
type: number
format: float
example: '10.00'
custom_surcharge2:
description: 'Second Custom Surcharge'
type: number
format: float
example: '10.00'
custom_surcharge3:
description: 'Third Custom Surcharge'
type: number
format: float
example: '10.00'
custom_surcharge4:
description: 'Fourth Custom Surcharge'
type: number
format: float
example: '10.00'
custom_surcharge_tax1:
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
custom_surcharge_tax2:
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
custom_surcharge_tax3:
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
custom_surcharge_tax4:
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
type: object

View File

@ -135,7 +135,7 @@
content:
application/json:
schema:
$ref: "#/components/schemas/FillableInvoice"
$ref: "#/components/schemas/InvoiceRequest"
responses:
200:
description: "Returns the saved invoice entity"

View File

@ -200,7 +200,7 @@ class SumTaxTest extends TestCase
$line_items = $invoice->line_items;
$this->assertEquals(10.88, $invoice->amount);
$this->assertEquals("CA Sales Tax", $line_items[0]->tax_name1);
$this->assertEquals("Sales Tax", $line_items[0]->tax_name1);
$this->assertEquals(8.75, $line_items[0]->tax_rate1);
}