finish facture group details

This commit is contained in:
Tiavina 2025-03-03 09:03:58 +03:00
parent a5188b7ebc
commit 7eb0a45a66
37 changed files with 350 additions and 71 deletions

View File

@ -65,6 +65,7 @@ return [
['name' => 'page#getFactures', 'url' => '/getFactures', 'verb' => 'PROPFIND'], ['name' => 'page#getFactures', 'url' => '/getFactures', 'verb' => 'PROPFIND'],
['name' => 'page#getFacturesWithProduits', 'url' => '/getFacturesWithProduits', 'verb' => 'PROPFIND'], ['name' => 'page#getFacturesWithProduits', 'url' => '/getFacturesWithProduits', 'verb' => 'PROPFIND'],
['name' => 'page#factureshow', 'url' => '/facture/{numfacture}/show', 'verb' => 'GET'], ['name' => 'page#factureshow', 'url' => '/facture/{numfacture}/show', 'verb' => 'GET'],
['name' => 'page#factureGroupDetails', 'url' => '/facture/{numfacture}/groupDetails', 'verb' => 'GET'],
['name' => 'page#apercustoutesfactures', 'url' => '/factures/apercus', 'verb' => 'GET'], ['name' => 'page#apercustoutesfactures', 'url' => '/factures/apercus', 'verb' => 'GET'],
['name' => 'page#apercustousdevis', 'url' => '/devis/apercus', 'verb' => 'GET'], ['name' => 'page#apercustousdevis', 'url' => '/devis/apercus', 'verb' => 'GET'],
['name' => 'page#insertFacture', 'url' => '/facture/insert', 'verb' => 'POST'], ['name' => 'page#insertFacture', 'url' => '/facture/insert', 'verb' => 'POST'],

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,46 @@
/*!
* Sizzle CSS Selector Engine v2.3.9
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2022-12-19
*/
/*!
* Toastify js 1.12.0
* https://github.com/apvarun/toastify-js
* @license MIT licensed
*
* Copyright (C) 2018 Varun A P
*/
/*!
* escape-html
* Copyright(c) 2012-2013 TJ Holowaychuk
* Copyright(c) 2015 Andreas Lubbe
* Copyright(c) 2015 Tiancheng "Timothy" Gu
* MIT Licensed
*/
/*!
* jQuery JavaScript Library v3.6.3
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2022-12-20T21:28Z
*/
/*! @license DOMPurify 2.4.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.4/LICENSE */
/*! DataTables 1.13.2
* ©2008-2023 SpryMedia Ltd - datatables.net/license
*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,7 @@ namespace OCA\Gestion\Controller;
use Exception; use Exception;
use OCA\Gestion\Constants\BddConstant; use OCA\Gestion\Constants\BddConstant;
use OCA\Gestion\Constants\DevisMentionConstant;
use OCA\Gestion\Constants\FactureTypeConstant; use OCA\Gestion\Constants\FactureTypeConstant;
use OCA\Gestion\Service\InvoicePdfHandler; use OCA\Gestion\Service\InvoicePdfHandler;
defined("TAB1") or define("TAB1", "\t"); defined("TAB1") or define("TAB1", "\t");
@ -342,7 +343,13 @@ class PageController extends Controller {
* @NoCSRFRequired * @NoCSRFRequired
*/ */
public function apercustousdevis() { public function apercustousdevis() {
$devis = json_decode($this->myDb->getDevis($this->idNextcloud)); $devisMentionsFilter = [
DevisMentionConstant::FACTURED,
DevisMentionConstant::FACTURED_FORMATTED,
DevisMentionConstant::MENTION,
DevisMentionConstant::NEW
];
$devis = json_decode($this->myDb->getDevis($this->idNextcloud,$devisMentionsFilter));
foreach ($devis as $key => $d) { foreach ($devis as $key => $d) {
$d->dproduits = []; $d->dproduits = [];
$produits = json_decode($this->myDb->getListProduit($d->id, $this->idNextcloud)); $produits = json_decode($this->myDb->getListProduit($d->id, $this->idNextcloud));
@ -2965,10 +2972,10 @@ class PageController extends Controller {
*/ */
public function factureGroupDetails($numfacture){ public function factureGroupDetails($numfacture){
$this->denyIfNotAdmin(); $this->denyIfNotAdmin();
$facture = $this->myDb->getOneFacture($numfacture,$this->idNextcloud); $facture = $this->myDb->getFactureGroupByFactureIdWithDetails($numfacture);
return new TemplateResponse('gestion', 'factureshow', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, return new TemplateResponse('gestion', 'factureGroupDetails', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud,
'configuration'=> $this->getConfiguration(), 'configuration'=> $this->getConfiguration(),
'facture'=>json_decode($facture), 'facture'=>json_decode(json_encode($facture)),
'url' => $this->getNavigationLink(), 'url' => $this->getNavigationLink(),
'logo' => $this->getLogo() 'logo' => $this->getLogo()
)); ));

View File

@ -51,7 +51,8 @@ class Bdd {
"product_brand","product_reference", "product_brand","product_reference",
"fk_user_uuid", "fk_user_uuid",
"phone_number","address",'postal_code','city','email','siret_number','tva_intracommu', "phone_number","address",'postal_code','city','email','siret_number','tva_intracommu',
'order_number','case_number','fk_template_type_key'); 'order_number','case_number','fk_template_type_key',
'facture_case_number','facture_order_number');
$this->whiteTable = array( $this->whiteTable = array(
"client", "lieu", "trajet", "devis", "produit_devis", "facture", "produit", "configuration", "ligne_trajet", "thanato", "article", "defunt", "article_devis", "bibliotheque", "bijou_defunt", "obs_defunt", "hypo_defunt", "client", "lieu", "trajet", "devis", "produit_devis", "facture", "produit", "configuration", "ligne_trajet", "thanato", "article", "defunt", "article_devis", "bibliotheque", "bijou_defunt", "obs_defunt", "hypo_defunt",
"client_group_discount","client_group", "client_group_discount","client_group",
@ -352,6 +353,9 @@ class Bdd {
.$this->tableprefix."facture.fk_facture_status_key, ".$this->tableprefix."facture.fk_facture_payment_type_id, ".$this->tableprefix."facture.payment_date, " .$this->tableprefix."facture.fk_facture_status_key, ".$this->tableprefix."facture.fk_facture_payment_type_id, ".$this->tableprefix."facture.payment_date, "
.$this->tableprefix."facture_payment_type.facture_payment_type_label, " .$this->tableprefix."facture_payment_type.facture_payment_type_label, "
.$this->tableprefix."facture_status.facture_status_label, " .$this->tableprefix."facture_status.facture_status_label, "
.$this->tableprefix."facture.facture_type, "
.$this->tableprefix."facture.fk_client_id as facture_client_id, "
.$this->tableprefix."facture.fk_client_group_facturation_id as facture_client_group_facturation_id, "
.$this->tableprefix."devis.num as dnum, ".$this->tableprefix."devis.comment as dcomment, date_paiement, type_paiement, id_devis, entreprise, " .$this->tableprefix."devis.num as dnum, ".$this->tableprefix."devis.comment as dcomment, date_paiement, type_paiement, id_devis, entreprise, "
.$this->tableprefix."facture.version, status_paiement," .$this->tableprefix."facture.version, status_paiement,"
.$this->tableprefix."client.nom, ".$this->tableprefix."client.prenom, " .$this->tableprefix."client.nom, ".$this->tableprefix."client.prenom, "
@ -2706,7 +2710,7 @@ class Bdd {
client.prenom as client_prenom, client.prenom as client_prenom,
client.entreprise as client_entreprise, client.entreprise as client_entreprise,
client.legal_one as client_legal_one, client.legal_one as client_legal_one,
client.addresse as client_address, client.adresse as client_address,
client.mail as client_mail, client.mail as client_mail,
client.fk_client_group_id as fk_client_group_id client.fk_client_group_id as fk_client_group_id
FROM ".$this->tableprefix."client as client FROM ".$this->tableprefix."client as client
@ -2803,25 +2807,29 @@ class Bdd {
$tvaValue = $configuration->tva_default; $tvaValue = $configuration->tva_default;
$factureData = $this->getFactureByFactureId($factureId); $factureData = $this->getFactureByFactureId($factureId);
$isFactureForSingleClient = $factureData['fk_client_id'] != null && $factureData['fk_client_id'] != 0; $isFactureForSingleClient = $factureData['fk_client_id'] != null && $factureData['fk_client_id'] != 0;
$devisMentionFilters = [
DevisMentionConstant::FACTURED_FORMATTED,
DevisMentionConstant::FACTURED
];
if($isFactureForSingleClient){ if($isFactureForSingleClient){
$factureDevisList = $this->getDevisDataByClientIdAndMonthYear( $factureDevisList = $this->getDevisDataByClientIdAndMonthYear(
$factureData['fk_client_id'], $factureData['fk_client_id'],
$factureData['month'], $factureData['month'],
$factureData['year']); $factureData['year'],$devisMentionFilters
);
} }
else{ else{
$factureDevisList = $this->getDevisDataByClientGroupFacturationIdAndMonthYear( $factureDevisList = $this->getDevisDataByClientGroupFacturationIdAndMonthYear(
$factureData['fk_client_group_facturation_id'], $factureData['fk_client_group_facturation_id'],
$factureData['month'], $factureData['month'],
$factureData['year']); $factureData['year'],$devisMentionFilters
);
} }
$factureIncrement = 0; $factureIncrement = 0;
$productsCount = 0; $productsCount = 0;
$totalHt = 0; $totalHt = 0;
$totalTtc = 0; $totalTtc = 0;
$totalTva = 0; $totalTva = 0;
$caseNumber = "";
$orderNumber = "";
$templateType = ClientTemplateTypeConstant::PRIVEES; $templateType = ClientTemplateTypeConstant::PRIVEES;
foreach($factureDevisList as &$devis){ foreach($factureDevisList as &$devis){
if($factureIncrement == 0){ if($factureIncrement == 0){
@ -2842,8 +2850,6 @@ class Bdd {
$templateType = $devis['fk_template_type_key'] ?? ClientTemplateTypeConstant::PRIVEES; $templateType = $devis['fk_template_type_key'] ?? ClientTemplateTypeConstant::PRIVEES;
} }
} }
$caseNumber = empty($devis["case_number"]) ? $caseNumber : $devis["case_number"];
$orderNumber = empty($devis["order_number"]) ? $orderNumber : $devis["order_number"];
$products = $this->getDevisProduits($devis["devis_id"]); $products = $this->getDevisProduits($devis["devis_id"]);
foreach($products as $product){ foreach($products as $product){
$valueHt = $product['produit_price'] * $product['quantite']; $valueHt = $product['produit_price'] * $product['quantite'];
@ -2869,8 +2875,6 @@ class Bdd {
$factureData["configuration_adresse_city"] = $configurationAdresses["city"]; $factureData["configuration_adresse_city"] = $configurationAdresses["city"];
$factureData["productsCount"] = $productsCount; $factureData["productsCount"] = $productsCount;
$factureData["totalPrices"] = $totaPricesArray; $factureData["totalPrices"] = $totaPricesArray;
$factureData["case_number"] = $caseNumber;
$factureData["order_number"] = $orderNumber;
$factureData["template_type_key"] = $templateType; $factureData["template_type_key"] = $templateType;
return $factureData; return $factureData;
} }
@ -4166,7 +4170,7 @@ class Bdd {
return FactureTypeConstant::TYPE_SINGLE; return FactureTypeConstant::TYPE_SINGLE;
} }
public function getDevisIdsByClientGroupFacturationIdAndMonthYear($clientGroupFacturationId,$month,$year){ public function getDevisIdsByClientGroupFacturationIdAndMonthYear($clientGroupFacturationId,$month,$year,$mentionFilters = []){
$sql = "SELECT devis.id $sql = "SELECT devis.id
FROM ".$this->tableprefix."devis as devis FROM ".$this->tableprefix."devis as devis
LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id
@ -4176,27 +4180,39 @@ class Bdd {
MONTH(devis.date) = ? MONTH(devis.date) = ?
"; ";
$result = $this->execSQLNoJsonReturn($sql,[$clientGroupFacturationId,$year,$month]); $conditions = [$clientGroupFacturationId,$year,$month];
if(!empty($mentionFilters)){
$mentionsFilterPlaceholders = implode(',', array_fill(0, count($mentionFilters), '?'));
$sql .= " AND ". $this->tableprefix."devis.mentions IN ($mentionsFilterPlaceholders)";
$conditions = array_merge($conditions, $mentionFilters);
}
$sql.= ";";
$result = $this->execSQLNoJsonReturn($sql,$conditions);
$devisIds = []; $devisIds = [];
foreach($result as $currentResult){ foreach($result as $currentResult){
$devisIds[] = $currentResult['id']; $devisIds[] = $currentResult['id'];
} }
return $devisIds; return $devisIds;
} }
public function getDevisIdsByClientIdAndMonthYear($clientId,$month,$year){ public function getDevisIdsByClientIdAndMonthYear($clientId,$month,$year,$mentionFilters = []){
$sql = "SELECT devis.id $sql = "SELECT devis.id
FROM ".$this->tableprefix."devis as devis FROM ".$this->tableprefix."devis as devis
LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id
WHERE WHERE
client.id = ? AND client.id = ? AND
YEAR(devis.date) = ? AND YEAR(devis.date) = ? AND
MONTH(devis.date) = ? MONTH(devis.date) = ?";
";
$result = $this->execSQLNoJsonReturn($sql,[$clientId,$year,$month]); $conditions = [$clientId,$year,$month];
if(!empty($mentionFilters)){
$mentionsFilterPlaceholders = implode(',', array_fill(0, count($mentionFilters), '?'));
$sql .= " AND devis.mentions IN ($mentionsFilterPlaceholders)";
$conditions = array_merge($conditions, $mentionFilters);
}
$sql.= ";";
$result = $this->execSQLNoJsonReturn($sql,$conditions);
$devisIds = []; $devisIds = [];
foreach($result as $currentResult){ foreach($result as $currentResult){
@ -4266,7 +4282,7 @@ class Bdd {
$this->execSQLNoData($sql,$conditions); $this->execSQLNoData($sql,$conditions);
} }
private function getDevisDataByClientGroupFacturationIdAndMonthYear($clientGroupFacturationId,$month,$year){ private function getDevisDataByClientGroupFacturationIdAndMonthYear($clientGroupFacturationId,$month,$year,$mentionFilters = []){
$sql = "SELECT $sql = "SELECT
devis.id as devis_id, devis.id as devis_id,
devis.date as devis_date, devis.date as devis_date,
@ -4274,6 +4290,7 @@ class Bdd {
devis.comment as devis_comment, devis.comment as devis_comment,
devis.order_number as order_number, devis.order_number as order_number,
devis.case_number as case_number, devis.case_number as case_number,
devis.devis_full_number as devis_full_number,
client.nom as client_nom, client.nom as client_nom,
client.entreprise as client_entreprise, client.entreprise as client_entreprise,
client.adresse as client_adresse, client.adresse as client_adresse,
@ -4304,19 +4321,21 @@ class Bdd {
WHERE WHERE
client.fk_client_group_facturation_id = ? AND client.fk_client_group_facturation_id = ? AND
YEAR(devis.date) = ? AND YEAR(devis.date) = ? AND
MONTH(devis.date) = ? MONTH(devis.date) = ?";
ORDER BY devis.date ASC;";
$devisList = $this->execSQLNoJsonReturn($sql,[ $conditions = [$clientGroupFacturationId,$year,$month];
$clientGroupFacturationId, if(!empty($mentionFilters)){
$year, $mentionsFilterPlaceholders = implode(',', array_fill(0, count($mentionFilters), '?'));
$month $sql .= " AND devis.mentions IN ($mentionsFilterPlaceholders)";
]); $conditions = array_merge($conditions, $mentionFilters);
}
$sql.= " ORDER BY devis.date ASC;";
$devisList = $this->execSQLNoJsonReturn($sql,$conditions);
return $devisList; return $devisList;
} }
private function getDevisDataByClientIdAndMonthYear($clientId,$month,$year){ private function getDevisDataByClientIdAndMonthYear($clientId,$month,$year,$mentionFilters = []){
$sql = "SELECT $sql = "SELECT
devis.id as devis_id, devis.id as devis_id,
devis.date as devis_date, devis.date as devis_date,
@ -4324,6 +4343,7 @@ class Bdd {
devis.comment as devis_comment, devis.comment as devis_comment,
devis.order_number as order_number, devis.order_number as order_number,
devis.case_number as case_number, devis.case_number as case_number,
devis.devis_full_number as devis_full_number,
client.nom as client_nom, client.nom as client_nom,
client.entreprise as client_entreprise, client.entreprise as client_entreprise,
client.adresse as client_adresse, client.adresse as client_adresse,
@ -4354,14 +4374,16 @@ class Bdd {
WHERE WHERE
client.id = ? AND client.id = ? AND
YEAR(devis.date) = ? AND YEAR(devis.date) = ? AND
MONTH(devis.date) = ? MONTH(devis.date) = ?";
ORDER BY devis.date ASC;";
$devisList = $this->execSQLNoJsonReturn($sql,[ $conditions = [$clientId,$year,$month];
$clientId, if(!empty($mentionFilters)){
$year, $mentionsFilterPlaceholders = implode(',', array_fill(0, count($mentionFilters), '?'));
$month $sql .= " AND devis.mentions IN ($mentionsFilterPlaceholders)";
]); $conditions = array_merge($conditions, $mentionFilters);
}
$sql.= " ORDER BY devis.date ASC;";
$devisList = $this->execSQLNoJsonReturn($sql,$conditions);
return $devisList; return $devisList;
} }
@ -4378,7 +4400,9 @@ class Bdd {
facture.date_paiement, facture.date_paiement,
facture.num, facture.num,
facture.fk_client_id, facture.fk_client_id,
facture.fk_client_group_facturation_id facture.fk_client_group_facturation_id,
facture.month,
facture.year
FROM ".$this->tableprefix."facture as facture FROM ".$this->tableprefix."facture as facture
WHERE facture.id = ? AND WHERE facture.id = ? AND
facture.facture_type = ? facture.facture_type = ?
@ -4398,11 +4422,13 @@ class Bdd {
$currentConfig = $configuration[0]; $currentConfig = $configuration[0];
$tvaValue = $currentConfig->tva_default; $tvaValue = $currentConfig->tva_default;
$isFactureSingleClient = $facture['fk_client_id'] != null $isFactureSingleClient = $facture['fk_client_id'] != null
&& $facture['fk_client_id'] != 0 && $facture['fk_client_id'] != 0;
&& ($facture['fk_client_group_facturation_id'] == null || $facture['fk_client_group_facturation_id'] == 0);
$devisMentionFilters = [
DevisMentionConstant::FACTURED,
DevisMentionConstant::FACTURED_FORMATTED
];
$devisList = [];
if($isFactureSingleClient){ if($isFactureSingleClient){
$client = $this->getClientById($facture['fk_client_id']); $client = $this->getClientById($facture['fk_client_id']);
$facture['group_name'] = $client["client_nom"]; $facture['group_name'] = $client["client_nom"];
@ -4413,7 +4439,8 @@ class Bdd {
$devisList = $this->getDevisDataByClientIdAndMonthYear( $devisList = $this->getDevisDataByClientIdAndMonthYear(
$facture['fk_client_id'], $facture['fk_client_id'],
$facture['month'], $facture['month'],
$facture['year'] $facture['year'],
$devisMentionFilters
); );
} }
else{ else{
@ -4426,7 +4453,8 @@ class Bdd {
$devisList = $this->getDevisDataByClientGroupFacturationIdAndMonthYear( $devisList = $this->getDevisDataByClientGroupFacturationIdAndMonthYear(
$facture['fk_client_group_facturation_id'], $facture['fk_client_group_facturation_id'],
$facture['month'], $facture['month'],
$facture['year'] $facture['year'],
$devisMentionFilters
); );
} }
$factureTotalHt= 0; $factureTotalHt= 0;
@ -4436,7 +4464,7 @@ class Bdd {
$totalHt = 0; $totalHt = 0;
$totalTva = 0; $totalTva = 0;
$totalTtc = 0; $totalTtc = 0;
$devisProducts = $this->getDevisProduits($currentDevis['id']); $devisProducts = $this->getDevisProduits($currentDevis['devis_id']);
foreach($devisProducts as $currentProduct){ foreach($devisProducts as $currentProduct){
$valueHt = $currentProduct['produit_price'] * $currentProduct['quantite']; $valueHt = $currentProduct['produit_price'] * $currentProduct['quantite'];
$valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue); $valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue);
@ -4451,8 +4479,8 @@ class Bdd {
$factureTotalHt += $totalHt; $factureTotalHt += $totalHt;
$factureTotalTtc += $totalTtc; $factureTotalTtc += $totalTtc;
$factureTotalTva += $totalTva; $factureTotalTva += $totalTva;
$facture["devisList"][] = $currentDevis;
} }
$facture["devisList"] = $devisList;
$facture["totalHt"] = $factureTotalHt; $facture["totalHt"] = $factureTotalHt;
$facture["totalTtc"] = $factureTotalTtc; $facture["totalTtc"] = $factureTotalTtc;
$facture["totalTva"] = $factureTotalTva; $facture["totalTva"] = $factureTotalTva;

View File

@ -13,4 +13,8 @@ class PriceHelpers
return ($price * (1 + ($vat / 100))); return ($price * (1 + ($vat / 100)));
} }
public static function formatDecimalPrice($price){
return number_format($price,2,'.','');
}
} }

View File

@ -83,7 +83,7 @@ class InvoiceOgfPdfHandler extends InvoiceGroupPdfHandler {
$this->Cell(60, 7, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C'); $this->Cell(60, 7, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C');
$this->Cell(40, 7, $this->factureData['num'], 1, 0, 'C'); $this->Cell(40, 7, $this->factureData['num'], 1, 0, 'C');
$this->Cell(40, 7, $factureDateEcheance, 1, 0, 'C'); $this->Cell(40, 7, $factureDateEcheance, 1, 0, 'C');
$this->Cell(34, 7, $this->factureData["order_number"], 1, 1, 'C'); $this->Cell(34, 7, $this->factureData["facture_order_number"], 1, 1, 'C');
$this->startingYOfArticlesTable = 85; $this->startingYOfArticlesTable = 85;
} }

View File

@ -29,6 +29,7 @@ namespace OCA\Gestion\Service;
use DateTime; use DateTime;
use OCA\Gestion\Constants\BddConstant; use OCA\Gestion\Constants\BddConstant;
use OCA\Gestion\Constants\ClientTemplateTypeConstant; use OCA\Gestion\Constants\ClientTemplateTypeConstant;
use OCA\Gestion\Constants\DevisMentionConstant;
use OCA\Gestion\Constants\FactureTypeConstant; use OCA\Gestion\Constants\FactureTypeConstant;
use OCA\Gestion\Constants\MultipleFactureTypeConstant; use OCA\Gestion\Constants\MultipleFactureTypeConstant;
use OCA\Gestion\Db\Bdd; use OCA\Gestion\Db\Bdd;
@ -252,9 +253,13 @@ class InvoicePdfService {
$factureId = null; $factureId = null;
$fkClientId = null; $fkClientId = null;
$fkClientGroupFacturationId = null; $fkClientGroupFacturationId = null;
$devisMentionFiltersToBeInvoiced = [
DevisMentionConstant::NEW,
DevisMentionConstant::MENTION
];
if($clientType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE){ if($clientType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE){
$factureId = $this->gestionBdd->getFactureIdByClientIdAndMonthYear($clientId,$month,$year); $factureId = $this->gestionBdd->getFactureIdByClientIdAndMonthYear($clientId,$month,$year);
$devisIds = $this->gestionBdd->getDevisIdsByClientIdAndMonthYear($clientId,$month,$year); $devisIds = $this->gestionBdd->getDevisIdsByClientIdAndMonthYear($clientId,$month,$year,$devisMentionFiltersToBeInvoiced);
$fkClientId = $clientId; $fkClientId = $clientId;
} }
else{ else{

View File

@ -7,3 +7,6 @@ export const CanceledDevisMentionConstant = "CANCELED";
export const FactureStatusPaid = "PAID"; export const FactureStatusPaid = "PAID";
export const FactureStatusPending = "PENDING"; export const FactureStatusPending = "PENDING";
export const FactureStatusCanceled = "CANCELED"; export const FactureStatusCanceled = "CANCELED";
export const FactureTypeSingle = "SINGLE";
export const FactureTypeGroup = "GROUP";

View File

@ -0,0 +1,12 @@
import "@nextcloud/dialogs/dist/index.css";
import "datatables.net-dt/css/jquery.dataTables.css";
import "../css/mycss.css";
import { globalConfiguration } from "./modules/mainFunction.mjs";
import "./listener/main_listener";
import "./listener/invoiceListener";
window.addEventListener("DOMContentLoaded", function () {
globalConfiguration();
});

View File

@ -2,6 +2,7 @@ import {showError, showSuccess } from "@nextcloud/dialogs";
import {baseUrl, hideLoader, showLoader} from "../modules/mainFunction.mjs"; import {baseUrl, hideLoader, showLoader} from "../modules/mainFunction.mjs";
import { Facture } from "../objects/facture.mjs"; import { Facture } from "../objects/facture.mjs";
import DataTable from "datatables.net"; import DataTable from "datatables.net";
import { generateUrl } from "@nextcloud/router";
window.addEventListener("DOMContentLoaded", function () { window.addEventListener("DOMContentLoaded", function () {
const today = new Date(); const today = new Date();
@ -129,3 +130,9 @@ document.onchange = function(event) {
} }
} }
}; };
$('body').on('click', '.goToDevisDetails', function () {
let devisId = $(this).data('devis-id');
let url = generateUrl(`/apps/gestion/devis/${devisId}/show`);
window.location.href = url;
});

View File

@ -2,6 +2,7 @@ import { showError } from "@nextcloud/dialogs";
import { generateUrl } from "@nextcloud/router"; import { generateUrl } from "@nextcloud/router";
import { baseUrl, LoadDT, showDone } from "../modules/mainFunction.mjs"; import { baseUrl, LoadDT, showDone } from "../modules/mainFunction.mjs";
import { Devis } from "./devis.mjs"; import { Devis } from "./devis.mjs";
import { FactureTypeSingle } from "../constants/invoiceConstant.js";
export class Facture { export class Facture {
@ -32,6 +33,13 @@ export class Facture {
paymentDate = paymentDate.toLocaleDateString("fr-FR"); paymentDate = paymentDate.toLocaleDateString("fr-FR");
} }
this.payment_date = paymentDate; this.payment_date = paymentDate;
this.factureType = myresp.facture_type;
if(this.factureType == FactureTypeSingle){
this.baseUrl = generateUrl(`/apps/gestion/facture/${this.id}/show`);
}
else{
this.baseUrl = generateUrl(`/apps/gestion/facture/${this.id}/groupDetails`);
}
} }
/** /**

View File

@ -0,0 +1,137 @@
<?php
use OC\URLGenerator;
use OCA\Gestion\Helpers\PriceHelpers;
$facture = $_['facture'];
$factureOrderNumber = $facture->facture_order_number == '' ? '-' : $facture->facture_order_number;
$factureCaseNumber = $facture->facture_case_number == '' ? '-' : $facture->facture_case_number;
$currentConfig = json_decode($_['configuration'])[0];
?>
<div class="bootstrap-iso">
<div id="factureId" data-id="<?php echo $facture->id; ?>"></div>
<div id="factureIdentifier" data-id="<?php echo $facture->id; ?>"></div>
<h2 class="mt-3 mb-3 text-center"> <?php echo ('Facture n° '.$facture->num); ?>
</h2>
<hr />
<div class="row">
<div class="col-5 h-100 m-0" style="min-height:250px;">
<h5 class="p-3 m-0 text-dark text-center border border-2 border-dark"><?php p($l->t('FROM')); ?>
<?php echo $currentConfig->entreprise; ?></h5>
<p style="min-height:180px;"
class="p-3 m-0 h-100 text-center text-dark text-center border border-top-0 border-2 border-dark">
<?php echo $currentConfig->prenom . " " . $currentConfig->nom; ?><br />
<?php echo $currentConfig->adresse; ?><br />
<?php echo $currentConfig->mail; ?><br />
<?php echo $currentConfig->telephone; ?><br />
<span id="nothing"></span><br />
</p>
</div>
<div class="col-2 h-100 m-0" style="min-height:250px;">
<?php
if (isset($_['logo']) && $_['logo'] !== "nothing") {
echo "<center><a><img alt='" . $l->t('Company logo') . "' class=\"img-fluid\" src=\"data:image/png;base64, " . $_['logo'] . "\"/></a></center>";
} else {
echo "<span style='font-size:12px' id='Company-logo' data-html2canvas-ignore><b><center>" . $l->t('You can add your company logo here.') . "</center></b><br/><i>" . $l->t('To add a logo, drop the logo.png file in ".gestion" folder at the root of your Nextcloud Files app. Remember to set "Show hidden files".') . "</i><br/><br/><center>" . $l->t('This message will not appear on generated PDF.') . "</center></span>";
}
?>
</div>
<div class="col-5 h-100 m-0" style="min-height:250px;">
<h5 class="p-3 m-0 text-dark text-center border border-2 border-dark"><?php p($l->t('TO')); ?>
<span><?php echo $facture->group_name; ?></span></h5>
<p style="min-height:180px;"
class="p-3 m-0 h-100 text-center text-dark text-center border border-top-0 border-2 border-dark">
<span><?php echo $facture->group_name; ?></span><br />
<span><?php echo $facture->client_name; ?></span><br />
<span><?php echo $facture->client_address; ?></span><br />
<span><?php echo $facture->mail; ?></span><br />
<span><?php echo $facture->siret; ?></span><br />
</p>
</div>
</div>
<hr />
<div class="row">
<div class="col col-md">
<label class="fw-bold">Commande :</label>
<div class="col col-xl mb-3 text-center editable" style="display:inline" data-table="facture"
data-column="facture_order_number" data-id="<?php echo $facture->id; ?>">
<?php echo $factureOrderNumber; ?>
</div>
</div>
<hr />
</div>
<div class="row">
<div class="col col-md">
<label class="fw-bold">Numéro de dossier :</label>
<div class="col col-xl mb-3 text-center editable" style="display:inline" data-table="facture"
data-column="facture_case_number" data-id="<?php echo $facture->id; ?>">
<?php echo $factureCaseNumber; ?>
</div>
</div>
<hr />
</div>
<div class="table-responsive">
<table id="factureGroupId" class="table table-striped">
<thead>
<tr>
<th><?php p($l->t('Devis')); ?></th>
<th><?php p($l->t('Defunt')); ?></th>
<th><?php p($l->t('Agence')); ?></th>
<th><?php p($l->t('Prix HT')); ?></th>
<th><?php p($l->t('Prix TTC')); ?></th>
<th><?php p($l->t('Actions')); ?></th>
</tr>
</thead>
<tbody>
<?php
$devisList = $facture->devisList;
foreach ($devisList as $currentDevis) {
?>
<tr>
<td><?php echo $currentDevis->devis_full_number; ?></td>
<td><?php echo $currentDevis->defunt_nom; ?></td>
<td><?php echo $currentDevis->client_nom; ?></td>
<td><?php echo PriceHelpers::formatDecimalPrice($currentDevis->totalHt).'€'; ?></td>
<td><?php echo PriceHelpers::formatDecimalPrice($currentDevis->totalTtc).'€'; ?></td>
<td>
<div style="display:inline-block;margin-right:0px;width:80%;">
<button class="goToDevisDetails" data-devis-id="<?php echo $currentDevis->devis_id; ?>">Ouvrir</button>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<div>
<button id="exportFactureToPdf" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore data-name=""><?php p($l->t('Save in Nextcloud'));?></button>
<button id="mailGestion" type="button" class="mb-2 btn btn-outline-success sendmail" data-html2canvas-ignore data-name=""><?php p($l->t('Send by email'));?></button>
</div>
<div class="mt-0 table-responsive">
<table id="totalFactureGroupPrice" class="table table-striped table-xl">
<thead class="bg-dark text-white">
<tr>
<th class="text-center"><?php p($l->t('Total without VAT')); ?></th>
<th class="text-center"><?php p($l->t('VAT Rate')); ?></th>
<th class="text-center"><?php p($l->t('Total VAT')); ?></th>
<th class="text-center"><?php p($l->t('Total Price')); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($facture->totalHt).'€'); ?></td>
<td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($currentConfig->tva_default).'€'); ?></td>
<td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($facture->totalTva).'€'); ?></td>
<td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($facture->totalTtc).'€'); ?></td>
</tr>
</tbody>
</table>
</div>
<div class="col m-0 pb-0 alert alert-info text-center">
<p><span id="mentions_default"><?php p($l->t('Please set in global configuration')); ?></span></p>
</div>
<hr />
<div class="col m-0 pb-0 alert alert-info text-center">
<p><?php echo $currentConfig->entreprise; ?><br /><?php echo $currentConfig->adresse; ?><br /><?php echo $currentConfig->legal_one; ?><br /><?php echo $currentConfig->legal_two; ?>
</p>
</div>
</div>

View File

@ -0,0 +1,18 @@
<?php
style('gestion', array('style'));
script('gestion', array('factureGroupDetails.app', '814.app', '856.app'));
?>
<div id="app">
<div id="app-navigation">
<?php print_unescaped($this->inc('navigation/index')); ?>
<?php print_unescaped($this->inc('settings/index')); ?>
</div>
<div id="app-content">
<div id="app-content-wrapper">
<?php print_unescaped($this->inc('content/changelog')); ?>
<?php print_unescaped($this->inc('content/factureGroupDetails')); ?>
<?php print_unescaped($this->inc('loader')); ?>
</div>
</div>
</div>

View File

@ -31,6 +31,7 @@ module.exports =
clientGroup: './src/js/clientGroup.js', clientGroup: './src/js/clientGroup.js',
clientGroupFacturation : './src/js/clientGroupFacturation.js', clientGroupFacturation : './src/js/clientGroupFacturation.js',
pdf: './src/js/pdf.js', pdf: './src/js/pdf.js',
factureGroupDetails: './src/js/factureGroupDetails.js'
}, },
output: { output: {
filename: '../js/[name].app.js', filename: '../js/[name].app.js',