Skip to content

Commit

Permalink
Merge branch 'InvoicePlane:development' into Preview-PDF-in-Modal-Inv…
Browse files Browse the repository at this point in the history
  • Loading branch information
Verony-makesIT authored Oct 29, 2024
2 parents d7abc0b + bf6ddb9 commit 0ade351
Show file tree
Hide file tree
Showing 31 changed files with 1,451 additions and 1,481 deletions.
19 changes: 12 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# InvoicePlane EditorConfig File
root = true

[**]
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120

[*.php]
indent_size = 4
max_line_length = 200
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ adminer.php
/.php_cs.cache
/doc
*.bak
npm-debug.log
yarn-error.log
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.13.1
18.20.4
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
<a href="https://translations.invoiceplane.com/project/fusioninvoice"><img src="https://img.shields.io/badge/Translations-%40%20Crowdin-429ae1"></a>
</p>

<p align="center" bgcolor="#429ae1"><b>InvoicePlane is a self-hosted open source application for managing your invoices, clients and payments.<br>
For more information visit <a href="https://www.invoiceplane.com">InvoicePlane.com</a> or try the <a href="https://demo.invoiceplane.com">Demo</a>.</b></p>
<p align="center" bgcolor="#429ae1"><i>InvoicePlane is a self-hosted open source application for managing your invoices, clients and payments.<br>
For more information visit <a href="https://www.invoiceplane.com">InvoicePlane.com</a> or try the <a href="https://www.invoiceplane.com/demo">Demo</a>.</i></p>

---

Since the start of the project in 2014, InvoicePlane evolved into a software that is used world wide. However, it is
still developed in our free time, as a hobby. We do your best to fulfill any legal requirements but please note that we
cannot make sure that the app is working 100% correct. Also, due to the fact that InvoicePlane is a free and open
source software without an income, there are no professional audits of the app yet.
Since the start of the project in 2014, InvoicePlane evolved into a software used worldwide.
However, it is still developed in our free time, as a hobby.
We do your best to fulfill any legal requirements but please note
that we cannot make sure that the app is working 100% correctly.
Also, due to the fact that InvoicePlane is a free and open source software without an income,
there are no professional audits of the app yet.

---

Expand All @@ -29,14 +31,14 @@ source software without an income, there are no professional audits of the app y
4. Open the `ipconfig.php` file in an editor and set your URL like specified in the file.
5. Open `http://your-invoiceplane-domain.com/index.php/setup` and follow the instructions.


_Notice: Please download InvoicePlane from our [website](https://www.invoiceplane.com/downloads) only as the packages contain additional needed components. If you are a developer, read the [development guide](CONTRIBUTING.md)._
_Notice: Please download InvoicePlane from our [website](https://www.invoiceplane.com/downloads) only as the packages contain additional needed components.
If you are a developer, read the [development guide](CONTRIBUTING.md)._

---

#### Issues

As soon as you run into issues and you want to report it, make sure we can replicate that issue.
Before you report an issue, try your best to make it reproducible.

Something like "_It doesn't work_" will not help in finding your issue.

Expand All @@ -52,11 +54,12 @@ Once the issue is _reproducable / replicatable_, you will be asked to create an

If you want to remove `index.php` from the URL, follow these instructions. However, this is an _optional_ step and not a requirement. If it's not working correctly, take a step back and use the application with out removing that part from the URL.

1. Make sure that mod_rewrite is enabled on your web server.
1. Make sure that `mod_rewrite` is enabled on your web server.
2. Set the `REMOVE_INDEXPHP` setting in your `ipconfig.php` to `true`.
3. Rename the `htaccess` file to `.htaccess`

If you want to install InvoicePlane in a subfolder (e.g. `http://your-invoiceplane-domain.com/invoices/`) you have to change the `ipconfig.php` and `.htaccess` file. The instructions can be found within the files.
If you want to install InvoicePlane in a subfolder (e.g. `http://your-invoiceplane-domain.com/invoices/`) you have to change the `ipconfig.php` and `.htaccess` file.
The instructions can be found within the files.

---

Expand Down
14 changes: 14 additions & 0 deletions application/config/payment_gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,20 @@
'label' => 'Publishable key'
),
),
'PayPal' => array(
'clientId' => array(
'type' => 'text',
'label' => 'Client ID'
),
'clientSecret' => array(
'type' => 'password',
'label' => 'Secret'
),
'testMode' => array(
'type' => 'checkbox',
'label' => 'Test Mode',
),
),
/* 'TargetPay_Directebanking' => array(
'subAccountId' => array(
'type' => 'text',
Expand Down
3 changes: 2 additions & 1 deletion application/language/english/ip_lang.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
'invoice_tax_rate' => 'Invoice Tax Rate',
'invoice_template' => 'Invoice Template',
'invoice_templates' => 'Invoice Templates',
'invoice_templates_info' => 'You can extend the available templates by downloading other templates provided by the community (see <a href="https://www.invoiceplane.com/themes" target="_blank">www.invoiceplane.com/themes</a>).',
'invoice_terms' => 'Invoice Terms',
'invoiced' => 'Invoiced',
'invoiceplane_news' => 'InvoicePlane News',
Expand Down Expand Up @@ -332,7 +333,7 @@
'no_overdue_invoices' => 'No overdue Invoices',
'no_quotes_requiring_approval' => 'There are no quotes requiring approval.',
'no_updates_available' => 'No updates available.',
'no_update_invoice_due_date_mail' => 'Disable the change of invoice due date before emailing',
'no_update_invoice_due_date_mail' => 'Disable the change of invoice date and due date before emailing',
'none' => 'None',
'note' => 'Note',
'notes' => 'Notes',
Expand Down
8 changes: 7 additions & 1 deletion application/libraries/ZugferdXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ protected function xmlApplicableSupplyChainTradeAgreement()
protected function xmlSellerTradeParty($index = '', $item = '')
{
$node = $this->doc->createElement('ram:SellerTradeParty');
$node->appendChild($this->doc->createElement('ram:Name', htmlsc($this->invoice->user_name)));

if (!empty($this->invoice->user_company)) {
$node->appendChild($this->doc->createElement('ram:Name', htmlsc($this->invoice->user_company)));
$node->appendChild($this->doc->createElement('ram:DefinedTradeContact', htmlsc($this->invoice->user_name)));
} else {
$node->appendChild($this->doc->createElement('ram:Name', htmlsc($this->invoice->user_name)));
}

// PostalTradeAddress
$addressNode = $this->doc->createElement('ram:PostalTradeAddress');
Expand Down
158 changes: 158 additions & 0 deletions application/libraries/gateways/PaypalLib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php

if (! defined('BASEPATH')) {
exit('No direct script access allowed');
}

use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;

class PaypalLib
{
protected Client $client;

protected string $endpoint = 'https://api-m.paypal.com';

protected string $client_id;

protected string $client_secret;

protected string $bearer_token;

public function __construct($params)
{
$params['demo'] && $this->endpoint = 'https://api-m.sandbox.paypal.com';
$this->client_id = $params['client_id'];
$this->client_secret = $params['client_secret'];

log_message('debug', 'Paypal library initialization started');

$this->client = new Client([
'base_uri' => $this->endpoint,
]);

log_message('debug', 'Paypal library client created');

$this->authorize();

}

/**
* Generate the authentication token
*
* @return void
*/
protected function authorize()
{
log_message('debug', 'Paypal library authorization started');
try {
$response = $this->client->request('post', 'v1/oauth2/token', [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
],
'auth' => [$this->client_id, $this->client_secret],
'form_params' => ['grant_type' => 'client_credentials'],
]);

$this->bearer_token = json_decode($response->getBody())->access_token;
log_message('debug', 'Paypal library authorization obtained');
} catch (ClientException $e) {
log_message('error', 'Paypal library authorization failed');

return $e->getResponse()->getBody();
}
}

