mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 18:48:39 -04:00 
			
		
		
		
	
						commit
						0fcfe24b54
					
				| @ -236,7 +236,7 @@ class CreateSingleAccount extends Command | ||||
|         $client->id_number = $this->getNextClientNumber($client); | ||||
| 
 | ||||
|         $settings = $client->settings; | ||||
|         $settings->currency_id = (string) rand(1, 79); | ||||
|         $settings->currency_id = "1"; | ||||
|         $client->settings = $settings; | ||||
| 
 | ||||
|         $country = Country::all()->random(); | ||||
|  | ||||
| @ -287,4 +287,6 @@ class InvoiceSum | ||||
|     { | ||||
|         return $this->getTotalTaxes(); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -301,4 +301,5 @@ class InvoiceSumInclusive | ||||
|     { | ||||
|         return $this->getTotalTaxes(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -34,18 +34,7 @@ use Turbo124\Beacon\Facades\LightLogs; | ||||
| 
 | ||||
| class LoginController extends BaseController | ||||
| { | ||||
|     /* | ||||
|     |-------------------------------------------------------------------------- | ||||
|     | Login Controller | ||||
|     |-------------------------------------------------------------------------- | ||||
|     | | ||||
|     | This controller handles authenticating users for the application and | ||||
|     | redirecting them to your home screen. The controller uses a trait | ||||
|     | to conveniently provide its functionality to your applications. | ||||
|     | | ||||
|     */ | ||||
| 
 | ||||
|     /* | ||||
|     /** | ||||
|       * @OA\Tag( | ||||
|       *     name="login", | ||||
|       *     description="Authentication", | ||||
|  | ||||
| @ -95,6 +95,7 @@ class InvoiceController extends Controller | ||||
|         } | ||||
| 
 | ||||
|         $invoices->map(function ($invoice) { | ||||
|             $invoice->service()->removeUnpaidGatewayFees()->save(); | ||||
|             $invoice->balance = Number::formatValue($invoice->balance, $invoice->client->currency()); | ||||
|             $invoice->partial = Number::formatValue($invoice->partial, $invoice->client->currency()); | ||||
| 
 | ||||
|  | ||||
| @ -163,19 +163,29 @@ class PaymentController extends Controller | ||||
| 
 | ||||
|         $first_invoice = $invoices->first(); | ||||
| 
 | ||||
|         $fee_totals = round($gateway->calcGatewayFee($invoice_totals, true), $first_invoice->client->currency()->precision); | ||||
|         $starting_invoice_amount = $first_invoice->amount; | ||||
| 
 | ||||
|         if (!$first_invoice->uses_inclusive_taxes) { | ||||
|             $fee_tax = 0; | ||||
|             $fee_tax += round(($first_invoice->tax_rate1 / 100) * $fee_totals, $first_invoice->client->currency()->precision); | ||||
|             $fee_tax += round(($first_invoice->tax_rate2 / 100) * $fee_totals, $first_invoice->client->currency()->precision); | ||||
|             $fee_tax += round(($first_invoice->tax_rate3 / 100) * $fee_totals, $first_invoice->client->currency()->precision); | ||||
|         // $fee_totals = round($gateway->calcGatewayFee($invoice_totals, true), $first_invoice->client->currency()->precision);
 | ||||
| 
 | ||||
|             $fee_totals += $fee_tax; | ||||
|         } | ||||
|         // if (!$first_invoice->uses_inclusive_taxes) {
 | ||||
|         //     $fee_tax = 0;
 | ||||
|         //     $fee_tax += round(($first_invoice->tax_rate1 / 100) * $fee_totals, $first_invoice->client->currency()->precision);
 | ||||
|         //     $fee_tax += round(($first_invoice->tax_rate2 / 100) * $fee_totals, $first_invoice->client->currency()->precision);
 | ||||
|         //     $fee_tax += round(($first_invoice->tax_rate3 / 100) * $fee_totals, $first_invoice->client->currency()->precision);
 | ||||
| 
 | ||||
|         //     $fee_totals += $fee_tax;
 | ||||
|         // }
 | ||||
| 
 | ||||
|         $first_invoice->service()->addGatewayFee($gateway, $invoice_totals)->save(); | ||||
| 
 | ||||
|         /** | ||||
|          * | ||||
|          * The best way to determine the exact gateway fee is to not calculate it in isolation (due to rounding) | ||||
|          * but to simply add it as a line item, and then subtract the starting and finishing amounts of | ||||
|          * the invoice. | ||||
|          */ | ||||
|         $fee_totals = $first_invoice->amount - $starting_invoice_amount; | ||||
| 
 | ||||
|         $payment_hash = new PaymentHash; | ||||
|         $payment_hash->hash = Str::random(128); | ||||
|         $payment_hash->data = $payable_invoices; | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Account", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Activity", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="BulkAction", | ||||
|  *   type="array", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="ClientContact", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="ClientGatewayToken", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Client", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="CompanyGateway", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="CompanyLedger", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Company", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="CompanySettings", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="CompanyToken", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
|  <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="CompanyUser", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="CreditPaymentable", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Credit", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Design", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Error", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Expense", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="FeesAndLimits", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="GroupSetting", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Header( | ||||
|  *     header="X-MINIMUM-CLIENT-VERSION", | ||||
|  *     description="The API version", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="InvoicePaymentable", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Invoice", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  *     @OA\Parameter( | ||||
|  *         name="X-Api-Secret", | ||||
|  *         in="header", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Payment", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="PaymentTerm", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Paymentable", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Product", | ||||
|  *   type="object", | ||||
|  | ||||
							
								
								
									
										9
									
								
								app/Http/Controllers/OpenAPI/ProjectSchema.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								app/Http/Controllers/OpenAPI/ProjectSchema.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Project", | ||||
|  *   type="object", | ||||
|  *       @OA\Property(property="id", type="string", example="Opnel5aKBz", description="______"), | ||||
|  *       @OA\Property(property="name", type="string", example="New Project", description="______"), | ||||
|  * ) | ||||
|  */ | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Quote", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="RecurringInvoice", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="RecurringQuote", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="SystemLog", | ||||
|  *   type="object", | ||||
| @ -7,9 +7,9 @@ | ||||
|  *       @OA\Property(property="company_id", type="string", example="AS3df3A", description="The company hashed id"), | ||||
|  *       @OA\Property(property="user_id", type="string", example="AS3df3A", description="The user_id hashed id"), | ||||
|  *       @OA\Property(property="client_id", type="string", example="AS3df3A", description="The client_id hashed id"), | ||||
|  *       @OA\Property(property="event_id", type="int", example="1", description="The Log Type ID"), | ||||
|  *       @OA\Property(property="category_id", type="int", example="1", description="The Category Type ID"), | ||||
|  *       @OA\Property(property="type_id", type="int", example="1", description="The Type Type ID"), | ||||
|  *       @OA\Property(property="event_id", type="integer", example=1, description="The Log Type ID"), | ||||
|  *       @OA\Property(property="category_id", type="integer", example=1, description="The Category Type ID"), | ||||
|  *       @OA\Property(property="type_id", type="integer", example=1, description="The Type Type ID"), | ||||
|  *       @OA\Property(property="log", type="object", example="{'key':'value'}", description="The json object of the error"), | ||||
|  *       @OA\Property(property="updated_at", type="string", example="2", description="______"), | ||||
|  *       @OA\Property(property="created_at", type="string", example="2", description="______"), | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="TaxRate", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Template", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="User", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="ValidationError", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="VendorContact", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Vendor", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\Schema( | ||||
|  *   schema="Webhook", | ||||
|  *   type="object", | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <?php | ||||
| /* | ||||
| /** | ||||
|  * @OA\OpenApi( | ||||
|  *     @OA\Info( | ||||
|  *         version="1.0.30", | ||||
| @ -15,8 +15,8 @@ | ||||
|  *         ) | ||||
|  *     ), | ||||
|  *     @OA\Server( | ||||
|  *         description="InvoiceNinja host", | ||||
|  *         url="https://virtserver.swaggerhub.com/InvoiceNinja/invoices/1.0.30" | ||||
|  *         description="Example InvoiceNinja base url", | ||||
|  *         url="https://ninja.test" | ||||
|  *     ), | ||||
|  *     @OA\ExternalDocumentation( | ||||
|  *         description="http://docs.invoiceninja.com", | ||||
|  | ||||
| @ -286,7 +286,7 @@ class CompanyGateway extends BaseModel | ||||
|         } | ||||
| 
 | ||||
|         if ($fees_and_limits->fee_percent) { | ||||
|             $fee += $amount * $fees_and_limits->fee_percent / 100; | ||||
|             $fee += round(($amount * $fees_and_limits->fee_percent / 100),2); | ||||
|             info("fee after adding fee percent = {$fee}"); | ||||
|         } | ||||
| 
 | ||||
| @ -300,17 +300,17 @@ class CompanyGateway extends BaseModel | ||||
|         /**/ | ||||
|         if ($include_taxes) { | ||||
|             if ($fees_and_limits->fee_tax_rate1) { | ||||
|                 $fee += $pre_tax_fee * $fees_and_limits->fee_tax_rate1 / 100; | ||||
|                 $fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate1 / 100),2); | ||||
|                 info("fee after adding fee tax 1 = {$fee}"); | ||||
|             } | ||||
| 
 | ||||
|             if ($fees_and_limits->fee_tax_rate2) { | ||||
|                 $fee += $pre_tax_fee * $fees_and_limits->fee_tax_rate2 / 100; | ||||
|                 $fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate2 / 100),2); | ||||
|                 info("fee after adding fee tax 2 = {$fee}"); | ||||
|             } | ||||
| 
 | ||||
|             if ($fees_and_limits->fee_tax_rate3) { | ||||
|                 $fee += $pre_tax_fee * $fees_and_limits->fee_tax_rate3 / 100; | ||||
|                 $fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate3 / 100),2); | ||||
|                 info("fee after adding fee tax 3 = {$fee}"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -104,19 +104,22 @@ class Gateway extends StaticModel | ||||
|     { | ||||
|         switch ($this->id) { | ||||
|             case 1: | ||||
|                 return ['methods' => [GatewayType::CREDIT_CARD], 'refund' => true, 'token_billing' => true ]; //Authorize.net
 | ||||
|                 return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true]];//Authorize.net
 | ||||
|                 break; | ||||
|             case 15: | ||||
|                 return ['methods' => [GatewayType::PAYPAL], 'refund' => true, 'token_billing' => false  ]; //Paypal
 | ||||
|                 return [GatewayType::PAYPAL => ['refund' => true, 'token_billing' => false]]; //Paypal
 | ||||
|                 break; | ||||
|             case 20: | ||||
|                 return ['methods' => [GatewayType::CREDIT_CARD, GatewayType::BANK_TRANSFER, GatewayType::ALIPAY, GatewayType::APPLE_PAY], 'refund' => true, 'token_billing' => true  ]; //Stripe
 | ||||
|                 return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true], | ||||
|                         GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true], | ||||
|                         GatewayType::ALIPAY => ['refund' => false, 'token_billing' => false],  | ||||
|                         GatewayType::APPLE_PAY => ['refund' => false, 'token_billing' => false]]; //Stripe
 | ||||
