|
| 1 | +diff --git a/vendor/magento/module-customer-balance/Model/Plugin/InvoiceRepository.php b/vendor/magento/module-customer-balance/Model/Plugin/InvoiceRepository.php |
| 2 | +index b88514d7f78..21a1c82ff0f 100644 |
| 3 | +--- a/vendor/magento/module-customer-balance/Model/Plugin/InvoiceRepository.php |
| 4 | ++++ b/vendor/magento/module-customer-balance/Model/Plugin/InvoiceRepository.php |
| 5 | +@@ -5,22 +5,29 @@ |
| 6 | + */ |
| 7 | + namespace Magento\CustomerBalance\Model\Plugin; |
| 8 | + |
| 9 | ++use Magento\Sales\Api\Data\InvoiceExtension; |
| 10 | ++use Magento\Sales\Api\Data\InvoiceExtensionFactory; |
| 11 | + use Magento\Sales\Api\Data\InvoiceInterface; |
| 12 | ++use Magento\Sales\Api\Data\InvoiceSearchResultInterface; |
| 13 | ++use Magento\Sales\Api\InvoiceRepositoryInterface; |
| 14 | + |
| 15 | ++/** |
| 16 | ++ * Plugin for Invoice repository |
| 17 | ++ */ |
| 18 | + class InvoiceRepository |
| 19 | + { |
| 20 | + /** |
| 21 | +- * @var \Magento\Sales\Api\Data\InvoiceExtensionFactory |
| 22 | ++ * @var InvoiceExtensionFactory |
| 23 | + */ |
| 24 | + private $extensionFactory; |
| 25 | + |
| 26 | + /** |
| 27 | + * Init plugin |
| 28 | + * |
| 29 | +- * @param \Magento\Sales\Api\Data\InvoiceExtensionFactory $invoiceExtensionFactory |
| 30 | ++ * @param InvoiceExtensionFactory $invoiceExtensionFactory |
| 31 | + */ |
| 32 | + public function __construct( |
| 33 | +- \Magento\Sales\Api\Data\InvoiceExtensionFactory $invoiceExtensionFactory |
| 34 | ++ InvoiceExtensionFactory $invoiceExtensionFactory |
| 35 | + ) { |
| 36 | + $this->extensionFactory = $invoiceExtensionFactory; |
| 37 | + } |
| 38 | +@@ -28,16 +35,16 @@ class InvoiceRepository |
| 39 | + /** |
| 40 | + * Get invoice customer balance |
| 41 | + * |
| 42 | +- * @param \Magento\Sales\Api\InvoiceRepositoryInterface $subject |
| 43 | +- * @param \Magento\Sales\Api\Data\InvoiceInterface $resultEntity |
| 44 | +- * @return \Magento\Sales\Api\Data\InvoiceInterface |
| 45 | ++ * @param InvoiceRepositoryInterface $subject |
| 46 | ++ * @param InvoiceInterface $resultEntity |
| 47 | ++ * @return InvoiceInterface |
| 48 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 49 | + */ |
| 50 | + public function afterGet( |
| 51 | +- \Magento\Sales\Api\InvoiceRepositoryInterface $subject, |
| 52 | +- \Magento\Sales\Api\Data\InvoiceInterface $resultEntity |
| 53 | ++ InvoiceRepositoryInterface $subject, |
| 54 | ++ InvoiceInterface $resultEntity |
| 55 | + ) { |
| 56 | +- /** @var \Magento\Sales\Api\Data\InvoiceExtension $extensionAttributes */ |
| 57 | ++ /** @var InvoiceExtension $extensionAttributes */ |
| 58 | + $extensionAttributes = $resultEntity->getExtensionAttributes(); |
| 59 | + if ($extensionAttributes === null) { |
| 60 | + $extensionAttributes = $this->extensionFactory->create(); |
| 61 | +@@ -51,14 +58,16 @@ class InvoiceRepository |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | +- * @param \Magento\Sales\Api\InvoiceRepositoryInterface $subject |
| 66 | +- * @param \Magento\Sales\Api\Data\InvoiceSearchResultInterface $resultInvoice |
| 67 | +- * @return \Magento\Sales\Api\Data\InvoiceSearchResultInterface |
| 68 | ++ * Add customer balance amount information to invoice list |
| 69 | ++ * |
| 70 | ++ * @param InvoiceRepositoryInterface $subject |
| 71 | ++ * @param InvoiceSearchResultInterface $resultInvoice |
| 72 | ++ * @return InvoiceSearchResultInterface |
| 73 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 74 | + */ |
| 75 | + public function afterGetList( |
| 76 | +- \Magento\Sales\Api\InvoiceRepositoryInterface $subject, |
| 77 | +- \Magento\Sales\Api\Data\InvoiceSearchResultInterface $resultInvoice |
| 78 | ++ InvoiceRepositoryInterface $subject, |
| 79 | ++ InvoiceSearchResultInterface $resultInvoice |
| 80 | + ) { |
| 81 | + /** @var InvoiceInterface $invoice */ |
| 82 | + foreach ($resultInvoice->getItems() as $invoice) { |
| 83 | +@@ -70,19 +79,25 @@ class InvoiceRepository |
| 84 | + /** |
| 85 | + * Add customer balance amount information to invoice |
| 86 | + * |
| 87 | +- * @param \Magento\Sales\Api\InvoiceRepositoryInterface $subject |
| 88 | +- * @param \Magento\Sales\Api\Data\InvoiceInterface $entity |
| 89 | ++ * @param InvoiceRepositoryInterface $subject |
| 90 | ++ * @param InvoiceInterface $entity |
| 91 | + * |
| 92 | + * @return void |
| 93 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 94 | + */ |
| 95 | + public function beforeSave( |
| 96 | +- \Magento\Sales\Api\InvoiceRepositoryInterface $subject, |
| 97 | +- \Magento\Sales\Api\Data\InvoiceInterface $entity |
| 98 | ++ InvoiceRepositoryInterface $subject, |
| 99 | ++ InvoiceInterface $entity |
| 100 | + ) { |
| 101 | + $extensionAttributes = $entity->getExtensionAttributes(); |
| 102 | +- if ($extensionAttributes) { |
| 103 | ++ if (!$extensionAttributes) { |
| 104 | ++ return; |
| 105 | ++ } |
| 106 | ++ |
| 107 | ++ if ($extensionAttributes->getCustomerBalanceAmount() !== null) { |
| 108 | + $entity->setCustomerBalanceAmount($extensionAttributes->getCustomerBalanceAmount()); |
| 109 | ++ } |
| 110 | ++ if ($extensionAttributes->getBaseCustomerBalanceAmount() !== null) { |
| 111 | + $entity->setBaseCustomerBalanceAmount($extensionAttributes->getBaseCustomerBalanceAmount()); |
| 112 | + } |
| 113 | + } |
| 114 | +diff --git a/vendor/magento/module-gift-card-account/Model/Plugin/InvoiceRepository.php b/vendor/magento/module-gift-card-account/Model/Plugin/InvoiceRepository.php |
| 115 | +index 8b9bb605033..ba681ffd49a 100644 |
| 116 | +--- a/vendor/magento/module-gift-card-account/Model/Plugin/InvoiceRepository.php |
| 117 | ++++ b/vendor/magento/module-gift-card-account/Model/Plugin/InvoiceRepository.php |
| 118 | +@@ -5,38 +5,44 @@ |
| 119 | + */ |
| 120 | + namespace Magento\GiftCardAccount\Model\Plugin; |
| 121 | + |
| 122 | ++use Magento\Sales\Api\Data\InvoiceExtension; |
| 123 | ++use Magento\Sales\Api\Data\InvoiceExtensionFactory; |
| 124 | ++use Magento\Sales\Api\Data\InvoiceInterface; |
| 125 | ++use Magento\Sales\Api\Data\InvoiceSearchResultInterface; |
| 126 | ++use Magento\Sales\Api\InvoiceRepositoryInterface; |
| 127 | ++ |
| 128 | + /** |
| 129 | + * Plugin for Invoice repository. |
| 130 | + */ |
| 131 | + class InvoiceRepository |
| 132 | + { |
| 133 | + /** |
| 134 | +- * @var \Magento\Sales\Api\Data\InvoiceExtensionFactory |
| 135 | ++ * @var InvoiceExtensionFactory |
| 136 | + */ |
| 137 | + private $extensionFactory; |
| 138 | + |
| 139 | + /** |
| 140 | +- * @param \Magento\Sales\Api\Data\InvoiceExtensionFactory $extensionFactory |
| 141 | ++ * @param InvoiceExtensionFactory $extensionFactory |
| 142 | + */ |
| 143 | + public function __construct( |
| 144 | +- \Magento\Sales\Api\Data\InvoiceExtensionFactory $extensionFactory |
| 145 | ++ InvoiceExtensionFactory $extensionFactory |
| 146 | + ) { |
| 147 | + $this->extensionFactory = $extensionFactory; |
| 148 | + } |
| 149 | + |
| 150 | + /** |
| 151 | +- * @param \Magento\Sales\Api\InvoiceRepositoryInterface $subject |
| 152 | +- * @param \Magento\Sales\Api\Data\InvoiceInterface $entity |
| 153 | +- * |
| 154 | +- * @return \Magento\Sales\Api\Data\InvoiceInterface |
| 155 | ++ * Sets gift card account data from extension attributes to Invoice models after get |
| 156 | + * |
| 157 | ++ * @param InvoiceRepositoryInterface $subject |
| 158 | ++ * @param InvoiceInterface $entity |
| 159 | ++ * @return InvoiceInterface |
| 160 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 161 | + */ |
| 162 | + public function afterGet( |
| 163 | +- \Magento\Sales\Api\InvoiceRepositoryInterface $subject, |
| 164 | +- \Magento\Sales\Api\Data\InvoiceInterface $entity |
| 165 | ++ InvoiceRepositoryInterface $subject, |
| 166 | ++ InvoiceInterface $entity |
| 167 | + ) { |
| 168 | +- /** @var \Magento\Sales\Api\Data\InvoiceExtension $extensionAttributes */ |
| 169 | ++ /** @var InvoiceExtension $extensionAttributes */ |
| 170 | + $extensionAttributes = $entity->getExtensionAttributes(); |
| 171 | + |
| 172 | + if ($extensionAttributes === null) { |
| 173 | +@@ -52,16 +58,17 @@ class InvoiceRepository |
| 174 | + } |
| 175 | + |
| 176 | + /** |
| 177 | +- * @param \Magento\Sales\Api\InvoiceRepositoryInterface $subject |
| 178 | +- * @param \Magento\Sales\Api\Data\InvoiceSearchResultInterface $entities |
| 179 | ++ * Sets gift card account data from extension attributes to Invoice models after get list |
| 180 | + * |
| 181 | +- * @return \Magento\Sales\Api\Data\InvoiceSearchResultInterface |
| 182 | ++ * @param InvoiceRepositoryInterface $subject |
| 183 | ++ * @param InvoiceSearchResultInterface $entities |
| 184 | ++ * @return InvoiceSearchResultInterface |
| 185 | + */ |
| 186 | + public function afterGetList( |
| 187 | +- \Magento\Sales\Api\InvoiceRepositoryInterface $subject, |
| 188 | +- \Magento\Sales\Api\Data\InvoiceSearchResultInterface $entities |
| 189 | ++ InvoiceRepositoryInterface $subject, |
| 190 | ++ InvoiceSearchResultInterface $entities |
| 191 | + ) { |
| 192 | +- /** @var \Magento\Sales\Api\Data\InvoiceInterface $entity */ |
| 193 | ++ /** @var InvoiceInterface $entity */ |
| 194 | + foreach ($entities->getItems() as $entity) { |
| 195 | + $this->afterGet($subject, $entity); |
| 196 | + } |
| 197 | +@@ -70,24 +77,26 @@ class InvoiceRepository |
| 198 | + } |
| 199 | + |
| 200 | + /** |
| 201 | +- * Sets gift card account data from extension attributes |
| 202 | +- * to Invoice model. |
| 203 | +- * |
| 204 | +- * @param \Magento\Sales\Api\InvoiceRepositoryInterface $subject |
| 205 | +- * @param \Magento\Sales\Api\Data\InvoiceInterface $entity |
| 206 | ++ * Sets gift card account data from extension attributes to Invoice model before save |
| 207 | + * |
| 208 | ++ * @param InvoiceRepositoryInterface $subject |
| 209 | ++ * @param InvoiceInterface $entity |
| 210 | + * @return void |
| 211 | +- * |
| 212 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 213 | + */ |
| 214 | + public function beforeSave( |
| 215 | +- \Magento\Sales\Api\InvoiceRepositoryInterface $subject, |
| 216 | +- \Magento\Sales\Api\Data\InvoiceInterface $entity |
| 217 | ++ InvoiceRepositoryInterface $subject, |
| 218 | ++ InvoiceInterface $entity |
| 219 | + ) { |
| 220 | + $extensionAttributes = $entity->getExtensionAttributes(); |
| 221 | ++ if (!$extensionAttributes) { |
| 222 | ++ return; |
| 223 | ++ } |
| 224 | + |
| 225 | +- if ($extensionAttributes) { |
| 226 | ++ if ($extensionAttributes->getGiftCardsAmount() !== null) { |
| 227 | + $entity->setGiftCardsAmount($extensionAttributes->getGiftCardsAmount()); |
| 228 | ++ } |
| 229 | ++ if ($extensionAttributes->getBaseGiftCardsAmount() !== null) { |
| 230 | + $entity->setBaseGiftCardsAmount($extensionAttributes->getBaseGiftCardsAmount()); |
| 231 | + } |
| 232 | + } |
0 commit comments