Skip to content

Commit

Permalink
CET-579/chore: Addressing PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SalmanTwo committed Jan 28, 2025
1 parent d247f1d commit fe6f3dd
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions Api/Config/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface RepositoryInterface
public const XML_PATH_ENABLE_ADDRESS_SEARCH = 'payment/two_payment/enable_address_search';
public const XML_PATH_ENABLE_TAX_SUBTOTALS = 'payment/two_payment/enable_tax_subtotals';
public const XML_PATH_ENABLE_ORDER_INTENT = 'payment/two_payment/enable_order_intent';
public const XML_PATH_ENABLE_MULTIPLE_INVOICE_EMAILS = 'payment/two_payment/enable_multiple_invoice_emails';
public const XML_PATH_ENABLE_INVOICE_EMAILS = 'payment/two_payment/enable_invoice_emails';
public const XML_PATH_ENABLE_DEPARTMENT_NAME = 'payment/two_payment/enable_department';
public const XML_PATH_ENABLE_PROJECT_NAME = 'payment/two_payment/enable_project';
public const XML_PATH_ENABLE_ORDER_NOTE = 'payment/two_payment/enable_order_note';
Expand Down Expand Up @@ -124,13 +124,13 @@ public function isCompanySearchEnabled(?int $storeId = null): bool;
public function isOrderIntentEnabled(?int $storeId = null): bool;

/**
* Check if order intent is enabled
* Check if invoice emails is enabled
*
* @param int|null $storeId
*
* @return bool
*/
public function isMultipleInvoiceEmailsEnabled(?int $storeId = null): bool;
public function isInvoiceEmailsEnabled(?int $storeId = null): bool;

