Skip to content

Commit

Permalink
Merge pull request #10 from friends-of-presta/releasedrafter
Browse files Browse the repository at this point in the history
Add Github release drafter and PR template and generate new version
  • Loading branch information
jf-viguier authored Oct 31, 2023
2 parents 1f9e8ff + 932fbd1 commit 12acc70
Show file tree
Hide file tree
Showing 17 changed files with 2,712 additions and 361 deletions.
16 changes: 16 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-----------------------------------------------------------------------------
Thank you for contributing
Please take the time to edit the "Answers" rows below with the necessary information.
------------------------------------------------------------------------------>

| Questions | Answers
| ------------- | -------------------------------------------------------
| Description? | Please be specific when describing the PR. <br> Every detail helps: versions, browser/server configuration, specific module/theme, etc. Feel free to add more information below this table.
| Type? | bug fix / improvement / new feature / refacto / critical
| BC breaks? | yes / no
| Deprecations? | yes / no
| Fixed ticket? | Fixes PrestaShop/Prestashop#{issue number here}.
| How to test? | Please indicate how to best verify that this PR is correct.

<!-- Click the form's "Preview" button to make sure the table is functional in GitHub. Thank you! -->
15 changes: 15 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
branches:
- master
name-template: v$NEXT_PATCH_VERSION
tag-template: v$NEXT_PATCH_VERSION
categories:
- title: 🚀 Improvements
label: enhancement
- title: 🐛 Bug Fixes
label: bug
change-template: '- #$NUMBER: $TITLE by @$AUTHOR'
template: |
# Changes
$CHANGES
7 changes: 7 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Build
on: [push, pull_request]

jobs:
build-and-release-draft:
name: Build & Release draft
uses: PrestaShop/.github/.github/workflows/build-release.yml@master
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor/
/config_*.xml
.php_cs.cache
11 changes: 11 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

$config = new PrestaShop\CodingStandards\CsFixer\Config();

$config
->setUsingCache(true)
->getFinder()
->in(__DIR__)
->exclude('vendor');

return $config;
68 changes: 34 additions & 34 deletions VATNumberTaxManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,48 +26,48 @@

class VATNumberTaxManager implements TaxManagerInterface
{
public static function isAvailableForThisAddress(Address $address)
{
/*
HOTFIX
For some reason, this check is called 6 times (?)
public static function isAvailableForThisAddress(Address $address)
{
/*
HOTFIX
1 w. the real address
2 w.o. the real address
For some reason, this check is called 6 times (?)
1 w. the real address
2 w.o. the real address
1 w. the real address
2 w.o. the real address
=> [1 0 0 1 0 0]
1 w. the real address
2 w.o. the real address
So we need to filter out the weird calls...
=> [1 0 0 1 0 0]
We do this by caching the correct calls between calls;
by creating a static variable, which we save the address to,
if it does not contain NULL in some of the other fields.
*/
So we need to filter out the weird calls...
static $cached_address = NULL;
We do this by caching the correct calls between calls;
by creating a static variable, which we save the address to,
if it does not contain NULL in some of the other fields.
*/

if ($address->id_customer != NULL) {
$cached_address = $address;
}
static $cached_address = null;

// Now, check on the cached address object
return (!empty($cached_address->vat_number)
&& !empty($cached_address->id_country)
&& $cached_address->id_country != Configuration::get('VATNUMBER_COUNTRY')
&& Configuration::get('VATNUMBER_MANAGEMENT')
);
}
if ($address->id_customer != null) {
$cached_address = $address;
}

public function getTaxCalculator()
{
// If the address matches the european vat number criterias no taxes are applied
$tax = new Tax();
$tax->rate = 0;
// Now, check on the cached address object
return !empty($cached_address->vat_number)
&& !empty($cached_address->id_country)
&& $cached_address->id_country != Configuration::get('VATNUMBER_COUNTRY')
&& Configuration::get('VATNUMBER_MANAGEMENT')
;
}

return new TaxCalculator(array($tax));
}
public function getTaxCalculator()
{
// If the address matches the european vat number criterias no taxes are applied
$tax = new Tax();
$tax->rate = 0;

return new TaxCalculator([$tax]);
}
}
6 changes: 3 additions & 3 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/vatnumber.php');
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../init.php';
include dirname(__FILE__) . '/vatnumber.php';

echo VatNumber::isApplicable(Tools::getValue('id_country'));
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
}
],
"require": {
"php": ">=5.3.2"
"php": ">=5.6"
},
"require-dev": {
"prestashop/php-dev-tools": "^3.16"
},
"config": {
"preferred-install": "dist"
Expand Down
Loading

0 comments on commit 12acc70

Please sign in to comment.