|                 break; | ||||
|             case 39: | ||||
|                 return ['methods' => [GatewayType::CREDIT_CARD], 'refund' => true, 'token_billing' => true  ]; //Checkout
 | ||||
|                 return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true]]; //Checkout
 | ||||
|                 break; | ||||
|             default: | ||||
|                 return ['methods' => [], 'refund' => false, 'token_billing' => false]; | ||||
|                 return []; | ||||
|                 break; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -44,6 +44,9 @@ class AddGatewayFee extends AbstractService | ||||
|     { | ||||
|         $gateway_fee = round($this->company_gateway->calcGatewayFee($this->amount), $this->invoice->client->currency()->precision); | ||||
| 
 | ||||
|         if((int)$gateway_fee == 0) | ||||
|             return; | ||||
| 
 | ||||
|         $this->cleanPendingGatewayFees(); | ||||
| 
 | ||||
|         if ($gateway_fee > 0) { | ||||
|  | ||||
| @ -212,6 +212,8 @@ class InvoiceService | ||||
| 
 | ||||
|     public function updateStatus() | ||||
|     { | ||||
|         info("invoice balance = {$this->invoice->balance}"); | ||||
| 
 | ||||
|         if((int)$this->invoice->balance == 0) | ||||
|             $this->setStatus(Invoice::STATUS_PAID); | ||||
| 
 | ||||
| @ -232,7 +234,7 @@ class InvoiceService | ||||
|                                          return $item; | ||||
|                                      })->toArray(); | ||||
| 
 | ||||
|         $this->invoice = $this->invoice->calc()->getInvoice(); | ||||
|         //$this->invoice = $this->invoice->calc()->getInvoice();
 | ||||
| 
 | ||||
|         $this->deletePdf(); | ||||
| 
 | ||||
|  | ||||
| @ -67,12 +67,16 @@ class PaymentService | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         $this->payment->ledger()->updatePaymentBalance($this->payment->amount); | ||||
|         $this->payment | ||||
|              ->ledger() | ||||
|              ->updatePaymentBalance($this->payment->amount); | ||||
| 
 | ||||
|         $client->service() | ||||
|             ->updateBalance($this->payment->amount) | ||||
|             ->updatePaidToDate($this->payment->amount * -1) | ||||
|             ->save(); | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function refundPayment(array $data) :?Payment | ||||
|  | ||||
| @ -31,7 +31,6 @@ class UpdateGatewayTableVisibleColumn extends Migration | ||||
| 
 | ||||
|         }); | ||||
| 
 | ||||
| 
 | ||||
|         Schema::table('expenses', function ($t){ | ||||
|             $t->renameColumn('invoice_category_id', 'category_id'); | ||||
|         }); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user