wip facture group details
This commit is contained in:
parent
560e097035
commit
a5188b7ebc
@ -2957,4 +2957,20 @@ class PageController extends Controller {
|
||||
public function getClientTemplateTypes(){
|
||||
return $this->myDb->getClientTemplateTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
*/
|
||||
public function factureGroupDetails($numfacture){
|
||||
$this->denyIfNotAdmin();
|
||||
$facture = $this->myDb->getOneFacture($numfacture,$this->idNextcloud);
|
||||
return new TemplateResponse('gestion', 'factureshow', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud,
|
||||
'configuration'=> $this->getConfiguration(),
|
||||
'facture'=>json_decode($facture),
|
||||
'url' => $this->getNavigationLink(),
|
||||
'logo' => $this->getLogo()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2705,6 +2705,9 @@ class Bdd {
|
||||
client.nom as client_nom,
|
||||
client.prenom as client_prenom,
|
||||
client.entreprise as client_entreprise,
|
||||
client.legal_one as client_legal_one,
|
||||
client.addresse as client_address,
|
||||
client.mail as client_mail,
|
||||
client.fk_client_group_id as fk_client_group_id
|
||||
FROM ".$this->tableprefix."client as client
|
||||
WHERE client.id = ?;";
|
||||
@ -4367,4 +4370,92 @@ class Bdd {
|
||||
$sql = "SELECT * FROM ".$this->tableprefix."client_template_type as client_template_type";
|
||||
return $this->execSQL($sql,[]);
|
||||
}
|
||||
|
||||
public function getFactureGroupById($factureId){
|
||||
$sql = "SELECT
|
||||
facture.id,
|
||||
facture.date,
|
||||
facture.date_paiement,
|
||||
facture.num,
|
||||
facture.fk_client_id,
|
||||
facture.fk_client_group_facturation_id
|
||||
FROM ".$this->tableprefix."facture as facture
|
||||
WHERE facture.id = ? AND
|
||||
facture.facture_type = ?
|
||||
;";
|
||||
|
||||
$result = $this->execSQLNoJsonReturn($sql,[$factureId,FactureTypeConstant::TYPE_GROUP]);
|
||||
if(!empty($result)){
|
||||
return $result[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getFactureGroupByFactureIdWithDetails($factureId){
|
||||
$facture = $this->getFactureGroupById($factureId);
|
||||
$configuration = $this->getConfiguration(BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD);
|
||||
$configuration = json_decode($configuration);
|
||||
$currentConfig = $configuration[0];
|
||||
$tvaValue = $currentConfig->tva_default;
|
||||
$isFactureSingleClient = $facture['fk_client_id'] != null
|
||||
&& $facture['fk_client_id'] != 0
|
||||
&& ($facture['fk_client_group_facturation_id'] == null || $facture['fk_client_group_facturation_id'] == 0);
|
||||
|
||||
|
||||
$devisList = [];
|
||||
if($isFactureSingleClient){
|
||||
$client = $this->getClientById($facture['fk_client_id']);
|
||||
$facture['group_name'] = $client["client_nom"];
|
||||
$facture['client_name'] = $client["client_prenom"];
|
||||
$facture['client_address'] = $client["client_address"];
|
||||
$facture['siret'] = $client["client_legal_one"];
|
||||
$facture['mail'] = $client["client_mail"];
|
||||
$devisList = $this->getDevisDataByClientIdAndMonthYear(
|
||||
$facture['fk_client_id'],
|
||||
$facture['month'],
|
||||
$facture['year']
|
||||
);
|
||||
}
|
||||
else{
|
||||
$clientGroupFacturation = $this->getClientGroupFacturationById($facture['fk_client_group_facturation_id']);
|
||||
$facture['group_name'] = $clientGroupFacturation["group_facturation_name"];
|
||||
$facture['client_name'] = $clientGroupFacturation["group_facturation_name"];
|
||||
$facture['client_address'] = $clientGroupFacturation["address"] . ' - ' .$clientGroupFacturation["postal_code"] . ' ' . $clientGroupFacturation['city'];
|
||||
$facture['siret'] = $clientGroupFacturation["siret_number"];
|
||||
$facture['mail'] = $clientGroupFacturation["email"];
|
||||
$devisList = $this->getDevisDataByClientGroupFacturationIdAndMonthYear(
|
||||
$facture['fk_client_group_facturation_id'],
|
||||
$facture['month'],
|
||||
$facture['year']
|
||||
);
|
||||
}
|
||||
$factureTotalHt= 0;
|
||||
$factureTotalTva = 0;
|
||||
$factureTotalTtc = 0;
|
||||
foreach($devisList as &$currentDevis){
|
||||
$totalHt = 0;
|
||||
$totalTva = 0;
|
||||
$totalTtc = 0;
|
||||
$devisProducts = $this->getDevisProduits($currentDevis['id']);
|
||||
foreach($devisProducts as $currentProduct){
|
||||
$valueHt = $currentProduct['produit_price'] * $currentProduct['quantite'];
|
||||
$valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue);
|
||||
$totalHt+=$valueHt;
|
||||
$totalTtc+=$valueTtc;
|
||||
$tvaAmount = $valueTtc - $valueHt;
|
||||
$totalTva += $tvaAmount;
|
||||
}
|
||||
$currentDevis["totalHt"] = $totalHt;
|
||||
$currentDevis["totalTtc"] = $totalTtc;
|
||||
$currentDevis["totalTva"] = $totalTva;
|
||||
$factureTotalHt += $totalHt;
|
||||
$factureTotalTtc += $totalTtc;
|
||||
$factureTotalTva += $totalTva;
|
||||
}
|
||||
$facture["devisList"] = $devisList;
|
||||
$facture["totalHt"] = $factureTotalHt;
|
||||
$facture["totalTtc"] = $factureTotalTtc;
|
||||
$facture["totalTva"] = $factureTotalTva;
|
||||
return $facture;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user