Skip to content

Commit

Permalink
Merge pull request #90 from danielebuso/fix_arrotondamento_tipocessio…
Browse files Browse the repository at this point in the history
…neprestazione

Aggiunto Arrotondamento e TipoCessionePrestazione
  • Loading branch information
salgua authored Aug 26, 2021
2 parents 6d3dcb6 + 14fa4e4 commit 93fc621
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.18] - 2021-08-26
### Added
- Aggiunto Arrotondamento e TipoCessionePrestazione #90 by danielebuso

## [1.1.17] - 2021-08-25
### Added
- Aggiunta impostazione decimali per linea #89 by danielebuso
Expand Down
31 changes: 31 additions & 0 deletions src/Codifiche/TipoCessionePrestazione.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* This file is part of deved/fattura-elettronica
*
* Copyright (c) Salvatore Guarino <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/

namespace Deved\FatturaElettronica\Codifiche;

use Deved\FatturaElettronica\Traits\CodificaTrait;

abstract class TipoCessionePrestazione
{
use CodificaTrait;

const Abbuono = 'AB';
const SpesaAccessoria = 'AC';
const Premio = 'PR';
const Sconto = 'SC';

protected static $codifiche = array(
'AB' => 'Abbuono',
'AC' => 'Spesa accessoria',
'PR' => 'Premio',
'SC' => 'Sconto'
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class DatiRiepilogo implements XmlSerializableInterface, \Countable, \Iterator
protected $datiRiepilogoAggiuntivi = [];
/** @var int */
protected $currentIndex = 0;
/** @var float */
protected $arrotondamento;
/** @var float */
protected $decimaliArrotondamento;

/**
* DatiRiepilogo constructor.
Expand All @@ -37,7 +41,7 @@ class DatiRiepilogo implements XmlSerializableInterface, \Countable, \Iterator
* @param string $esigibilitaIVA
* @param bool $imposta
*/
public function __construct($imponibileImporto, $aliquotaIVA, $esigibilitaIVA = "I", $imposta = false)
public function __construct($imponibileImporto, $aliquotaIVA, $esigibilitaIVA = "I", $imposta = false, $arrotondamento = null, $decimaliArrotondamento = 2)
{
if ($imposta === false) {
$this->imposta = ($imponibileImporto / 100) * $aliquotaIVA;
Expand All @@ -48,6 +52,8 @@ public function __construct($imponibileImporto, $aliquotaIVA, $esigibilitaIVA =
$this->aliquotaIVA = $aliquotaIVA;
$this->esigibilitaIVA = $esigibilitaIVA;
$this->datiRiepilogoAggiuntivi[] = $this;
$this->arrotondamento = $arrotondamento;
$this->decimaliArrotondamento = $decimaliArrotondamento;
}

/**
Expand All @@ -62,6 +68,9 @@ public function toXmlBlock(\XMLWriter $writer)
$writer->startElement('DatiRiepilogo');
$writer->writeElement('AliquotaIVA', fe_number_format($block->aliquotaIVA, 2));
$block->writeXmlField('Natura', $writer);
if ($block->arrotondamento) {
$writer->writeElement('Arrotondamento', fe_number_format($block->arrotondamento, $block->decimaliArrotondamento));
}
$writer->writeElement('ImponibileImporto', fe_number_format($block->imponibileImporto, 2));
$writer->writeElement('Imposta', fe_number_format($block->imposta, 2));
if (!$natura) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class Linea implements XmlSerializableInterface
protected $scontoMaggiorazione = [];
/** @var int */
protected $decimaliLinea;
/** @var string */
protected $tipoCessionePrestazione;


/**
Expand All @@ -58,7 +60,8 @@ public function __construct(
$unitaMisura = 'pz',
$aliquotaIva = 22.00,
$codiceTipo = 'FORN',
$decimaliLinea = 2
$decimaliLinea = 2,
$tipoCessionePrestazione = null
) {
$this->codiceArticolo = $codiceArticolo;
$this->descrizione = $descrizione;
Expand All @@ -68,6 +71,7 @@ public function __construct(
$this->aliquotaIva = $aliquotaIva;
$this->codiceTipo = $codiceTipo;
$this->decimaliLinea = $decimaliLinea;
$this->tipoCessionePrestazione = $tipoCessionePrestazione;
}


Expand All @@ -79,6 +83,9 @@ public function toXmlBlock(\XMLWriter $writer)
{
$writer->startElement('DettaglioLinee');
$writer->writeElement('NumeroLinea', $this->numeroLinea);
if ($this->tipoCessionePrestazione) {
$writer->writeElement('TipoCessionePrestazione', $this->tipoCessionePrestazione);
}
if ($this->codiceArticolo) {
$writer->startElement('CodiceArticolo');
$writer->writeElement('CodiceTipo', $this->codiceTipo);
Expand Down

0 comments on commit 93fc621

Please sign in to comment.