Skip to content

Commit

Permalink
Merge branch 'bp_compat_v19' into 'master'
Browse files Browse the repository at this point in the history
Dolibarr V19 Compatibility

See merge request SplashSync/Dolibarr!3
  • Loading branch information
BadPixxel committed Feb 21, 2024
2 parents 4ac1537 + 3a164d2 commit 8f3a73f
Show file tree
Hide file tree
Showing 21 changed files with 261 additions and 91 deletions.
54 changes: 33 additions & 21 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ variables:
################################################################
# Defined Pipeline Stages
stages:
- quality
- basic
- advanced
- variants
- Quality
- Basic
- Advanced
- Variants
- Builds

################################################################
Expand All @@ -61,8 +61,10 @@ stages:
- mysql:5.7
artifacts:
when: always
paths:
- "$CI_PROJECT_DIR/*-report.html"
reports:
junit: "$CI_PROJECT_DIR/*-report.xml"
junit: "$CI_PROJECT_DIR/*-report.xml"
################################################################
# Before Script
before_script:
Expand All @@ -87,31 +89,46 @@ stages:
# Show PhpUnit Version
- splash/vendor/phpunit/phpunit/phpunit --version
# Run PhpUnit Main Local Testsuite
- splash/vendor/phpunit/phpunit/phpunit --testsuite=Init --log-junit $CI_PROJECT_DIR/init-report.xml
- splash/vendor/phpunit/phpunit/phpunit --testsuite=$PHPUNIT_SUITE --log-junit $CI_PROJECT_DIR/full-report.xml
- splash/vendor/phpunit/phpunit/phpunit --testsuite=Init --log-junit $CI_PROJECT_DIR/init-report.xml --testdox-html $CI_PROJECT_DIR/init-report.html
- splash/vendor/phpunit/phpunit/phpunit --testsuite=$PHPUNIT_SUITE --log-junit $CI_PROJECT_DIR/full-report.xml --testdox-html $CI_PROJECT_DIR/full-report.html

.functionnal-basic: &functionnal-basic
<<: *functionnal
stage: basic
stage: Basic
variables:
PHPUNIT_SUITE: Basic

.functionnal-advanced: &functionnal-advanced
<<: *functionnal
stage: advanced
stage: Advanced
variables:
PHPUNIT_SUITE: Advanced

.functionnal-variants: &functionnal-variants
<<: *functionnal
stage: variants
stage: Variants
variables:
PHPUNIT_SUITE: Variants

################################################################
# Functional Tests Map
################################################################

################################################################
# Dolibarr V19
Dol-19-Basics:
image: tuxgasy/dolibarr:19
<<: *functionnal-basic
allow_failure: true
Dol-19-Advanced:
image: tuxgasy/dolibarr:19
<<: *functionnal-advanced
allow_failure: true
Dol-19-Variants:
image: tuxgasy/dolibarr:19
<<: *functionnal-variants
allow_failure: true

################################################################
# Dolibarr V18
Dol-18-Basics:
Expand Down Expand Up @@ -199,7 +216,7 @@ Dol-13-Variants:
################################################################
.code_quality: &code_quality
# when: manual
stage: quality
stage: Quality
tags: ['Dedicated']
services:
- mysql:5.7
Expand Down Expand Up @@ -228,6 +245,11 @@ Dol-13-Variants:
after_script:
- curl -s https://raw.githubusercontent.com/BadPixxel/Php-Sdk/main/ci/after.sh | sh

Dol-19-Quality:
image: tuxgasy/dolibarr:19
<<: *code_quality
allow_failure: true

Dol-18-Quality:
image: tuxgasy/dolibarr:18
<<: *code_quality
Expand All @@ -244,16 +266,6 @@ Dol-14-Quality:
image: tuxgasy/dolibarr:14
<<: *code_quality

#Dol-13-Quality:
# image: tuxgasy/dolibarr:13
# allow_failure: true
# <<: *code_quality
#
#Dol-Dev-Quality:
# image: tuxgasy/dolibarr:develop
# allow_failure: true
# <<: *code_quality

################################################################
# Build Module
################################################################
Expand Down
1 change: 1 addition & 0 deletions ci/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@
// Activate Splash Module
activateModule("modSplash");
activateModule("modExpedition");
activateModule("modProduct");
activateModule("modProductBatch");
activateModule("modAccounting");
2 changes: 1 addition & 1 deletion ci/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set -e

################################################################################
# Docker Compose Container you want to check
CONTAINERS="dol-18,dol-17,dol-16,dol-14"
CONTAINERS="dol-19,dol-18,dol-17,dol-16,dol-14"
WORKDIR="/var/www/html/custom"
################################################################################
# Start Docker Compose Stack
Expand Down
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# 172.100.0.16 v16.dolibarr.local
# 172.100.0.17 v17.dolibarr.local
# 172.100.0.18 v18.dolibarr.local
# 172.100.0.19 v19.dolibarr.local
# 172.100.0.99 latest.dolibarr.local
# 172.100.0.100 toolkit.dolibarr.local
# 172.100.0.101 db.dolibarr.local
Expand Down Expand Up @@ -87,6 +88,36 @@ services:
dolibarr: { ipv4_address: 172.100.0.99 }
splashsync: { aliases: [ latest.dolibarr.local ] }

