fix statistique client calcul total HT
This commit is contained in:
parent
34717b772d
commit
411cc2d5a8
@ -3208,7 +3208,7 @@ class Bdd
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getClientFactureStatisticPerMonth($clientId, array $produitList)
|
private function getClientFactureStatisticPerMonth($clientId, array $produitList, $clientGroupId = null)
|
||||||
{
|
{
|
||||||
$currentYear = date('Y');
|
$currentYear = date('Y');
|
||||||
$monthLists = range(1, 12);
|
$monthLists = range(1, 12);
|
||||||
@ -3245,7 +3245,8 @@ class Bdd
|
|||||||
$statisticForeachProductPerMonth[$produit['id']] = 0;
|
$statisticForeachProductPerMonth[$produit['id']] = 0;
|
||||||
}
|
}
|
||||||
$productTotalCount = $this->getDevisProductsQuantityByDevisListAndProductId($factureDevisIds, $produit['id']);
|
$productTotalCount = $this->getDevisProductsQuantityByDevisListAndProductId($factureDevisIds, $produit['id']);
|
||||||
$totalWithoutVat = $productTotalCount * $produit["prix_unitaire"];
|
$prixUnitaire = is_null($clientGroupId) ? $produit["prix_unitaire"] : $this->getProductPriceByClientGroupId($clientGroupId, $produit['id']);
|
||||||
|
$totalWithoutVat = $productTotalCount * $prixUnitaire;
|
||||||
$statisticForeachProductPerMonth[$produit['id']] += $productTotalCount;
|
$statisticForeachProductPerMonth[$produit['id']] += $productTotalCount;
|
||||||
$produitsPrice += $totalWithoutVat;
|
$produitsPrice += $totalWithoutVat;
|
||||||
}
|
}
|
||||||
@ -3272,9 +3273,10 @@ class Bdd
|
|||||||
$client = $this->getClientById($clientId);
|
$client = $this->getClientById($clientId);
|
||||||
if($client != null) {
|
if($client != null) {
|
||||||
$clientName = trim($client["client_nom"]) . '-' .trim($client['client_entreprise']);
|
$clientName = trim($client["client_nom"]) . '-' .trim($client['client_entreprise']);
|
||||||
|
$clientGroupId = $client['fk_client_group_id'];
|
||||||
}
|
}
|
||||||
$data[$clientId]["client_name"] = $clientName;
|
$data[$clientId]["client_name"] = $clientName;
|
||||||
$data[$clientId]["client_data"] = $this->getClientFactureStatisticPerMonth($clientId, $produitList);
|
$data[$clientId]["client_data"] = $this->getClientFactureStatisticPerMonth($clientId, $produitList, $clientGroupId);
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,8 @@ use OCA\Gestion\Db\Bdd;
|
|||||||
use OCA\Gestion\Helpers\FileExportHelpers;
|
use OCA\Gestion\Helpers\FileExportHelpers;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class ExportClientStatisticService {
|
class ExportClientStatisticService
|
||||||
|
{
|
||||||
/** @var Bdd */
|
/** @var Bdd */
|
||||||
private $gestionBdd;
|
private $gestionBdd;
|
||||||
|
|
||||||
@ -39,12 +40,14 @@ class ExportClientStatisticService {
|
|||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Bdd $gestionBdd,
|
Bdd $gestionBdd,
|
||||||
LoggerInterface $logger) {
|
LoggerInterface $logger
|
||||||
|
) {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->gestionBdd = $gestionBdd;
|
$this->gestionBdd = $gestionBdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFileName(array $clientIds){
|
public function getFileName(array $clientIds)
|
||||||
|
{
|
||||||
$filename = "";
|
$filename = "";
|
||||||
$clients = $this->gestionBdd->getClientsByClientsID($clientIds);
|
$clients = $this->gestionBdd->getClientsByClientsID($clientIds);
|
||||||
foreach($clients as $client) {
|
foreach($clients as $client) {
|
||||||
@ -56,7 +59,8 @@ class ExportClientStatisticService {
|
|||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getExportClientFileHeader(): string{
|
public function getExportClientFileHeader(): string
|
||||||
|
{
|
||||||
$fileHeader =
|
$fileHeader =
|
||||||
'CLIENT'.';'.
|
'CLIENT'.';'.
|
||||||
'MOIS'.';'.
|
'MOIS'.';'.
|
||||||
@ -71,7 +75,8 @@ class ExportClientStatisticService {
|
|||||||
return $fileHeader;
|
return $fileHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function populateExportDataIntoFileContent(array $exportData,string $fileContent): string{
|
public function populateExportDataIntoFileContent(array $exportData, string $fileContent): string
|
||||||
|
{
|
||||||
foreach($exportData as $clientId => $clientData) {
|
foreach($exportData as $clientId => $clientData) {
|
||||||
$clientName = $clientData["client_name"];
|
$clientName = $clientData["client_name"];
|
||||||
$clientStatPerMonth = $clientData["client_data"];
|
$clientStatPerMonth = $clientData["client_data"];
|
||||||
@ -88,7 +93,8 @@ class ExportClientStatisticService {
|
|||||||
return $fileContent;
|
return $fileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function populateTotalPriceIntoFileContent(string $fileContent,$totalPrice,$productsCount){
|
private function populateTotalPriceIntoFileContent(string $fileContent, $totalPrice, $productsCount)
|
||||||
|
{
|
||||||
$fileContent = $fileContent.
|
$fileContent = $fileContent.
|
||||||
''.';'.
|
''.';'.
|
||||||
''.';'.
|
''.';'.
|
||||||
@ -102,10 +108,12 @@ class ExportClientStatisticService {
|
|||||||
return $fileContent;
|
return $fileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function populateClientStatDataIntoFileContent(string $fileContent,$month,array $statPerMonth){
|
private function populateClientStatDataIntoFileContent(string $fileContent, $month, array $statPerMonth)
|
||||||
|
{
|
||||||
$yearValue = $statPerMonth["year"];
|
$yearValue = $statPerMonth["year"];
|
||||||
$defuntCount = $statPerMonth["defunt_count"];
|
$defuntCount = $statPerMonth["defunt_count"];
|
||||||
$products = $statPerMonth["products"];
|
$products = $statPerMonth["products"];
|
||||||
|
$priceTotal = $statPerMonth["total_price"];
|
||||||
|
|
||||||
$fileContent = $fileContent.
|
$fileContent = $fileContent.
|
||||||
FileExportHelpers::FormatTextForExport($statPerMonth['client_name']).';'.
|
FileExportHelpers::FormatTextForExport($statPerMonth['client_name']).';'.
|
||||||
@ -116,7 +124,7 @@ class ExportClientStatisticService {
|
|||||||
foreach($products as $productCount) {
|
foreach($products as $productCount) {
|
||||||
$fileContent .= "$productCount".";";
|
$fileContent .= "$productCount".";";
|
||||||
}
|
}
|
||||||
$fileContent .= "\n";
|
$fileContent .= "$priceTotal".';'."\n";
|
||||||
return $fileContent;
|
return $fileContent;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user