Finish version/v.0.0.42

This commit is contained in:
Roland Schneider 2016-02-26 21:21:02 +01:00
commit 3a70206b38
19 changed files with 423 additions and 123 deletions

View File

@ -13,6 +13,7 @@ use common\models\Product;
use common\models\User;
use common\components\Helper;
use common\models\Account;
use yii\helpers\Url;
/**
* ProcurementController implements the CRUD actions for Procurement model.
@ -193,7 +194,15 @@ class ProcurementController extends \backend\controllers\BackendController
}
return $this->redirect(['view', 'id' => $model->id_procurement]);
// return $this->redirect(['view', 'id' => $model->id_procurement]);
$url = Url::previous("product_index");
if ( isset($url)){
return $this->redirect( $url );
}else{
return $this->redirect(['product/index']);
}
// return $this->redirect(Yii::$app->request->referrer);
} else {
return $this->render('create_product', [
'model' => $model,

View File

@ -12,6 +12,7 @@ use common\models\Account;
use common\models\ProductCategory;
use backend\models\ProductStatisticsSearch;
use PHPExcel;
use yii\helpers\Url;
/**
* ProductController implements the CRUD actions for Product model.
@ -47,6 +48,8 @@ class ProductController extends \backend\controllers\BackendController
$searchModel = new ProductSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Url::remember(Url::current(),"product_index");
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,

View File

@ -16,6 +16,10 @@ use common\models\Customer;
use common\models\Card;
use backend\models\TicketSearchStatisitcs;
use backend\models\TicketSearchCustomer;
use common\components\TicketSale;
use common\models\Contract;
use common\components\giro\GiroDETSTATetel;
use common\components\DetStatTetelProcessor;
/**
* TicketController implements the CRUD actions for Ticket model.
@ -34,7 +38,8 @@ class TicketController extends \backend\controllers\BackendController {
'view',
'update',
'index-customer',
'statistics'
'statistics' ,
'test'
],
'allow' => true,
'roles' => [
@ -223,6 +228,58 @@ class TicketController extends \backend\controllers\BackendController {
] );
}
public function actionTest(){
// $this->doTestTicketSale();
$this->doTestDetstaProcess();
return $this->render('test');
}
protected function doTestDetstaProcess(){
$contract = Contract::findOne(19);
$megbizas = $contract->requests[0];
$tetel = new GiroDETSTATetel();
$tetel->visszajelzesInformacio = "02";
$tp = new DetStatTetelProcessor([
'megbizas' => $megbizas,
'tetel' => $tetel
]);
$tp->run();
}
protected function doTestTicketSale(){
$ticketType = TicketType::findOne(1);
$customer = Customer::findOne(1);
$account = Account::findOne(1);
$card = $customer->card;
$discount = null;
$contract = Contract::findOne(19);
$megbizas = $contract->requests[0];
$ticketSale = new TicketSale(
[
'ticketType'=> $ticketType,
'customer'=> $customer,
'account'=> $account,
'card'=> $card,
'discount'=> $discount,
'contract'=> $contract,
'ticketInstallmentRequest' => $megbizas
]
);
$ticketSale->doSale();
}
/**
* Finds the Ticket model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.

View File

@ -39,16 +39,17 @@ class DestaUploadForm extends Model
$datum = $destaUzenet->fej->csoportosUzenetSorszam->osszeallitasDatuma;
$koteg = Ugiro::find()->andWhere(['number' =>$number,'datum' => $datum ])->one();
$this->koteg = $koteg;
$idKoteg = $this->koteg->id_ugiro;
if (!isset($koteg)){
$this->addError($attribute,"Nincs ilyen köteg! ( Datum: $datum, Sorszam: $number )");
}else{
if ( $koteg->status != Ugiro::$STATUS_SENT ){
$idKoteg = $this->koteg->id_ugiro;
$this->addError($attribute,"A köteg detsta fájl-ja már fel van töltve !( Köteg azonosító: $idKoteg )");
}
}
}
}

View File

@ -17,21 +17,41 @@ $warehouseOptions = ArrayHelper::map($warehouses, 'id_warehouse', 'name') ;
?>
<h3><?= Yii::t('common/product', 'Product') ?> </h3>
<div class="row">
<div class="col-md-6">
<?php
echo DetailView::widget([
'model' => $product,
'attributes' =>[
'productCategoryName',
'accountName',
'product_number',
'barcode',
'stock',
[
'attribute' => 'productCategoryName',
'label' => 'Termék kategória'
],
[
'attribute' => 'accountName',
'label' => 'Kassza'
],
[
'attribute' => 'product_number',
'label' => 'Termék szám'
],
[
'attribute' => 'barcode',
'label' => 'Vonalkód'
],
[
'attribute' => 'stock',
'label' => 'Raktáron'
],
]
]);
?>
</div>
</div>
<div class="row">
<div class="col-md-4" >
<div class="procurement-form">
<?php $form = ActiveForm::begin(); ?>
@ -52,3 +72,4 @@ echo DetailView::widget([
<?php ActiveForm::end(); ?>
</div>
</div></div>

View File

@ -0,0 +1 @@
test

View File

@ -1,3 +1,6 @@
-0.0.42
- add detsta import improvements
- add procurement/create-product , translations, redirects
-0.0.41
- add button kulcs "visszaad"
- fix ReceptionFomr#getFirstKey method

View File

@ -65,7 +65,7 @@ class DetStatProcessor extends Object{
]
);
$processor->run();
$this->errors = $this->errors + $processor->errors;
// $this->errors = $this->errors + $processor->errors;
}
}
@ -129,21 +129,21 @@ class DetStatProcessor extends Object{
$this->megbizasok = $this->koteg->requests;
}
public function applyNewMegbizasState(){
$kod = $this->tetel->valaszHivatkozasiKod;
// public function applyNewMegbizasState(){
// $kod = $this->tetel->valaszHivatkozasiKod;
if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){
$this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
}else{
$this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED;
}
$this->megbizas->save(false);
}
// if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){
// $this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
// }else{
// $this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED;
// }
// $this->megbizas->save(false);
// }
public function applyNewTicketState(){
$this->ticket->applyTicketInstallmentRequest($this->megbizas);
$this->ticket->save(false);
}
// public function applyNewTicketState(){
// $this->ticket->applyTicketInstallmentRequest($this->megbizas);
// $this->ticket->save(false);
// }
public function hasError(){

View File

@ -5,10 +5,8 @@ namespace common\components;
use yii\base\Object;
use common\models\TicketInstallmentRequest;
use common\components\giro\GiroDETSTATetel;
use backend\models\TicketInstallmentMarkForSendForm;
use common\models\Transfer;
use common\models\Account;
use common\models\Discount;
use common\models\Contract;
/**
* This is the model class for table "ticket".
@ -16,114 +14,265 @@ use common\models\Discount;
* @property common\components\giro\GiroDETSTATetel $tetel
* @property common\models\TicketInstallmentRequest $megbizas
* @property common\models\Ticket $ticket
* @property common\models\Contract $contract
*
*
*/
class DetStatTetelProcessor extends Object {
/**
* A válasz tétel . Ha nincs megadva, automatikus visszautasítjuk a megbízást
* */
public $tetel; // config
/**
* A megbízás. Ha a megbízás már el van fogadva, megszakítjuk a feldolgozást
* */
public $megbizas; // config
public $ticket;
public $errors = [ ];
public $dryRun = false; // for testing, to not to persist the changes
/**
* A szerződés. A megbízás hoz tartozó szerződés
* */
public $contract;
/**
* a tételből kiolvasott kód. Lásd extractKodAndStatus
* */
protected $kod;
/**
* Státusz. Az új státusza a megbízásnak a tétel alapján
* */
protected $status;
/**
* A komment. Lásd fillComment metódus
* */
protected $comment;
/**
* A bérlet objectkum, amit elmentettünk
* */
protected $ticket;
/**
* A tranzakció, amit mentettünk
* */
protected $transfer;
protected $eredetiMegbizasStatus;
public function run() {
// $this->readMegbizas();
if ($this->megbizas->isStatusAccepted()) {
\Yii::info('Megbízás feldolgozása: megbízás azonosító=' .$this->megbizas->id_ticket_installment_request);
if ($this->isAlreadeyAccepted ()) {
// \Yii::info('A megbízás feldolgozásának megszakítása. A megbízás már elfogadott: megbízás azonosító=' .$this->megbizas->id_ticket_installment_request);
// return;
}
$status = TicketInstallmentRequest::$STATUS_REJECTED;
$kod = 'xx';
$comment = "";
if (isset ( $this->tetel )) {
$kod = $this->tetel->visszajelzesInformacio;
$this->rememberEredetiMegbizasStatus();
$this->readContract();
$this->extractKodAndStatus ();
$this->fillComment();
if ( $this->status == TicketInstallmentRequest::$STATUS_ACCEPTED ){
$this->buyNewTicket();
}else{
$this->doRejectRequest();
}
if ($kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT) {
$status = TicketInstallmentRequest::$STATUS_ACCEPTED;
} else {
$status = TicketInstallmentRequest::$STATUS_REJECTED;
if ( $kod == "xx"){
$comment = "Nem található a detsta fájlban a tétel válasza";
}else{
if ( array_key_exists($kod, GiroDETSTATetel::$INFORMACIOK)){
$comment = "Hiba kód: ".$kod ." - " .GiroDETSTATetel::$INFORMACIOK[$kod];
}else{
$comment = "Ismeretlen hiba kód: " .$kod;
}
protected function rememberEredetiMegbizasStatus(){
$this->eredetiMegbizasStatus = $this->megbizas->status;
}
protected function isEredetiMegbizasStatusFinished(){
return $this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_ACCEPTED ||
$this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL ||
$this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_REJECTED;
}
protected function buyNewTicket(){
\Yii::info('Új bérlet vásárlás folyamant indítása' );
$megbizas = $this->megbizas;
$customer = $this->contract->customer;
$card = $customer->card;
$account = Account::findOne(1);
$ticketType = $this->contract->ticketType;
$discount = $this->contract->discount;
$ticketSale = new TicketSale(
[
'ticketType'=> $ticketType,
'customer'=> $customer,
'account'=> $account,
'card'=> $card,
'discount'=> $discount,
'contract'=> $this->contract,
'ticketInstallmentRequest' => $megbizas
]
);
$ticketSale->doSale();
\Yii::info('Bérlet és tranzakció elmentve' );
$this->transfer = $ticketSale->transfer;
$this->ticket = $ticketSale->ticket;
$this->updateContractOnSuccess();
$this->updateMegbizasOnSuccess();
}
/**
* A szerződés betöltése
* */
protected function readContract(){
$this->contract = $this->megbizas->contract;
\Yii::info('Szerződés betöltve. Id:' .$this->contract->id_contract);
}
/**
* A megbízás módosítása sikeres detsta üzenet esetén
* */
protected function updateMegbizasOnSuccess(){
\Yii::info('Megbízás frissítése - megbizás elfogadva ' );
$this->megbizas->status = $this->status;
$this->megbizas->id_transfer = $this->transfer->id_transfer;
$this->megbizas->id_ticket = $this->ticket->id_ticket;
$this->megbizas->request_processed_at = Helper::getDateTimeString();
$this->megbizas->detsta_answer = $this->kod;
$this->megbizas->comment = $this->comment;
if ( !$this->megbizas->save(false) ){
\Yii::error("Nem sikerült menteni a megbízást!");
throw new \Exception("Nem sikerült menteni a megbízást!");
}
\Yii::info("A megbízás elmentve!");
}
/**
* Megbízás módosítása , ha a detsta üzenetben a megbízás vissza lett utasítva
* */
protected function updateMegbizasOnFail(){
\Yii::info('Megbázás frissítése - megbízás visszautasítva ' );
$this->megbizas->status = $this->status;
$this->megbizas->detsta_answer = $this->kod;
$this->megbizas->comment = $this->comment;
$this->megbizas->request_processed_at = Helper::getDateTimeString();
if ( !$this->megbizas->save(false) ){
\Yii::error("Nem sikerült menteni a megbízást!");
throw new \Exception("Nem sikerült menteni a megbízást!");
}
\Yii::info("A megbízás elmentve!");
}
/**
* Szerződés módosítása, ha a detsta üzenetben a megbízás el lett fogadva
* */
protected function updateContractOnSuccess(){
\Yii::info('Szerződés frissítése - megbizás elfogadva ' );
$this->incRequiredParts();
$this->contract->part_paid = $this->contract->part_paid +1;
$this->updateContractPaidStatus();
if ( !$this->contract->save(false) ){
\Yii::error("Nem sikerült menteni a szerződést!");
throw new \Exception("Nem sikerült menteni a szerződést!");
}
\Yii::info("A szerződés elmentve!");
}
protected function updateContractOnFail(){
\Yii::info('Szerződés frissítése - megbizás visszautasítva ' );
$this->incRequiredParts();
$this->updateContractPaidStatus();
// $this->contract->status = Contract::$STATUS_NOT_PAID;
if ( !$this->contract->save(false) ){
\Yii::error("Nem sikerült menteni a szerződést!");
throw new \Exception("Nem sikerült menteni a szerződést!");
}
\Yii::info("A szerződés elmentve!");
}
/**
* Szerződés
* */
protected function incRequiredParts(){
if ( !$this->isEredetiMegbizasStatusFinished() ){
$this->contract->part_required = $this->contract->part_required +1;
\Yii::info("Szerződés szükséges megbizások száma növelve");
}else{
\Yii::info("Szerződés szükséges megbizások száma nem lett növelve az eredeti státusz miatt");
}
}
protected function updateContractPaidStatus(){
$required = $this->contract->part_required;
$paid = $this->contract->part_paid;
$ok = $required <= $paid;
if ($ok ){
$this->contract->status = Contract::$STATUS_PAID;
}else{
$this->contract->status = Contract::$STATUS_NOT_PAID;
}
\Yii::info("Szerződés új státusza id= " .$this->contract->id_contract . ", Státusz: " . $this->contract->status . " (" . Contract::toStatusName($this->contract->status) . ")");
}
/**
* Szerződés és megbízás frissítése , ha a detsta üzenet visszautásításra került
* */
protected function doRejectRequest(){
$this->updateContractOnFail();
$this->updateMegbizasOnFail();
}
/**
* Komment összeállítás a status mező alapján
* */
protected function fillComment() {
$this->comment = "Megbízás teljesítve";
if ($this->status != TicketInstallmentRequest::$STATUS_ACCEPTED) {
if ($this->kod == "xx") {
$this->comment = "Nem található a detsta fájlban a tétel válasza";
} else {
if (array_key_exists ( $this->kod, GiroDETSTATetel::$INFORMACIOK )) {
$this->comment = "Hiba kód: " . $this->kod . " - " . GiroDETSTATetel::$INFORMACIOK [$this->kod];
} else {
$this->comment = "Ismeretlen hiba kód: " . $this->kod;
}
}
}
$this->megbizas->applyStatus($status,true,$kod,$comment);
// $this->readTicket();
// if ( !$this->hasError() ){
// $this->applyNewMegbizasState();
// $this->applyNewTicketState();
// $this->addTransfer();
// }
}
// public function readMegbizas(){
// $this->megbizas = TicketInstallmentRequest::findOne($this->tetel->ugyfelAzonosito);
// if ( !isset($this->megbizas) ){
// $this->errors [] = "Válaszban jelölt megbízás nem található! (".$this->tetel->ugyfelAzonosito." )";
// }
// }
// public function readTicket(){
// $this->ticket = $this->megbizas->ticket;
// if ( !isset($this->ticket) ){
// $this->errors [] = "Válaszban jelölt bérlet nem található! (".$this->megbizas->id_ticket." )";
// }
// }
// public function applyNewMegbizasState(){
// $kod = 'xx';
// if ( isset($this->tetel ) ) {
// $kod = $this->tetel->visszajelzesInformacio;
// }
// if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){
// $this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
// }else{
// $this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED;
// }
// if ( !$this->isDryRun() ){
// $this->megbizas->save(false);
// }
// }
// public function applyNewTicketState(){
// $this->ticket->applyTicketInstallmentRequest($this->megbizas);
// if ( !$this->isDryRun() ){
// $this->ticket->save(false);
// }
// }
// protected function addTransfer(){
// $account = Account::findOne($this->ticket->id_account);
// $discount = null;
// if ( isset($this->ticket->id_account)){
// $discount = Discount::findOne( $this->ticket->id_discount );
// }
// $transfer = Transfer::createTicketTransfer($account, $discount, null, 1, $this->ticket);
// $transfer->status = Transfer::STATUS_PAID;
// $transfer->paid_at = date('Y-m-d H:i:s' ) ;
// $transfer->paid_by = \Yii::$app->user->id;
// $transfer->payment_method = Transfer::PAYMENT_METHOD_TRANSFER;
// $transfer->money = $this->megbizas->money;
// $transfer->comment = "Csoportos beszedes";
// $transfer->id_user = \Yii::$app->user->id;
// $transfer->id_customer = $this->ticket->id_customer;
// $transfer->save(false);
// }
/**
* Visszajelző kód kiolvasása a detsta tételből.
* Status beállítása a kód alapján
* */
protected function extractKodAndStatus() {
\Yii::info('Visszajelző kód kiolvasása' );
$this->status = TicketInstallmentRequest::$STATUS_REJECTED;
$this->kod = 'xx';
if (isset ( $this->tetel )) {
$this->kod = $this->tetel->visszajelzesInformacio;
}
if ($this->kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT) {
$this->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
} else {
$this->status = TicketInstallmentRequest::$STATUS_REJECTED;
}
\Yii::info('Visszajelző kód kiolvasva: kod=' .$this->kod);
\Yii::info('Visszajelző kód kiolvasva: statusz=' .$this->status. " (" . TicketInstallmentRequest::toStatusName($this->status) .")");
}
protected function isAlreadeyAccepted() {
return $this->megbizas->isStatusAccepted ();
}
public function hasError() {
return count ( $this->errors ) > 0;
}
public function isDryRun() {
return $this->dryRun;
return false;
}
}

View File

@ -92,6 +92,10 @@ class Helper {
return date("Y-m-d H:i:s");
}
public static function getDateString( ){
return date("Y-m-d");
}
public static function getArrayValue($arr,$key,$def){
$result = $def;

File diff suppressed because one or more lines are too long

View File

@ -30,7 +30,7 @@ class GiroBeszedFej extends GiroBase{
return $this->recordTipus
.$this->uzenetTipus
. $this->duplumKod
. $this->szamKitolt( $this->kezdemenyezoAzonosito , 13)
. $this->szovegKitolt( $this->kezdemenyezoAzonosito , 13)
. $this->uzenetSorszam->toString()
. $this->kezdemenyezoBankszamla->toString()
. $this->szamKitolt($this->ertesitesiHatarido,8)

View File

@ -4,7 +4,7 @@ return [
'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.41',
'version' => 'v0.0.42',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global
@ -18,7 +18,7 @@ return [
'account_state_close_preload_money' => 'true',//preload money wnen show account state close page
'ugiro_duplom_kod' => 1,
'ugiro_kezdemenyezo_szamlaszam' => '000000000000000',//5860025215371128
'ugiro_kezdemenyezo_azonosito' => 'A25366936T244',
'ugiro_kezdemenyezo_azonosito' => 'A25006285',//
//a recepicó kosár csak az aktuális user által kiadott termékeket tartalmazza
//vagy mindent
//értékek user|all

View File

@ -122,6 +122,11 @@ class Contract extends \yii\db\ActiveRecord
public function getRequests(){
return $this->hasMany(TicketInstallmentRequest::className(), ['id_contract' => 'id_contract']);
}
public function getDiscount(){
return $this->hasOne(Discount::className(), ['id_discount' => 'id_discount']);
}
// public static $STATUS_PAID = 10;
// public static $STATUS_NOT_PAID = 20;

View File

@ -243,7 +243,7 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
$count = $type->installment_count;
$discount = $ticket->discount;
$money = $type->installment_money;
if ( isset($discount ) ){
if ( isset( $discount ) ){
$money = Discount::applyDiscount($money, $discount);
}
$ticketCreatedAt = time();

View File

@ -23,8 +23,17 @@ class Ugiro extends \yii\db\ActiveRecord
public static $PATH_MEGBIZAS = "giro/megbizas";
public static $PATH_VALASZ = "giro/valasz";
/**
* beszed fájl kész
* */
public static $STATUS_SENT = 0;
/**
* detsta fájl felöltve
* */
public static $STATUS_RECIEVED = 10;
/**
* detsta fájl feldolgozva
* */
public static $STATUS_FINISHED = 20;
/**

View File

@ -0,0 +1,30 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160131_102226_alter__table__contract__add__column__id_discount extends Migration
{
public function up()
{
$this->addColumn("contract", "id_discount", "int");
}
public function down()
{
echo "m160131_102226_alter__table__contract__add__column__id_discount cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -157,7 +157,7 @@ class ContractForm extends Model {
'phone' => 'Telefonszám',
'email' => 'E-mail',
'ticket_type' => 'Bérlet típus' ,
'payment_method' => 'Fizetési mód' ,
'payment_method' => 'Fizetési mód (első bérlet)' ,
'id_discount' => 'Kedvezmény' ,
];
}

View File

@ -176,6 +176,7 @@ class TicketCreate extends Ticket{
$contract->part_required = 0;
$contract->expired_at = date('Y-m-d', strtotime("today +12 month -1 day"));
$contract->id_ticket_type = $this->id_ticket_type;
$contract->id_discount = $this->id_discount;
$contract->save();
$requests = TicketInstallmentRequest::createInstallments($this, $ticketType, $this->customer,$contract);