################################################################################
# Dolibarr V19
dol-19:
image: tuxgasy/dolibarr:19
container_name: v19.dolibarr.local
depends_on:
- mysql
links:
- mysql
working_dir: /var/www/html/custom
environment:
- "DOLI_DB_TYPE=mysqli"
- "DOLI_DB_HOST=mysql"
- "DOLI_DB_NAME=dolibarr19"
- "DOLI_DB_USER=root"
- "DOLI_DB_PASSWORD=dolibarr"
- "DOLI_ADMIN_LOGIN=Admin"
- "PHP_MEMORY_LIMIT=-1"
- SPLASH_WS_ID=ThisIsDol19Key
- SPLASH_WS_KEY=ThisTokenIsNotSoSecretChangeIt
- SPLASH_WS_HOST=http://172.100.0.100/ws/soap
volumes:
- "./:/var/www/html/custom/"
- "./.git/:/var/www/html/custom/.git/"
entrypoint: sh /var/www/html/custom/docker/docker-entrypoint.sh
hostname: v19.dolibarr.local
networks:
dolibarr: { ipv4_address: 172.100.0.19 }
splashsync: { aliases: [ v19.dolibarr.local ] }

################################################################################
# Dolibarr V18
dol-18:
Expand Down
15 changes: 15 additions & 0 deletions docker/toolkit/splash.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ splash:
WsHost: http://latest.dolibarr.local
WsPath: /custom/splash/vendor/splash/phpcore/soap.php

########################################################################
# Dolibarr V19
dol-19:
id: ThisIsDol19Key
key: ThisTokenIsNotSoSecretChangeIt
name: Dolibarr 19
host: false
connector: soap
config:
Extended: true
WsIdentifier: ThisIsDol19Key
WsEncryptionKey: ThisTokenIsNotSoSecretChangeIt
WsHost: http://v19.dolibarr.local
WsPath: /custom/splash/vendor/splash/phpcore/soap.php

########################################################################
# Dolibarr V18
dol-18:
Expand Down
2 changes: 1 addition & 1 deletion grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ parameters:
# For Building Splash Module
mod-src: '/splash'
mod-target: '/splash/'
mod-file: "module_splash-2.18.1"
mod-file: "module_splash-2.19.0"

# For Building Splash Manifest
yml-enable: false
Expand Down
8 changes: 5 additions & 3 deletions grumphp/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ parameters:
- ArrayObject
- FactureStats
- CommandeStats

ignoreErrors:
ignoreErrors:
- '#Function completeFileArrayWithDatabaseInfo not found.#'

# Undefined in Dolibarr Class Property
Expand All @@ -39,4 +38,7 @@ parameters:
- '#Method ProductCombination2ValuePair::create\(\) invoked with 1 parameter, 0 required#'

# Fix for Dolibarr V18
- '#Class EcmfilesLine referenced with incorrect case: EcmFilesLine.#'
- '#Class EcmfilesLine referenced with incorrect case: EcmFilesLine.#'

# Fix for Dolibarr V19
- '#Method Commande::load_board\(\) invoked with 2 parameters, 1 required#'
2 changes: 1 addition & 1 deletion splash/_conf/defines.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

//====================================================================//
// Module Version
define("SPL_MOD_VERSION", '2.18.1');
define("SPL_MOD_VERSION", '2.19.0');
define("SPL_MOD_ID", 9200);
define("SPL_MOD_NAME", 'splash');
define("SPL_MOD_CATEGORIE", 'technic');
Expand Down
19 changes: 12 additions & 7 deletions splash/src/Core/BaseItemsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ protected function insertItem(object $item): bool
$item->total_localtax1 = 0;
$item->total_localtax2 = 0;

$item->fk_multicurrency = "";
$item->multicurrency_code = "";
$item->multicurrency_subprice = "0.0";
$item->multicurrency_total_ht = "0.0";
$item->multicurrency_total_tva = "0.0";
$item->multicurrency_total_ttc = "0.0";
$item->fk_multicurrency = 0;
$item->multicurrency_code = "0";
$item->multicurrency_subprice = 0.0;
$item->multicurrency_total_ht = 0.0;
$item->multicurrency_total_tva = 0.0;
$item->multicurrency_total_ttc = 0.0;

if ($item->insert() <= 0) {
$this->catchDolibarrErrors($item);
Expand Down Expand Up @@ -655,13 +655,18 @@ private function updateItemTotals()
}
}