/**
* Create an order on paypal
*
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_create
*
* @param array $order_information
* @return string
*/
public function createOrder($order_information): string|array
{
log_message('debug', 'Paypal library order creation started');
try {
$response = $this->client->request('POST', 'v2/checkout/orders', [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $this->bearer_token
],
'body' => json_encode([
'purchase_units' => [[
'invoice_id' => $order_information['invoice_id'],
'amount' => [
'currency_code' => $order_information['currency_code'],
'value' => $order_information['value'],
],
'custom_id' => $order_information['custom_id'],
]],
'intent' => 'CAPTURE',
]),
]);
log_message('debug', 'Paypal library order creation completed');

return $response->getBody()->getContents();
} catch (ClientException $e) {
log_message('debug', 'Paypal library order creation failed');

return ['status' => false, 'error' => $e];
}
}

/**
* Capture the payment of the order
*
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture
*
* @param string $order_id
*/
public function captureOrder($order_id): array
{
log_message('debug', 'Paypal library order capturing started');
try {
$response = $this->client->request('POST', 'v2/checkout/orders/'.$order_id.'/capture', [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $this->bearer_token
]
]);
log_message('debug', 'Paypal library order capturing completed');

return ['status' => true, 'response' => $response];
} catch (ClientException $e) {
log_message('debug', 'Paypal library order capturing failed');

return ['status' => false, 'error' => $e];
}
}

/**
* Get the details of a paypal order by order id
*
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_get
*
* @param string $order_id
*/
public function showOrderDetails($order_id)
{
log_message('debug', 'Paypal library show order started');
try {
$response = $this->client->request('GET', 'v2/checkout/orders/'.$order_id, [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $this->bearer_token
]
]);
log_message('debug', 'Paypal library show order completed');

return ['status' => true, 'response' => $response];
} catch (ClientException $e) {
log_message('debug', 'Paypal library show order failed');

return ['status' => false, 'error' => $e];
}
}
}
6 changes: 5 additions & 1 deletion application/modules/dashboard/views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@
<?php echo anchor('projects/view/' . $project->project_id, htmlsc($project->project_name)); ?>
</td>
<td>
<?php echo anchor('clients/view/' . $project->client_id, htmlsc(format_client($project))); ?>
<?php if ($project->client_id != null): ?>
<?php echo anchor('clients/view/' . $project->client_id, htmlsc(format_client($project))); ?>
<?php else: ?>
-
<?php endif; ?>
</td>
</tr>
<?php } ?>
Expand Down
Loading

0 comments on commit 0ade351

Please sign in to comment.