2018-10-20 10:12:23 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Helper\Common;
|
|
|
|
|
|
|
|
use AcceptanceTester;
|
|
|
|
|
|
|
|
class RowHelper extends \Codeception\Module
|
|
|
|
{
|
|
|
|
/** @param string */
|
2019-07-11 17:20:58 +02:00
|
|
|
protected $tablePattern = "//div[@class='panel-heading' and contains(string(), 'Righe')]/parent::*//table//tr[contains(string(), '|name|')]";
|
2018-12-24 10:46:59 +01:00
|
|
|
protected $dir;
|
2018-10-20 10:12:23 +02:00
|
|
|
|
2019-07-11 17:20:58 +02:00
|
|
|
/**
|
|
|
|
* Aggiunge un nuovo sconto.
|
|
|
|
*
|
2020-02-11 11:43:59 +01:00
|
|
|
* @param string $value
|
|
|
|
* @param int $type
|
2019-07-11 17:20:58 +02:00
|
|
|
*/
|
|
|
|
public function addDiscount(AcceptanceTester $t, $descrizione, $value, $type)
|
|
|
|
{
|
|
|
|
$t->wait(0.5);
|
|
|
|
|
|
|
|
// Apre il modal
|
|
|
|
$t->clickAndWaitModal('Sconto/maggiorazione', '#tab_0');
|
|
|
|
|
|
|
|
$t->fillField('#descrizione_riga', $descrizione);
|
|
|
|
|
|
|
|
if ($type == 'UNT') {
|
|
|
|
$t->fillField('#sconto_unitario', $value);
|
|
|
|
} else {
|
|
|
|
$t->fillField('#sconto_percentuale', $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Effettua il submit
|
|
|
|
$t->clickAndWait('Aggiungi', '.modal');
|
|
|
|
|
|
|
|
// Controlla il salvataggio finale
|
|
|
|
$t->see('Sconto/maggiorazione aggiunto');
|
|
|
|
}
|
|
|
|
|
2018-11-22 15:34:44 +01:00
|
|
|
/**
|
|
|
|
* Aggiunge una nuova riga.
|
|
|
|
*
|
2020-02-11 11:43:59 +01:00
|
|
|
* @param string $descrizione
|
|
|
|
* @param int $qta
|
|
|
|
* @param float $prezzo
|
|
|
|
* @param int $sconto
|
|
|
|
* @param string $tipo_sconto
|
|
|
|
* @param int $id_iva
|
|
|
|
* @param int $id_rivalsa_inps
|
|
|
|
* @param int $id_ritenuta_acconto
|
2018-11-22 15:34:44 +01:00
|
|
|
*/
|
|
|
|
public function addRow(AcceptanceTester $t, $descrizione, $qta, $prezzo, $sconto = 0, $tipo_sconto = 'UNT', $id_iva = null, $id_rivalsa_inps = null, $id_ritenuta_acconto = null)
|
|
|
|
{
|
2019-07-11 17:20:58 +02:00
|
|
|
$t->wait(0.5);
|
|
|
|
|
2018-11-22 15:34:44 +01:00
|
|
|
// Apre il modal
|
|
|
|
$t->clickAndWaitModal('Riga', '#tab_0');
|
|
|
|
|
|
|
|
$this->fill($t, $descrizione, $qta, $prezzo, $sconto, $tipo_sconto, $id_iva, $id_rivalsa_inps, $id_ritenuta_acconto);
|
2018-10-20 10:12:23 +02:00
|
|
|
|
|
|
|
// Effettua il submit
|
|
|
|
$t->clickAndWait('Aggiungi', '.modal');
|
|
|
|
|
|
|
|
// Controlla il salvataggio finale
|
|
|
|
$t->see('Riga aggiunta');
|
|
|
|
}
|
|
|
|
|
2018-11-22 15:34:44 +01:00
|
|
|
/**
|
|
|
|
* Aggiunge un nuovo articolo.
|
|
|
|
*
|
2020-02-11 11:43:59 +01:00
|
|
|
* @param string $descrizione
|
|
|
|
* @param int $qta
|
|
|
|
* @param float $prezzo
|
|
|
|
* @param int $sconto
|
|
|
|
* @param string $tipo_sconto
|
|
|
|
* @param int $id_iva
|
|
|
|
* @param int $id_rivalsa_inps
|
|
|
|
* @param int $id_ritenuta_acconto
|
2018-11-22 15:34:44 +01:00
|
|
|
*/
|
|
|
|
public function addArticle(AcceptanceTester $t, $id_articolo, $descrizione, $qta, $prezzo, $sconto = 0, $tipo_sconto = 'UNT', $id_iva = null, $id_rivalsa_inps = null, $id_ritenuta_acconto = null)
|
|
|
|
{
|
2019-07-11 17:20:58 +02:00
|
|
|
$t->wait(0.5);
|
|
|
|
|
2018-11-22 15:34:44 +01:00
|
|
|
// Apre il modal
|
|
|
|
$t->clickAndWaitModal('Articolo', '#tab_0');
|
|
|
|
|
|
|
|
$t->select2ajax('#idarticolo', $id_articolo);
|
|
|
|
$this->fill($t, $descrizione, $qta, $prezzo, $sconto, $tipo_sconto, $id_iva, $id_rivalsa_inps, $id_ritenuta_acconto);
|
|
|
|
|
|
|
|
// Effettua il submit
|
|
|
|
$t->clickAndWait('Aggiungi', '.modal');
|
|
|
|
|
|
|
|
// Controlla il salvataggio finale
|
|
|
|
$t->see('Articolo aggiunto');
|
|
|
|
}
|
|
|
|
|
2018-10-20 10:12:23 +02:00
|
|
|
/**
|
2018-10-25 16:57:39 +02:00
|
|
|
* Undocumented function.
|
2018-10-20 10:12:23 +02:00
|
|
|
*/
|
2018-12-24 10:46:59 +01:00
|
|
|
public function testImporti(AcceptanceTester $t, $direzione = 'entrata')
|
2018-10-20 10:12:23 +02:00
|
|
|
{
|
2018-12-24 10:46:59 +01:00
|
|
|
$this->dir = $direzione;
|
|
|
|
|
2018-11-22 15:34:44 +01:00
|
|
|
// Righe di test (issue #98)
|
2018-10-20 10:12:23 +02:00
|
|
|
$this->addRow($t, 'Riga 1', 1, 34);
|
2019-07-11 17:20:58 +02:00
|
|
|
|
2018-10-20 10:12:23 +02:00
|
|
|
$this->addRow($t, 'Riga 2', 1, 17.44);
|
|
|
|
$this->addRow($t, 'Riga 3', 48, 0.52);
|
|
|
|
$this->addRow($t, 'Riga 4', 66, 0.44);
|
|
|
|
$this->addRow($t, 'Riga 5', 1, 104.90);
|
|
|
|
$this->addRow($t, 'Riga 6', 1, 2);
|
|
|
|
|
2018-10-25 16:57:39 +02:00
|
|
|
$t->see('212,34', $this->getFinalValue('Imponibile'));
|
|
|
|
$t->see('46,71', $this->getFinalValue('IVA'));
|
|
|
|
$t->see('259,05', $this->getFinalValue('Totale'));
|
2018-10-20 10:12:23 +02:00
|
|
|
|
2018-11-22 15:34:44 +01:00
|
|
|
// Righe di controllo sugli sconti
|
2018-10-20 10:12:23 +02:00
|
|
|
$this->addRow($t, 'Riga 7 con sconto in euro', 15, 12, 2);
|
|
|
|
$this->addRow($t, 'Riga 8 con sconto percentuale', 15, 10, 20, 'PRC');
|
|
|
|
|
2018-10-25 16:57:39 +02:00
|
|
|
$t->see('542,34', $this->getFinalValue('Imponibile'));
|
|
|
|
$t->see('60,00', $this->getFinalValue('Sconto'));
|
2019-07-11 17:44:42 +02:00
|
|
|
$t->see('482,34', $this->getFinalValue('Totale imponibile'));
|
2018-10-25 16:57:39 +02:00
|
|
|
$t->see('106,11', $this->getFinalValue('IVA'));
|
|
|
|
$t->see('588,45', $this->getFinalValue('Totale'));
|
2018-11-22 15:34:44 +01:00
|
|
|
|
|
|
|
// Sconto globale in euro
|
2019-07-11 17:20:58 +02:00
|
|
|
$this->addDiscount($t, 'Sconto unitario', 100, 'UNT');
|
2018-11-22 15:34:44 +01:00
|
|
|
|
2019-07-11 17:20:58 +02:00
|
|
|
$t->see('542,34', $this->getFinalValue('Imponibile'));
|
|
|
|
$t->see('160,00', $this->getFinalValue('Sconto'));
|
2019-07-11 17:44:42 +02:00
|
|
|
$t->see('382,34', $this->getFinalValue('Totale imponibile'));
|
2018-11-22 15:34:44 +01:00
|
|
|
$t->see('84,11', $this->getFinalValue('IVA'));
|
|
|
|
$t->see('466,45', $this->getFinalValue('Totale'));
|
|
|
|
|
|
|
|
// Sconto globale in percentuale
|
2019-07-11 17:20:58 +02:00
|
|
|
$this->addDiscount($t, null, 10, 'PRC');
|
2018-11-22 15:34:44 +01:00
|
|
|
|
2019-07-11 17:20:58 +02:00
|
|
|
$this->delete($t, 'Sconto unitario');
|
|
|
|
|
|
|
|
$t->see('542,34', $this->getFinalValue('Imponibile'));
|
|
|
|
$t->see('98,23', $this->getFinalValue('Sconto'));
|
2019-07-11 17:44:42 +02:00
|
|
|
$t->see('444,11', $this->getFinalValue('Totale imponibile'));
|
2019-07-11 17:20:58 +02:00
|
|
|
$t->see('97,70', $this->getFinalValue('IVA'));
|
|
|
|
$t->see('541,81', $this->getFinalValue('Totale'));
|
2018-10-20 10:12:23 +02:00
|
|
|
}
|
2018-12-29 12:03:22 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Completa le informazioni per la creazione di un nuovo elemento.
|
|
|
|
*
|
2020-02-11 11:43:59 +01:00
|
|
|
* @param [type] $descrizione
|
|
|
|
* @param [type] $qta
|
|
|
|
* @param [type] $prezzo
|
|
|
|
* @param int $sconto
|
|
|
|
* @param string $tipo_sconto
|
|
|
|
* @param [type] $id_iva
|
|
|
|
* @param [type] $id_rivalsa_inps
|
|
|
|
* @param [type] $id_ritenuta_acconto
|
2018-12-29 12:03:22 +01:00
|
|
|
*/
|
|
|
|
protected function fill(AcceptanceTester $t, $descrizione, $qta, $prezzo, $sconto = 0, $tipo_sconto = 'UNT', $id_iva = null, $id_rivalsa_inps = null, $id_ritenuta_acconto = null)
|
|
|
|
{
|
|
|
|
$t->fillField('#descrizione_riga', $descrizione);
|
2019-02-22 13:10:58 +01:00
|
|
|
$t->fillField('#qta', $qta);
|
2018-12-29 12:03:22 +01:00
|
|
|
|
2019-03-08 15:18:52 +01:00
|
|
|
$t->fillField('#prezzo', $prezzo);
|
2018-12-29 12:03:22 +01:00
|
|
|
|
|
|
|
if (!empty($sconto)) {
|
2019-02-22 13:10:58 +01:00
|
|
|
$t->fillField('#sconto', $sconto);
|
2018-12-29 12:03:22 +01:00
|
|
|
|
|
|
|
if (in_array($tipo_sconto, ['PRC', 'UNT'])) {
|
2019-07-11 17:20:58 +02:00
|
|
|
$t->select2ajax('#tipo_sconto', $tipo_sconto == 'PRC' ? 0 : 1);
|
2018-12-29 12:03:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($id_iva) {
|
|
|
|
$t->select2('#idiva', $id_iva);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($id_rivalsa_inps) {
|
|
|
|
$t->select2('#id_rivalsa_inps', $id_rivalsa_inps);
|
|
|
|
}
|
|
|
|
if ($id_ritenuta_acconto) {
|
|
|
|
$t->select2('#id_ritenuta_acconto', $id_ritenuta_acconto);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-11 17:20:58 +02:00
|
|
|
protected function delete(AcceptanceTester $t, $descrizione)
|
|
|
|
{
|
|
|
|
$path = $this->getPattern($descrizione).'//td[last()]';
|
|
|
|
|
|
|
|
$t->wait(0.5);
|
|
|
|
$t->click('.btn-danger', $path);
|
|
|
|
$t->acceptPopup();
|
|
|
|
|
|
|
|
$t->waitForElementNotVisible('#main_loading');
|
|
|
|
$t->waitForElementNotVisible('#mini-loader');
|
|
|
|
|
|
|
|
$t->see('Riga eliminata!');
|
|
|
|
|
|
|
|
//$t->click('#save', '#tab_0');
|
|
|
|
}
|
|
|
|
|
2018-12-29 12:03:22 +01:00
|
|
|
/**
|
|
|
|
* Undocumented function.
|
|
|
|
*
|
|
|
|
* @param string $pattern
|
|
|
|
*/
|
2019-07-11 17:20:58 +02:00
|
|
|
protected function setPattern($pattern)
|
2018-12-29 12:03:22 +01:00
|
|
|
{
|
2019-07-11 17:20:58 +02:00
|
|
|
$this->tablePattern = $pattern;
|
2018-12-29 12:03:22 +01:00
|
|
|
}
|
|
|
|
|
2019-07-11 17:20:58 +02:00
|
|
|
protected function getPattern($name)
|
2018-12-29 12:03:22 +01:00
|
|
|
{
|
2019-07-11 17:20:58 +02:00
|
|
|
return str_replace('|name|', $name, $this->tablePattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getFinalValue($name)
|
|
|
|
{
|
|
|
|
$name = strtoupper($name);
|
|
|
|
|
|
|
|
return $this->getPattern($name).'//td[2]';
|
2018-12-29 12:03:22 +01:00
|
|
|
}
|
2018-10-20 10:12:23 +02:00
|
|
|
}
|