Skip to content

Commit

Permalink
Merge pull request vindi#105 from cedran/master
Browse files Browse the repository at this point in the history
PLANOS - Ajuste dos tópicos 1, 2, 3 e 4
  • Loading branch information
cedran authored Aug 14, 2024
2 parents da82ebb + 5a548dc commit e13708c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
10 changes: 8 additions & 2 deletions Controller/Adminhtml/VindiPlan/ImportPlans.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
use Vindi\Payment\Model\VindiPlanFactory;
use Vindi\Payment\Model\VindiPlanRepository;
use Vindi\Payment\Model\Vindi\Plan;
use Vindi\Payment\Helper\Data;

/**
* Class ImportPlans
* @package Vindi\Payment\Controller\Adminhtml\VindiPlan
*/
class ImportPlans extends Action
{
Expand Down Expand Up @@ -95,6 +95,12 @@ public function execute()

$vindiplan = $this->vindiplanFactory->create();

$code = $planData['code'] ?? null;
if (empty($code)) {
$name = preg_replace('/[^\p{L}\p{N}\s]/u', '', $planData['name']);
$code = Data::sanitizeItemSku($name);
}

$vindiplan->setData([
'vindi_id' => $planData['id'],
'name' => $planData['name'],
Expand All @@ -104,7 +110,7 @@ public function execute()
'billing_trigger_type' => $planData['billing_trigger_type'],
'billing_trigger_day' => $planData['billing_trigger_day'],
'billing_cycles' => empty($planData['billing_cycles']) ? null : $planData['billing_cycles'],
'code' => $planData['code'],
'code' => $code,
'description' => $planData['description'],
'installments' => $planData['installments'],
'invoice_split' => $planData['invoice_split'],
Expand Down
7 changes: 5 additions & 2 deletions Controller/Adminhtml/VindiPlan/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private function prepareData($post, $name, $code)
}
}

if (isset($post["settings"]["billing_cycles"]) && $post["settings"]["billing_cycles"] !== '') {
if (!empty($post["settings"]["billing_cycles"])) {
$data['billing_cycles'] = $post["settings"]["billing_cycles"];
}

Expand Down Expand Up @@ -266,7 +266,10 @@ private function prepareDataForMagentoStore($data, $post)
$data['installments'] = empty($post["settings"]["installments"]) ? null : $post["settings"]["installments"];
}

if (!empty($post["settings"]["duration"])) {
// Set 'duration' to 'undefined' if 'billing_cycles' is empty
if (isset($post["settings"]["billing_cycles"]) && $post["settings"]["billing_cycles"] === '') {
$data['duration'] = 'undefined';
} elseif (!empty($post["settings"]["duration"])) {
$data['duration'] = $post["settings"]["duration"];
}

Expand Down
2 changes: 1 addition & 1 deletion Model/Config/Source/BillingTriggerDaysOfTheMonth.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getAllOptions()
private function getRangeOptions()
{
$range = [];
for ($number = 1; $number <= 30; $number++) {
for ($number = 1; $number <= 31; $number++) {
$range[] = [
'label' => __('Day %1', $number),
'value' => $number
Expand Down
8 changes: 4 additions & 4 deletions Model/Config/Source/Duration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function getAllOptions()
{
if ($this->_options === null) {
$this->_options = [
['label' => __('defined'), 'value' => 'Por tempo definido'],
['label' => __('undefined'), 'value' => 'Por tempo indefinido']
['label' => __('defined'), 'value' => __('Temporary')],
['label' => __('undefined'), 'value' => __('Indefinitely')]
];
}

Expand All @@ -34,8 +34,8 @@ public function getAllOptions()
public function toOptionArray()
{
return [
['value' => 'defined', 'label' => __('Por tempo definido')],
['value' => 'undefined', 'label' => __('Por tempo indefinido')]
['value' => 'defined', 'label' => __('Temporary')],
['value' => 'undefined', 'label' => __('Indefinitely')]
];
}
}
4 changes: 2 additions & 2 deletions Model/Config/Source/Interval.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function getAllOptions()
public function toOptionArray()
{
return [
['value' => 'days', 'label' => __('Day')],
['value' => 'months', 'label' => __('Month')]
['value' => 'days', 'label' => __('Days')],
['value' => 'months', 'label' => __('Months')]
];
}
}
2 changes: 2 additions & 0 deletions i18n/pt_BR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -492,3 +492,5 @@
"Your cart already contains a subscription product. Only one subscription product is allowed per transaction.","Seu carrinho já contém um produto de assinatura. Apenas um produto de assinatura"
"Your cart already contains a subscription product. You can only add one subscription product per transaction. Please complete your current purchase or remove the existing subscription product to add a different one.","Seu carrinho já contém um produto de assinatura. Você só pode adicionar um produto de assinatura por transação. Conclua sua compra atual ou remova o produto de assinatura existente para adicionar outro."
"Subscription products have been removed from your cart after login.","Produtos de assinatura foram removidos do seu carrinho após o login."
"Indefinitely","Por tempo indefinido"
"Temporary","Temporário"
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
</argument>
<settings>
<validation>
<rule name="required-entry" xsi:type="boolean">true</rule>
<rule name="validate-number" xsi:type="boolean">true</rule>
</validation>
<dataType>text</dataType>
Expand Down

0 comments on commit e13708c

Please sign in to comment.