/**
* Check if tax subtotals is enabled
Expand Down
4 changes: 2 additions & 2 deletions Model/Config/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ public function isOrderIntentEnabled(?int $storeId = null): bool
/**
* @inheritDoc
*/
public function isMultipleInvoiceEmailsEnabled(?int $storeId = null): bool
public function isInvoiceEmailsEnabled(?int $storeId = null): bool
{
return $this->isSetFlag(self::XML_PATH_ENABLE_MULTIPLE_INVOICE_EMAILS, $storeId);
return $this->isSetFlag(self::XML_PATH_ENABLE_INVOICE_EMAILS, $storeId);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Model/Two.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function authorize(InfoInterface $payment, $amount)

$additionalInformation = $payment->getAdditionalInformation();

$multipleInvoiceEmails = $additionalInformation['multipleInvoiceEmails'] ?? null;
$invoiceEmails = $additionalInformation['invoiceEmails'] ?? null;

$payload = $this->compositeOrder->execute(
$order,
Expand Down
2 changes: 1 addition & 1 deletion Model/Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function getConfig(): array
'checkoutPageUrl' => $this->configRepository->getCheckoutPageUrl(),
'redirectUrlCookieCode' => UrlCookie::COOKIE_NAME,
'isOrderIntentEnabled' => $this->configRepository->isOrderIntentEnabled(),
'isMultipleInvoiceEmailsEnabled' => $this->configRepository->isMultipleInvoiceEmailsEnabled(),
'isInvoiceEmailsEnabled' => $this->configRepository->isInvoiceEmailsEnabled(),
'orderIntentConfig' => $orderIntentConfig,
'isCompanySearchEnabled' => $this->configRepository->isCompanySearchEnabled(),
'isAddressSearchEnabled' => $this->configRepository->isAddressSearchEnabled(),
Expand Down
2 changes: 1 addition & 1 deletion Observer/DataAssignObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DataAssignObserver extends AbstractDataAssignObserver
'department',
'orderNote',
'poNumber',
'multipleInvoiceEmails'
'invoiceEmails'
];

/**
Expand Down
6 changes: 3 additions & 3 deletions Service/Order/ComposeOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public function execute(Order $order, string $orderReference, array $additionalD
$lineItems = $this->getLineItemsOrder($order);


// Initialize invoice_details only if multipleInvoiceEmails is present
// Initialize invoice_details only if invoiceEmails is present
$invoiceDetails = [];
if (!empty($additionalData['multipleInvoiceEmails'])) {
$invoiceDetails['invoice_emails'] = explode(',', $additionalData['multipleInvoiceEmails']);
if (!empty($additionalData['invoiceEmails'])) {
$invoiceDetails['invoice_emails'] = explode(',', $additionalData['invoiceEmails']);
// Required placeholders to pass create order API Schema requirements
$invoiceDetails['payment_reference_message'] = "";
$invoiceDetails['payment_reference_ocr'] = "";
Expand Down
6 changes: 3 additions & 3 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@
</depends>
<config_path>payment/two_payment/enable_order_intent</config_path>
</field>
<field id="enable_multiple_invoice_emails" translate="label" type="select" sortOrder="75" showInDefault="1"
<field id="enable_invoice_emails" translate="label" type="select" sortOrder="75" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Enable multiple invoice emails</label>
<label>Enable invoice emails</label>
<comment>Let your buyer input additional emails to forward the invoice to on order fulfilment.</comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="active">1</field>
</depends>
<config_path>payment/two_payment/enable_multiple_invoice_emails</config_path>
<config_path>payment/two_payment/enable_invoice_emails</config_path>
</field>
<field id="enable_tax_subtotals" translate="label" type="select" sortOrder="75" showInDefault="1"
showInWebsite="1" showInStore="1">
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<days_on_invoice>14</days_on_invoice>
<finalize_purchase>1</finalize_purchase>
<enable_order_intent>1</enable_order_intent>
<enable_multiple_invoice_emails>0</enable_multiple_invoice_emails>
<enable_invoice_emails>0</enable_invoice_emails>
<enable_tax_subtotals>1</enable_tax_subtotals>
<fulfill_trigger>shipment</fulfill_trigger>
<fulfill_order_status>complete</fulfill_order_status>
Expand Down
12 changes: 6 additions & 6 deletions view/frontend/web/js/view/payment/method-renderer/two_payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ define([
invalidEmailListMessage: config.invalidEmailListMessage,
soleTraderErrorMessage: config.soleTraderErrorMessage,
isOrderIntentEnabled: config.isOrderIntentEnabled,
isMultipleInvoiceEmailsEnabled: config.isMultipleInvoiceEmailsEnabled,
isInvoiceEmailsEnabled: config.isInvoiceEmailsEnabled,
isDepartmentFieldEnabled: config.isDepartmentFieldEnabled,
isProjectFieldEnabled: config.isProjectFieldEnabled,
isOrderNoteFieldEnabled: config.isOrderNoteFieldEnabled,
Expand All @@ -69,7 +69,7 @@ define([
autofillToken: '',
companyName: ko.observable(''),
companyId: ko.observable(''),
multipleInvoiceEmails: ko.observable(''),
invoiceEmails: ko.observable(''),
project: ko.observable(''),
department: ko.observable(''),
orderNote: ko.observable(''),
Expand Down Expand Up @@ -98,8 +98,8 @@ define([
}, duration);
}
},
validateMultipleEmails: function () {
const emails = this.multipleInvoiceEmails();
validateEmails: function () {
const emails = this.invoiceEmails();
let emailArray = emails.split(',').map((email) => email.trim());

const isValid = emailArray.every((email) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email));
Expand Down Expand Up @@ -244,7 +244,7 @@ define([
}

// Validate emails on the forward list
if (this.isMultipleInvoiceEmailsEnabled && !this.validateMultipleEmails()) {
if (this.isInvoiceEmailsEnabled && !this.validateEmails()) {
this.showErrorMessage(this.invalidEmailListMessage);
return;
}
Expand Down Expand Up @@ -425,7 +425,7 @@ define([
department: this.department(),
orderNote: this.orderNote(),
poNumber: this.poNumber(),
multipleInvoiceEmails: this.multipleInvoiceEmails()
invoiceEmails: this.invoiceEmails()
}
};
},
Expand Down
8 changes: 4 additions & 4 deletions view/frontend/web/template/payment/two_payment.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@
/>
</div>
</div>
<div class="field field-text" data-bind="visible: isMultipleInvoiceEmailsEnabled">
<label for="multiple_invoice_emails" class="label">
<div class="field field-text" data-bind="visible: isInvoiceEmailsEnabled">
<label for="invoice_emails" class="label">
<span data-bind="i18n: 'Forward invoice to email list (optional)'"></span>
</label>
<div class="control">
<input
type="text"
id="multiple_invoice_emails"
data-bind="value: multipleInvoiceEmails, event: { change: validateMultipleEmails }"
id="invoice_emails"
data-bind="value: invoiceEmails, event: { change: validateEmails }"
class="input-text"
/>
</div>
Expand Down

0 comments on commit fe6f3dd

Please sign in to comment.