//====================================================================//
// Ensure ThirdParty is Loaded
if (!$this->object->thirdparty instanceof \Societe) {
$this->object->fetch_thirdparty();
}
//====================================================================//
// Calcul du total TTC et de la TVA pour la ligne à partir de
// qty, pu, remise_percent et txtva
$localTaxType = getLocalTaxesFromRate(
(string) $vatRateOrId,
0,
$this->object->fetch_thirdparty(),
$this->object->thirdparty,
$mysoc,
(int) $useId
);
Expand Down
9 changes: 7 additions & 2 deletions splash/src/Objects/Address/CRUDTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use Contact;
use Splash\Core\SplashCore as Splash;
use Splash\Local\Local;
use Splash\Local\Services\MultiCompany;
use User;

Expand Down Expand Up @@ -137,7 +138,7 @@ public function update(bool $needed): ?string
*/
public function delete(string $objectId): bool
{
global $db,$user;
global $db, $user;
//====================================================================//
// Stack Trace
Splash::log()->trace();
Expand All @@ -159,8 +160,12 @@ public function delete(string $objectId): bool
return Splash::log()->err(" Unable to delete Product (".$objectId.").");
}
//====================================================================//
// Prepare Args
$arg1 = (Local::dolVersionCmp("19.0.0") > 0) ? $user : 0;
//====================================================================//
// Delete Object
if ($object->delete() <= 0) {
/** @phpstan-ignore-next-line */
if ($object->delete($arg1) <= 0) {
return $this->catchDolibarrErrors($object);
}

Expand Down
5 changes: 3 additions & 2 deletions splash/src/Objects/Invoice/CRUDTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ public function create(): ?Facture
$this->setSimple('date_commande', $dateTime->getTimestamp());
$this->doCustomerDetection($this->in);
$this->setSimple("statut", Facture::STATUS_DRAFT);
$this->object->fk_user_author = $user->id;
$this->object->entity = MultiCompany::getCurrentId();
$this->object->statut = Facture::STATUS_DRAFT;
$this->setInvoiceStatus(Facture::STATUS_DRAFT);
$this->object->paye = 0;
//====================================================================//
// If Credit Note => Setup Type
Expand Down Expand Up @@ -252,7 +253,7 @@ public function updateObjectPdf(): void
}
//====================================================================//
// Only if Invoice is Valid
if ($this->object->statut <= 0) {
if ($this->getInvoiceStatus() <= 0) {
return;
}
//====================================================================//
Expand Down
2 changes: 1 addition & 1 deletion splash/src/Objects/Invoice/ItemsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function deleteItem(FactureLigne $factureLigne): bool
if (Splash::isDebugMode()) {
//====================================================================//
// Force Invoice Status To Draft
$this->object->statut = 0;
$this->setInvoiceStatus(\Facture::STATUS_DRAFT);
}
//====================================================================//
// Perform Line Delete
Expand Down
14 changes: 7 additions & 7 deletions splash/src/Objects/Invoice/MainTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,19 @@ protected function getStateFields(string $key, string $fieldName)
//====================================================================//

case 'isDraft':
$this->out[$fieldName] = (0 == $this->object->statut);
$this->out[$fieldName] = (Facture::STATUS_DRAFT == $this->getInvoiceStatus());

break;
case 'isCanceled':
$this->out[$fieldName] = (3 == $this->object->statut);
$this->out[$fieldName] = (Facture::STATUS_ABANDONED == $this->getInvoiceStatus());

break;
case 'isValidated':
$this->out[$fieldName] = (1 == $this->object->statut);
$this->out[$fieldName] = (Facture::STATUS_VALIDATED == $this->getInvoiceStatus());

break;
case 'isPaid':
$this->out[$fieldName] = (2 == $this->object->statut);
$this->out[$fieldName] = (Facture::STATUS_CLOSED == $this->getInvoiceStatus());

break;
default:
Expand Down Expand Up @@ -257,21 +257,21 @@ private function setPaidFlag($data): bool
}
//====================================================================//
// If Status Is Not Validated | Closed => Cannot Update This Flag
if (!in_array((int) $this->object->statut, array(Facture::STATUS_VALIDATED, Facture::STATUS_CLOSED), false)) {
if (!in_array($this->getInvoiceStatus(), array(Facture::STATUS_VALIDATED, Facture::STATUS_CLOSED), false)) {
return true;
}
//====================================================================//
// Update This Flag
if ($data) {
//====================================================================//
// Set Paid using Dolibarr Function
if ((1 == $this->object->statut) && (1 != $this->object->set_paid($user))) {
if ((Facture::STATUS_VALIDATED == $this->getInvoiceStatus()) && (1 != $this->object->set_paid($user))) {
return $this->catchDolibarrErrors();
}
} else {
//====================================================================//
// Set UnPaid using Dolibarr Function
if ((2 == $this->object->statut) && (1 != $this->object->set_unpaid($user))) {
if ((Facture::STATUS_CLOSED == $this->getInvoiceStatus()) && (1 != $this->object->set_unpaid($user))) {
return $this->catchDolibarrErrors();
}
}
Expand Down
Loading

0 comments on commit 8f3a73f

Please sign in to comment.