Changeset 2495913
- Timestamp:
- 03/15/2021 12:38:01 PM (5 years ago)
- Location:
- miqid-woo/trunk
- Files:
-
- 6 added
- 40 edited
-
miqid-woo.php (modified) (2 diffs)
-
readme.md (modified) (1 diff)
-
src/Admin/Admin.php (modified) (5 diffs)
-
src/Admin/Dinero.php (added)
-
src/Frontend/Dinero.php (added)
-
src/Frontend/EConomic.php (modified) (6 diffs)
-
src/Includes/DTO/Base.php (modified) (1 diff)
-
src/Includes/Dinero/API/Base.php (modified) (6 diffs)
-
src/Includes/Dinero/API/Contacts.php (modified) (4 diffs)
-
src/Includes/Dinero/API/Invoices.php (modified) (3 diffs)
-
src/Includes/Dinero/API/Products.php (modified) (2 diffs)
-
src/Includes/Dinero/DTO/Contact.php (modified) (2 diffs)
-
src/Includes/Dinero/DTO/Invoice.php (modified) (12 diffs)
-
src/Includes/Dinero/DTO/Product.php (modified) (1 diff)
-
src/Includes/Dinero/DTO/ProductLine.php (modified) (2 diffs)
-
src/Includes/EConomic/API/Base.php (modified) (2 diffs)
-
src/Includes/EConomic/API/Invoices.php (added)
-
src/Includes/EConomic/API/Orders.php (modified) (2 diffs)
-
src/Includes/EConomic/API/ProductGroups.php (modified) (1 diff)
-
src/Includes/EConomic/DTO/Account.php (modified) (13 diffs)
-
src/Includes/EConomic/DTO/Accrual.php (modified) (1 diff)
-
src/Includes/EConomic/DTO/Attention.php (modified) (1 diff)
-
src/Includes/EConomic/DTO/Base.php (added)
-
src/Includes/EConomic/DTO/Currency.php (modified) (1 diff)
-
src/Includes/EConomic/DTO/Customer.php (modified) (3 diffs)
-
src/Includes/EConomic/DTO/CustomerGroup.php (modified) (6 diffs)
-
src/Includes/EConomic/DTO/Delivery.php (modified) (7 diffs)
-
src/Includes/EConomic/DTO/DeliveryLocation.php (modified) (1 diff)
-
src/Includes/EConomic/DTO/DepartmentalDistribution.php (modified) (6 diffs)
-
src/Includes/EConomic/DTO/Inventory.php (modified) (5 diffs)
-
src/Includes/EConomic/DTO/Invoice.php (added)
-
src/Includes/EConomic/DTO/Layout.php (modified) (3 diffs)
-
src/Includes/EConomic/DTO/Line.php (modified) (2 diffs)
-
src/Includes/EConomic/DTO/Order.php (modified) (3 diffs)
-
src/Includes/EConomic/DTO/PaymentTerm.php (modified) (3 diffs)
-
src/Includes/EConomic/DTO/Product.php (modified) (2 diffs)
-
src/Includes/EConomic/DTO/ProductGroup.php (modified) (5 diffs)
-
src/Includes/EConomic/DTO/ProductInvoice.php (added)
-
src/Includes/EConomic/DTO/Recipient.php (modified) (2 diffs)
-
src/Includes/EConomic/DTO/SalesPerson.php (modified) (1 diff)
-
src/Includes/EConomic/DTO/Unit.php (modified) (1 diff)
-
src/Includes/EConomic/DTO/VatType.php (modified) (3 diffs)
-
src/Includes/EConomic/DTO/VatZone.php (modified) (4 diffs)
-
src/Includes/EConomic/DTO/objSelf.php (modified) (1 diff)
-
src/Includes/Extensions.php (modified) (3 diffs)
-
src/Init.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
miqid-woo/trunk/miqid-woo.php
r2469422 r2495913 3 3 * Plugin Name: MIQID-Woo 4 4 * Description: MIQID-Woo extension for WooCommerce. 5 * Version: 1. 1.25 * Version: 1.6.3 6 6 * Requires at least: 5.2 7 7 * Requires PHP: 7.2 … … 14 14 15 15 require_once __DIR__ . '/vendor/autoload.php'; 16 ini_set( 'serialize_precision', - 1 ); 16 17 17 18 \MIQID\Plugin\WooCommerce\Init::Instance(); -
miqid-woo/trunk/readme.md
r2469422 r2495913 2 2 Contributors: karlogit, miqid 3 3 Tags: MIQID, gtin 4 Tested up to: 5. 5.34 Tested up to: 5.7 5 5 Requires PHP: 7.2 6 Stable tag: 1. 1.26 Stable tag: 1.6.3 7 7 License: GPL v3 or Later 8 8 -
miqid-woo/trunk/src/Admin/Admin.php
r2469411 r2495913 5 5 6 6 use MIQID\Plugin\WooCommerce\Includes\Dinero\{API\Accounts, API\Contacts, API\Invoices, API\Organizations, API\Products, DTO\Contact, DTO\Invoice, DTO\Organization, DTO\Product, DTO\ProductLine}; 7 use Automattic\Jetpack\Constants; 8 use MIQID\Plugin\Core\Classes\DTO\HttpResponse; 7 use MIQID\Plugin\WooCommerce\Includes\EConomic\{DTO\Account, DTO\Accrual}; 9 8 use MIQID\Plugin\WooCommerce\Includes\Extensions; 10 use MIQID\Plugin\WooCommerce\Util;11 9 12 10 class Admin { … … 38 36 } 39 37 40 /*if ( $this->extensions->is_e_conomic() ) {38 if ( $this->extensions->is_e_conomic() ) { 41 39 EConomic::Instance(); 42 }*/ 40 } 41 42 if ( $this->extensions->is_dinero() ) { 43 Dinero::Instance(); 44 } 43 45 } 44 46 … … 61 63 <h1 class="wp-heading-inline"><?= get_admin_page_title() ?></h1> 62 64 <hr class="wp-header-end"/> 65 <p>Upload Test</p> 63 66 <form action="<?= esc_attr( admin_url( 'options.php' ) ) ?>" method="post"> 64 67 <?php … … 106 109 '' 107 110 ); 108 /*add_settings_field(111 add_settings_field( 109 112 'e_conomic', 110 113 'e-conomic', … … 116 119 'miqid-woo', 117 120 '' 118 );*/ 121 ); 122 add_settings_field( 123 'dinero', 124 'Dinero', 125 function () { 126 printf( '<input type="checkbox" name="miqid-woo[dinero]" %1$s />', 127 $this->extensions->is_dinero() ? 'checked' : '' ); 128 }, 129 'miqid-woo', 130 'miqid-woo', 131 '' 132 ); 119 133 } 120 134 -
miqid-woo/trunk/src/Frontend/EConomic.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Frontend; 4 4 5 use Automattic\WooCommerce\Admin\DateTimeProvider\CurrentDateTimeProvider; 5 6 use MIQID\Plugin\Core\Classes\DTO\HttpResponse; 6 use MIQID\Plugin\WooCommerce\{Includes\EConomic\API\Currencies, Includes\EConomic\API\CustomerGroups, Includes\EConomic\API\Customers, Includes\EConomic\API\ Layouts, Includes\EConomic\API\Orders, Includes\EConomic\API\PaymentTerms, Includes\EConomic\API\ProductGroups, Includes\EConomic\API\Products, Includes\EConomic\API\Units, Includes\EConomic\API\VatZones, Includes\EConomic\DTO\Currency, Includes\EConomic\DTO\Customer, Includes\EConomic\DTO\CustomerGroup, Includes\EConomic\DTO\Layout, Includes\EConomic\DTO\Line, Includes\EConomic\DTO\Order, Includes\EConomic\DTO\PaymentTerm, Includes\EConomic\DTO\Product, Includes\EConomic\DTO\ProductGroup, Includes\EConomic\DTO\Recipient, Includes\EConomic\DTO\Unit, Includes\EConomic\DTO\VatZone, Util};7 use MIQID\Plugin\WooCommerce\{Includes\EConomic\API\Currencies, Includes\EConomic\API\CustomerGroups, Includes\EConomic\API\Customers, Includes\EConomic\API\Invoices, Includes\EConomic\API\Layouts, Includes\EConomic\API\Orders, Includes\EConomic\API\PaymentTerms, Includes\EConomic\API\ProductGroups, Includes\EConomic\API\Products, Includes\EConomic\API\Units, Includes\EConomic\API\VatZones, Includes\EConomic\DTO\Currency, Includes\EConomic\DTO\Customer, Includes\EConomic\DTO\CustomerGroup, Includes\EConomic\DTO\Invoice, Includes\EConomic\DTO\Layout, Includes\EConomic\DTO\Line, Includes\EConomic\DTO\Order, Includes\EConomic\DTO\PaymentTerm, Includes\EConomic\DTO\Product, Includes\EConomic\DTO\ProductGroup, Includes\EConomic\DTO\Recipient, Includes\EConomic\DTO\Unit, Includes\EConomic\DTO\VatZone, Util}; 7 8 8 9 class EConomic { … … 27 28 $this->sync_completed = filter_var( get_option( Util::generate_id( self::SECTION_SETTINGS, 'sync', 'completed' ) ), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 28 29 29 /*if ( $this->sync_processing ) {30 if ( $this->sync_processing ) { 30 31 add_action( 'woocommerce_order_status_processing', [ $this, '_processing' ], 10, 1 ); 31 }*/ 32 } 33 if ( $this->sync_completed ) { 34 add_action( 'woocommerce_order_status_completed', [ $this, '_completed' ], 10, 1 ); 35 } 32 36 } 33 37 … … 74 78 } 75 79 76 $dtoCustomer = Customers::Instance()->GET( null, sprintf( '?filter=email$eq:%s', $order->get_billing_email() ) ); 77 78 if ( $dtoCustomer instanceof HttpResponse || empty( $dtoCustomer ) ) { 79 $dtoCustomer = new Customer( [ 80 'Name' => sprintf( '%s %s', $order->get_billing_first_name(), $order->get_billing_last_name() ), 81 'Currency' => $Currency, 82 'email' => $order->get_billing_email(), 83 'customerGroup' => $CustomerGroup, 84 'paymentTerms' => $PaymentTerm, 85 'vatZone' => $VatZone, 86 ] ); 87 80 if ( ( $dtoCustomer = Customers::Instance()->GET( null, sprintf( '?filter=email$eq:%s', $order->get_billing_email() ) ) ) && ! $dtoCustomer instanceof Customer || empty( $dtoCustomer ) ) { 81 $dtoCustomer = new Customer(); 82 } 83 84 $dtoCustomer 85 ->set_currency( $Currency ) 86 ->set_customer_group( $CustomerGroup ) 87 ->set_payment_terms( $PaymentTerm ) 88 ->set_vat_zone( $VatZone ) 89 ->set_email( $order->get_billing_email() ) 90 ->set_name( $order->get_formatted_billing_full_name() ) 91 ->set_address( $order->get_billing_address_1() ) 92 ->set_city( $order->get_billing_city() ) 93 ->set_zip( $order->get_billing_postcode() ) 94 ->set_country( $order->get_billing_country() ) 95 ->set_mobile_phone( $order->get_billing_phone() ); 96 97 if ( empty( $dtoCustomer->get_customer_number() ) ) { 88 98 $dtoCustomer = Customers::Instance()->Post( $dtoCustomer ); 89 if ( $dtoCustomer instanceof HttpResponse ) { 90 error_log( print_r( $dtoCustomer, true ) ); 91 wp_die( '' ); 92 } 93 } 94 95 $dtoCustomer->set_name( sprintf( '%s %s', $order->get_billing_first_name(), $order->get_billing_last_name() ) ); 96 $dtoCustomer->set_address( $order->get_billing_address_1() ); 97 $dtoCustomer->set_city( $order->get_billing_city() ); 98 $dtoCustomer->set_zip( $order->get_billing_postcode() ); 99 $dtoCustomer->set_country( $order->get_billing_country() ); 100 $dtoCustomer->set_mobile_phone( $order->get_billing_phone() ); 101 102 $dtoCustomer = Customers::Instance()->Put( $dtoCustomer->get_customer_number(), $dtoCustomer ); 103 if ( $dtoCustomer instanceof HttpResponse ) { 104 error_log( print_r( $dtoCustomer, true ) ); 105 wp_die( '' ); 106 } 107 108 $dtoOrder = Orders::Instance()->GetDrafts( null, sprintf( '?filter=references.other$eq:%s', $order->get_id() ) ); 109 if ( $dtoOrder instanceof HttpResponse || empty( $dtoOrder ) ) { 110 $dtoOrder = new Order( [ 111 'currency' => $Currency, 112 'customer' => $dtoCustomer, 113 'references' => [ 114 'other' => sprintf( '%s', $order->get_id() ), 115 ], 116 ] ); 117 118 $dtoOrder->set_date( $order->get_date_paid() ?? $order->get_date_created() ); 119 $dtoOrder->set_layout( $Layout ); 120 $dtoOrder->set_payment_terms( $PaymentTerm ); 121 $dtoOrder->set_recipient( new Recipient( [ 122 'Name' => sprintf( '%s %s', $order->get_shipping_first_name(), $order->get_shipping_last_name() ), 123 'Address' => $order->get_shipping_address_1(), 124 'City' => $order->get_shipping_city(), 125 'Zip' => $order->get_shipping_postcode(), 126 'Country' => $order->get_shipping_country(), 127 'MobilePhone' => $order->get_billing_phone(), 128 'VatZone' => $VatZone, 129 ] ) ); 130 131 $dtoOrder = Orders::Instance()->PostDrafts( $dtoOrder ); 132 if ( $dtoOrder instanceof HttpResponse ) { 133 error_log( print_r( $dtoOrder, true ) ); 134 wp_die( '' ); 135 } 136 } 99 } else { 100 $dtoCustomer = Customers::Instance()->Put( $dtoCustomer->get_customer_number(), $dtoCustomer ); 101 } 102 137 103 138 104 $LineNumber = 1; … … 142 108 /** @var \WC_Product|bool $wc_product */ 143 109 if ( $wc_product = $order_item->get_product() ) { 144 $dtoProduct = Products::Instance()->Get( null, '?filter=productNumber$eq:' . $wc_product->get_sku() ); 145 if ( $dtoProduct instanceof HttpResponse || empty( $dtoProduct ) ) { 146 $dtoProduct = new Product( [ 147 'Name' => $wc_product->get_name(), 148 'ProductGroup' => $wc_product->is_taxable() ? ProductGroups::Instance()->Get( 1 ) : ProductGroups::Instance()->Get( 2 ), 149 'ProductNumber' => $wc_product->get_sku(), 150 ] ); 151 110 if ( ( $dtoProduct = Products::Instance()->Get( null, '?filter=productNumber$eq:' . $wc_product->get_sku() ) ) && ! $dtoProduct instanceof Product || empty( $dtoProduct ) ) { 111 $dtoProduct = new Product(); 112 } 113 114 $ProductGroup = ProductGroups::Instance()->Get( ProductGroups::Product_Without_Vat ); 115 if ( wc_tax_enabled() ) { 116 $ProductGroup = ProductGroups::Instance()->Get( ProductGroups::Product_With_Vat ); 117 118 if ( ! $wc_product->is_taxable() ) { 119 $ProductGroup = ProductGroups::Instance()->Get( ProductGroups::Product_Without_Vat ); 120 } 121 } 122 123 $dtoProduct 124 ->set_product_number( $wc_product->get_sku() ) 125 ->set_name( $wc_product->get_name() ) 126 ->set_product_group( $ProductGroup ) 127 ->set_sales_price( wc_get_price_excluding_tax( $wc_product ) ); 128 129 if ( empty( $dtoProduct->get_self() ) ) { 152 130 $dtoProduct = Products::Instance()->Post( $dtoProduct ); 153 } 154 $dtoProduct->set_name( $wc_product->get_name() ); 155 $dtoProduct->set_description( $wc_product->get_short_description() ); 156 if ( empty( $dtoProduct->get_description() ) ) { 157 $dtoProduct->set_description( $wc_product->get_description() ); 158 } 159 $dtoProduct->set_sales_price( $wc_product->get_price() ); 160 161 $dtoProduct = Products::Instance()->PUT( $dtoProduct->get_product_number(), $dtoProduct ); 162 163 $Lines[] = new Line( [ 164 'LineNumber' => $LineNumber ++, 165 'product' => $dtoProduct, 166 'description' => $order_item->get_name(), 167 'Unit' => $Unit, 168 'unitNetPrice' => $wc_product->get_price(), 169 'Quantity' => $order_item->get_quantity(), 170 ] ); 131 } else { 132 $dtoProduct = Products::Instance()->PUT( $dtoProduct->get_product_number(), $dtoProduct ); 133 } 134 135 $Lines[] = ( new Line() ) 136 ->set_line_number( $LineNumber ++ ) 137 ->set_product( $dtoProduct ) 138 ->set_description( $order_item->get_name() ) 139 ->set_unit( $Unit ) 140 ->set_unit_net_price( $dtoProduct->get_sales_price() ) 141 ->set_quantity( $order_item->get_quantity() ); 171 142 } 172 143 } … … 174 145 /** @var \WC_Order_Item_Shipping $order_item */ 175 146 foreach ( $order->get_items( 'shipping' ) as $order_item ) { 176 $sku = sprintf( '%s-%s', $order_item->get_method_id(), $order_item->get_instance_id() ); 177 $dtoProduct = Products::Instance()->Get( null, '?filter=productNumber$eq:' . $sku ); 178 if ( $dtoProduct instanceof HttpResponse || empty( $dtoProduct ) ) { 179 $dtoProduct = new Product( [ 180 'Name' => $order_item->get_name(), 181 'ProductNumber' => $sku, 182 'ProductGroup' => ProductGroups::Instance()->Get( 4 ), 183 'SalesPrice' => $order_item->get_total(), 184 ] ); 147 $sku = sprintf( '%s-%s', $order_item->get_method_id(), $order_item->get_instance_id() ); 148 149 if ( ( $dtoProduct = Products::Instance()->Get( null, '?filter=productNumber$eq:' . $sku ) ) && ! $dtoProduct instanceof Product || empty( $dtoProduct ) ) { 150 $dtoProduct = new Product(); 151 } 152 153 $ProductGroup = ProductGroups::Instance()->Get( ProductGroups::Product_Without_Vat ); 154 if ( wc_tax_enabled() ) { 155 $ProductGroup = ProductGroups::Instance()->Get( ProductGroups::Product_With_Vat ); 156 157 if ( ! $order_item->calculate_taxes() ) { 158 $ProductGroup = ProductGroups::Instance()->Get( ProductGroups::Product_Without_Vat ); 159 } 160 } 161 162 163 $dtoProduct 164 ->set_product_number( $sku ) 165 ->set_name( $order_item->get_name() ) 166 ->set_product_group( $ProductGroup ) 167 ->set_sales_price( $order_item->get_total() ); 168 169 if ( empty( $dtoProduct->get_self() ) ) { 185 170 $dtoProduct = Products::Instance()->Post( $dtoProduct ); 186 if ( $dtoProduct instanceof HttpResponse ) { 187 error_log( print_r( $dtoProduct, true ) ); 188 } 171 } else { 172 $dtoProduct = Products::Instance()->PUT( $dtoProduct->get_product_number(), $dtoProduct ); 189 173 } 190 174 … … 199 183 } 200 184 201 $dtoOrder->set_lines( $Lines ); 202 203 $dtoOrder = Orders::Instance()->PutDrafts( $dtoOrder->get_order_number(), $dtoOrder ); 204 if ( $dtoOrder instanceof HttpResponse ) { 205 error_log( print_r( $dtoOrder, true ) ); 206 wp_die( '' ); 185 186 if ( ( $dtoOrder = Orders::Instance()->GetDrafts( null, sprintf( '?filter=references.other$eq:%s', $order->get_order_number() ) ) ) && ! $dtoOrder instanceof Order || empty( $dtoOrder ) ) { 187 $dtoOrder = new Order(); 188 } 189 190 $dtoOrder 191 ->set_currency( $Currency ) 192 ->set_customer( $dtoCustomer ) 193 ->set_references( [ 194 'other' => sprintf( '%s', $order->get_order_number() ), 195 ] ) 196 ->set_date( $order->get_date_paid() ?? $order->get_date_created() ) 197 ->set_layout( $Layout ) 198 ->set_payment_terms( $PaymentTerm ) 199 ->set_recipient( ( new Recipient() ) 200 ->set_name( ! empty( trim( $order->get_formatted_shipping_full_name() ) ) ? $order->get_formatted_shipping_full_name() : $order->get_formatted_billing_full_name() ) 201 ->set_address( ! empty( trim( $order->get_shipping_address_1() ) ) ? $order->get_shipping_address_1() : $order->get_billing_address_1() ) 202 ->set_zip( ! empty( trim( $order->get_shipping_postcode() ) ) ? $order->get_shipping_postcode() : $order->get_billing_postcode() ) 203 ->set_city( ! empty( trim( $order->get_shipping_city() ) ) ? $order->get_shipping_city() : $order->get_billing_city() ) 204 ->set_country( ! empty( trim( $order->get_shipping_country() ) ) ? $order->get_shipping_country() : $order->get_billing_country() ) 205 ->set_mobile_phone( $order->get_billing_phone() ) 206 ->set_vat_zone( $VatZone ) 207 ) 208 ->set_lines( $Lines ); 209 210 $dtoOrder->set_delivery( $dtoOrder->get_recipient() ); 211 212 if ( empty( $dtoOrder->get_self() ) ) { 213 $dtoOrder = Orders::Instance()->PostDrafts( $dtoOrder ); 214 } else { 215 $dtoOrder = Orders::Instance()->PutDrafts( $dtoOrder->get_order_number(), $dtoOrder ); 216 } 217 218 if ( ( $dtoInvoice = Invoices::Instance()->GetDrafts( null, sprintf( 'references.other$eq:%s', $order->get_order_number() ) ) ) && $dtoInvoice instanceof Invoice || empty( $dtoInvoice ) ) { 219 $dtoInvoice = new Invoice( $dtoOrder->jsonSerialize() ); 220 } 221 222 if ( is_array( $dtoInvoice ) ) { 223 $dtoInvoice = current( $dtoInvoice ); 224 } 225 226 $dtoInvoice 227 ->set_lines( $dtoOrder->get_lines() ); 228 229 if ( empty( $dtoInvoice->get_self() ) ) { 230 $dtoInvoice = Invoices::Instance()->PostDrafts( $dtoInvoice ); 231 } else { 232 $dtoInvoice = Invoices::Instance()->PutDrafts( $dtoInvoice->get_draft_invoice_number(), $dtoInvoice ); 233 } 234 } 235 236 function _completed( $order_id ) { 237 $wc_order = wc_get_order( $order_id ); 238 239 if ( ( $dtoOrder = Orders::Instance()->GetDrafts( null, sprintf( '?filter=references.other$eq:%s', $wc_order->get_order_number() ) ) ) && ! $dtoOrder instanceof Order || empty( $dtoOrder ) ) { 240 $dtoOrder = new Order(); 241 } 242 243 244 245 if ( ! empty( $dtoOrder->get_order_number() ) ) { 246 $dtoOrder = Orders::Instance()->PostSent( $dtoOrder ); 247 } 248 249 if ( ( $dtoInvoice = Invoices::Instance()->GetDrafts( null, sprintf( 'references.other$eq:%s', $wc_order->get_order_number() ) ) ) && $dtoInvoice instanceof Invoice || empty( $dtoInvoice ) ) { 250 $dtoInvoice = new Invoice(); 251 } 252 253 if ( is_array( $dtoInvoice ) ) { 254 $dtoInvoice = current( $dtoInvoice ); 255 } 256 257 if ( ! empty( $dtoInvoice->get_draft_invoice_number() ) ) { 258 $dtoInvoice = Invoices::Instance()->PostBooked( $dtoInvoice ); 207 259 } 208 260 } -
miqid-woo/trunk/src/Includes/DTO/Base.php
r2469411 r2495913 6 6 public function __construct( $must_be_null = null ) { 7 7 if ( is_array( $must_be_null ) ) { 8 wp_die( sprintf( '<pre>%s</pre>', print_r( [ $this, $must_be_null ], true ) ) );8 wp_die( sprintf( '<pre>%s</pre>', print_r( [ 'Missing construct', $this, $must_be_null ], true ) ) ); 9 9 } 10 10 } -
miqid-woo/trunk/src/Includes/Dinero/API/Base.php
r2469411 r2495913 14 14 $headers = wp_parse_args( $headers, [ 15 15 'Content-Type' => 'application/json', 16 'Authorization' => sprintf( 'bearer %s', $this->Authenticate() ),16 'Authorization' => sprintf( 'bearer %s', $this->Authenticate()['access_token'] ?? '' ), 17 17 ] ); 18 18 … … 33 33 $headers = wp_parse_args( $headers, [ 34 34 'Content-Type' => 'application/json', 35 'Authorization' => sprintf( 'bearer %s', $this->Authenticate() ),35 'Authorization' => sprintf( 'bearer %s', $this->Authenticate()['access_token'] ?? '' ), 36 36 ] ); 37 37 … … 48 48 protected function GetEndpoint( ...$endpoint ): string { 49 49 $class = $this; 50 if ( empty( $endpoint ) ) { 51 try { 52 $endpoint[] = ( new \ReflectionClass( $this ) )->getShortName(); 53 } catch ( \ReflectionException $e ) { 50 54 51 try {52 $class = new \ReflectionClass( $this );53 if ( empty( $endpoint ) ) {54 $endpoint[] = $class->getShortName();55 55 } 56 } catch ( \ReflectionException $e ) {57 58 56 } 59 57 … … 65 63 private $authenticate; 66 64 65 /** 66 * @return array|null 67 */ 67 68 public function Authenticate() { 68 69 if ( is_null( $this->authenticate ) ) { … … 70 71 'headers' => [ 71 72 'Content-Type' => 'application/x-www-form-urlencoded', 72 'Authorization' => 'Basic ' . base64_encode( sprintf( '%s:%s', 'KarlogIT', 'GYOwGzQE3LkZt7h9w1bTDnQtFRuGrnS8BjfeisfduA' ) ), 73 'Authorization' => 'Basic ' . base64_encode( sprintf( '%s:%s', 74 get_option( Util::generate_id( 'dinero', 'access', 'username' ) ), 75 get_option( Util::generate_id( 'dinero', 'access', 'password' ) ) 76 ) ), 73 77 ], 74 78 'method' => 'POST', 75 79 'body' => http_build_query( [ 76 'username' => '755ba08d8d8244cd8c593eb6c4852f3c',77 'password' => '755ba08d8d8244cd8c593eb6c4852f3c',80 'username' => get_option( Util::generate_id( 'dinero', 'access', 'token' ) ), 81 'password' => get_option( Util::generate_id( 'dinero', 'access', 'token' ) ), 78 82 'scope' => 'read write', 79 83 'grant_type' => 'password', 84 //8CjPGo3m6Qp9JO79qVuPsCfUA02Lvvz! 80 85 ] ), 81 86 ] ); … … 86 91 } 87 92 88 return $this->authenticate ['access_token'] ?? '';93 return $this->authenticate; 89 94 } 90 95 91 protected function GetOrganizationId() {92 return 320738;96 protected function GetOrganizationId() { 97 return get_option( Util::generate_id( 'dinero', 'access', 'organization_id' ) );//320738; 93 98 } 94 99 } -
miqid-woo/trunk/src/Includes/Dinero/API/Contacts.php
r2469411 r2495913 32 32 'fields' => $fields, 33 33 'queryFilter' => $queryFilter, 34 ], $this->GetEndpoint( 320738, 'contacts' ) )34 ], $this->GetEndpoint( $this->GetOrganizationId(), 'contacts' ) ) 35 35 ); 36 36 … … 49 49 function CreateContact( Contact $contact ) { 50 50 $HttpReponse = $this->RemotePost( 51 $this->GetEndpoint( 320738, 'contacts' ),51 $this->GetEndpoint( $this->GetOrganizationId(), 'contacts' ), 52 52 $contact 53 53 ); 54 54 55 55 if ( in_array( $HttpReponse->get_response_code(), [ 201 ] ) ) { 56 return $contact->set_contact_guid( $HttpReponse->get_body()['ContactGuid'] );56 return self::GetContact( $HttpReponse->get_body()['ContactGuid'] ); 57 57 } 58 58 … … 67 67 function GetContact( $guid ) { 68 68 $HttpResponse = $this->RemoteGet( 69 $this->GetEndpoint( 320738, 'contacts', $guid ),69 $this->GetEndpoint( $this->GetOrganizationId(), 'contacts', $guid ) 70 70 ); 71 71 … … 79 79 function UpdateContact( $guid, Contact $contact ) { 80 80 $httpResponse = $this->RemotePost( 81 $this->GetEndpoint( 320738, 'contacts', $guid ),81 $this->GetEndpoint( $this->GetOrganizationId(), 'contacts', $guid ), 82 82 $contact, 83 83 [], -
miqid-woo/trunk/src/Includes/Dinero/API/Invoices.php
r2469411 r2495913 32 32 33 33 if ( in_array( $HttpResponse->get_response_code(), [ 201 ] ) ) { 34 return $invoice->set_invoice_guid( $HttpResponse->get_body()['Guid'] );34 return self::GetInvoice( $HttpResponse->get_body()['Guid'] ); 35 35 } 36 36 … … 89 89 function UpdateInvoice( $guid, Invoice $invoice ) { 90 90 $HttpResponse = $this->RemotePost( 91 strtr( $this->GetEndpoint( $this->GetOrganizationId(), 'invoices' ), [ '/v1/' => '/v1.2/' ] ),91 strtr( $this->GetEndpoint( $this->GetOrganizationId(), 'invoices', $guid ), [ '/v1/' => '/v1.2/' ] ), 92 92 $invoice, 93 93 [], … … 96 96 97 97 if ( in_array( $HttpResponse->get_response_code(), [ 200 ] ) ) { 98 return $invoice->set_invoice_guid( $HttpResponse->get_body()['Guid'] ); 98 return $invoice->set_guid( $HttpResponse->get_body()['Guid'] ); 99 } 100 101 return $HttpResponse; 102 } 103 104 /** 105 * @param $guid 106 * @param array $body = [ 107 * 'Timestamp' => required, 108 * 'Number' => nullable 109 * ] 110 * 111 * @return Invoice|HttpResponse 112 */ 113 function BookInvoice( $guid, $body = [] ) { 114 $HttpResponse = $this->RemotePost( 115 //https://api.dinero.dk/v1/{organizationId}/invoices/{guid}/book 116 $this->GetEndpoint( $this->GetOrganizationId(), 'invoices', $guid, 'book' ), 117 $body 118 ); 119 120 if ( in_array( $HttpResponse->get_response_code(), [ 200 ] ) ) { 121 return self::GetInvoice( $guid ); 99 122 } 100 123 -
miqid-woo/trunk/src/Includes/Dinero/API/Products.php
r2469411 r2495913 28 28 function GetProduct( $guid ) { 29 29 $HttpResponse = $this->RemoteGet( 30 $this->GetEndpoint( 320738, 'products', $guid )30 $this->GetEndpoint( $this->GetOrganizationId(), 'products', $guid ) 31 31 ); 32 32 … … 46 46 function UpdateProduct( $guid, Product $product ) { 47 47 $HttpResponse = $this->RemotePost( 48 $this->GetEndpoint( 320738, 'products', $guid ),48 $this->GetEndpoint( $this->GetOrganizationId(), 'products', $guid ), 49 49 $product, 50 50 [], -
miqid-woo/trunk/src/Includes/Dinero/DTO/Contact.php
r2469411 r2495913 5 5 use DateTime; 6 6 use MIQID\Plugin\WooCommerce\Includes\Dinero\DTO; 7 use MIQID\Plugin\WooCommerce\Util; 7 8 8 9 class Contact extends DTO { … … 693 694 public function jsonSerialize() { 694 695 $vars = get_object_vars( $this ); 696 $vars = Util::filter_null_from( $vars ); 695 697 696 698 return $vars; -
miqid-woo/trunk/src/Includes/Dinero/DTO/Invoice.php
r2469411 r2495913 5 5 use DateTime; 6 6 use MIQID\Plugin\WooCommerce\Includes\Dinero\DTO; 7 use MIQID\Plugin\WooCommerce\Util; 7 8 8 9 class Invoice extends DTO { 9 10 /** @var string|null */ 10 protected $InvoiceGuid; 11 private $Guid; 12 /** @var string|null */ 13 private $ContactGuid; 14 /** @var string|null */ 15 private $InvoiceTemplateId; 16 /** @var string|null */ 17 private $ExternalReference; 18 /** @var string|null */ 19 private $Language; 11 20 /** @var string|null */ 12 21 private $Currency; 13 /** @var string|null */ 14 private $Language; 15 /** @var string|null */ 16 private $ExternalReference; 17 /** @var string|null */ 18 private $Description; 19 /** @var string|null */ 20 private $Comment; 21 /** @var DateTime|string|null */ 22 /** @var DateTime|null */ 22 23 private $Date; 23 /** @var ProductLine[] */ 24 private $ProductLines; 25 /** @var string|null */ 26 private $Address; 27 /** @var bool */ 28 private $ShowLinesInclVat; 29 /** @var string|null */ 30 private $InvoiceTemplateId; 31 /** @var string|null */ 32 private $ContactGuid; 24 /** @var string|null */ 25 private $TimeStamp; 26 /** @var DateTime|null */ 27 private $CreatedAt; 28 /** @var DateTime|null */ 29 private $UpdatedAt; 30 /** @var DateTime|null */ 31 private $DeletedAt; 32 /** @var DateTime|null */ 33 private $PaymentDate; 34 /** @var string|null */ 35 private $Status; 36 /** @var string|null */ 37 private $MailOutStatus; 38 /** @var string|null */ 39 private $PaymentStatus; 33 40 /** @var int|null */ 34 41 private $PaymentConditionNumberOfDays; 35 42 /** @var string|null */ 36 43 private $PaymentConditionType; 44 /** @var string|null */ 45 private $FikCode; 46 /** @var int|null */ 47 private $DepositAccountNumber; 48 /** @var string|null */ 49 private $LatestMailOutType; 50 /** @var string|null */ 51 private $Description; 52 /** @var string|null */ 53 private $Comment; 54 /** @var string|null */ 55 private $Address; 56 /** @var int|null */ 57 private $Number; 58 /** @var string|null */ 59 private $ContactName; 60 /** @var string|null */ 61 private $ShowLinesInclVat; 62 /** @var ProductLine[]|null */ 63 private $ProductLines; 64 /** @var array|null */ 65 private $TotalLines; 66 /** @var float|null */ 67 private $TotalExclVat; 68 /** @var float|null */ 69 private $TotalVatableAmount; 70 /** @var float|null */ 71 private $TotalInclVat; 72 /** @var float|null */ 73 private $TotalNonVatableAmount; 74 /** @var float|null */ 75 private $TotalVat; 76 /** @var bool */ 77 private $IsSentToDebtCollection; 37 78 /** @var bool */ 38 79 private $IsMobilePayInvoiceEnabled; 39 80 40 /** 41 * @param string|null $InvoiceGuid 42 * 43 * @return Invoice 44 */ 45 public function set_invoice_guid( ?string $InvoiceGuid ): Invoice { 46 $this->InvoiceGuid = $InvoiceGuid; 47 48 return $this; 81 public function __construct( array $invoice_arr = null ) { 82 if ( is_array( $invoice_arr ) ) { 83 $this->parse_array( $invoice_arr ); 84 } 85 } 86 87 /** 88 * @param string|null $Guid 89 * 90 * @return Invoice 91 */ 92 public function set_guid( ?string $Guid ): self { 93 $this->Guid = $Guid; 94 95 return $this; 96 } 97 98 /** 99 * @return string|null 100 */ 101 public function get_guid(): ?string { 102 return $this->Guid; 103 } 104 105 /** 106 * @param string|null $ContactGuid 107 * 108 * @return Invoice 109 */ 110 public function set_contact_guid( ?string $ContactGuid ): self { 111 $this->ContactGuid = $ContactGuid; 112 113 return $this; 114 } 115 116 /** 117 * @return string|null 118 */ 119 public function get_contact_guid(): ?string { 120 return $this->ContactGuid; 121 } 122 123 /** 124 * @param string|null $InvoiceTemplateId 125 * 126 * @return Invoice 127 */ 128 public function set_invoice_template_id( ?string $InvoiceTemplateId ): self { 129 $this->InvoiceTemplateId = $InvoiceTemplateId; 130 131 return $this; 132 } 133 134 /** 135 * @return string|null 136 */ 137 public function get_invoice_template_id(): ?string { 138 return $this->InvoiceTemplateId; 139 } 140 141 /** 142 * @param string|null $ExternalReference 143 * 144 * @return Invoice 145 */ 146 public function set_external_reference( ?string $ExternalReference ): self { 147 $this->ExternalReference = $ExternalReference; 148 149 return $this; 150 } 151 152 /** 153 * @return string|null 154 */ 155 public function get_external_reference(): ?string { 156 return $this->ExternalReference; 157 } 158 159 /** 160 * @param string|null $Language 161 * 162 * @return Invoice 163 */ 164 public function set_language( ?string $Language ): self { 165 $this->Language = $Language; 166 167 return $this; 168 } 169 170 /** 171 * @return string|null 172 */ 173 public function get_language(): ?string { 174 return $this->Language; 49 175 } 50 176 … … 54 180 * @return Invoice 55 181 */ 56 public function set_currency( ?string $Currency ): Invoice{182 public function set_currency( ?string $Currency ): self { 57 183 $this->Currency = $Currency; 58 184 … … 61 187 62 188 /** 63 * @param string|null $Language 64 * 65 * @return Invoice 66 */ 67 public function set_language( ?string $Language ): Invoice { 68 $this->Language = $Language; 69 70 return $this; 71 } 72 73 /** 74 * @param string|null $ExternalReference 75 * 76 * @return Invoice 77 */ 78 public function set_external_reference( ?string $ExternalReference ): Invoice { 79 $this->ExternalReference = $ExternalReference; 80 81 return $this; 82 } 83 84 /** 85 * @param string|null $Description 86 * 87 * @return Invoice 88 */ 89 public function set_description( ?string $Description ): Invoice { 90 $this->Description = $Description; 91 92 return $this; 93 } 94 95 /** 96 * @param string|null $Comment 97 * 98 * @return Invoice 99 */ 100 public function set_comment( ?string $Comment ): Invoice { 101 $this->Comment = $Comment; 102 103 return $this; 189 * @return string|null 190 */ 191 public function get_currency(): ?string { 192 return $this->Currency; 104 193 } 105 194 … … 109 198 * @return Invoice 110 199 */ 111 public function set_date( $Date ): Invoice{200 public function set_date( $Date ): self { 112 201 if ( is_string( $Date ) ) { 113 202 $Date = date_create( $Date ); … … 119 208 120 209 /** 121 * @param ProductLine[] $ProductLines 122 * 123 * @return Invoice 124 */ 125 public function set_product_lines( array $ProductLines ): Invoice { 126 $this->ProductLines = $ProductLines; 127 128 return $this; 129 } 130 131 public function add_product_lines( ProductLine $product_line ): Invoice { 132 if ( ! is_array( $this->ProductLines ) ) { 133 $this->ProductLines = []; 134 } 135 136 array_push( $this->ProductLines, $product_line ); 137 138 return $this; 139 } 140 141 /** 142 * @param string|null $Address 143 * 144 * @return Invoice 145 */ 146 public function set_address( ?string $Address ): Invoice { 147 $this->Address = $Address; 148 149 return $this; 150 } 151 152 /** 153 * @param bool $ShowLinesInclVat 154 * 155 * @return Invoice 156 */ 157 public function set_show_lines_incl_vat( bool $ShowLinesInclVat ): Invoice { 158 $this->ShowLinesInclVat = $ShowLinesInclVat; 159 160 return $this; 161 } 162 163 /** 164 * @param string|null $InvoiceTemplateId 165 * 166 * @return Invoice 167 */ 168 public function set_invoice_template_id( ?string $InvoiceTemplateId ): Invoice { 169 $this->InvoiceTemplateId = $InvoiceTemplateId; 170 171 return $this; 172 } 173 174 /** 175 * @param string|null $ContactGuid 176 * 177 * @return Invoice 178 */ 179 public function set_contact_guid( ?string $ContactGuid ): Invoice { 180 $this->ContactGuid = $ContactGuid; 181 182 return $this; 210 * @param string|null $format 211 * 212 * @return DateTime|string|null 213 */ 214 public function get_date( ?string $format = null ) { 215 if ( $this->Date instanceof DateTime && ! empty( $format ) ) { 216 return $this->Date->format( $format ); 217 } 218 219 return $this->Date; 220 } 221 222 /** 223 * @param string|null $TimeStamp 224 * 225 * @return Invoice 226 */ 227 public function set_time_stamp( ?string $TimeStamp ): self { 228 $this->TimeStamp = $TimeStamp; 229 230 return $this; 231 } 232 233 /** 234 * @return string|null 235 */ 236 public function get_time_stamp(): ?string { 237 return $this->TimeStamp; 238 } 239 240 /** 241 * @param DateTime|string|null $CreatedAt 242 * 243 * @return Invoice 244 */ 245 public function set_created_at( $CreatedAt ): self { 246 if ( is_string( $CreatedAt ) ) { 247 $CreatedAt = date_create( $CreatedAt ); 248 } 249 $this->CreatedAt = $CreatedAt; 250 251 return $this; 252 } 253 254 /** 255 * @param null $format 256 * 257 * @return DateTime|string|null 258 */ 259 public function get_created_at( $format = null ) { 260 if ( $this->CreatedAt instanceof DateTime && ! empty( $format ) ) { 261 return $this->CreatedAt->format( $format ); 262 } 263 264 return $this->CreatedAt; 265 } 266 267 /** 268 * @param DateTime|string|null $UpdatedAt 269 * 270 * @return Invoice 271 */ 272 public function set_updated_at( $UpdatedAt ): self { 273 if ( is_string( $UpdatedAt ) ) { 274 $UpdatedAt = date_create( $UpdatedAt ); 275 } 276 $this->UpdatedAt = $UpdatedAt; 277 278 return $this; 279 } 280 281 /** 282 * @return DateTime|string|null 283 */ 284 public function get_updated_at( $format = null ) { 285 if ( $this->UpdatedAt instanceof DateTime && ! empty( $format ) ) { 286 return $this->UpdatedAt->format( $format ); 287 } 288 289 return $this->UpdatedAt; 290 } 291 292 /** 293 * @param DateTime|string|null $DeletedAt 294 * 295 * @return Invoice 296 */ 297 public function set_deleted_at( $DeletedAt ): self { 298 if ( is_string( $DeletedAt ) ) { 299 $DeletedAt = date_create( $DeletedAt ); 300 } 301 $this->DeletedAt = $DeletedAt; 302 303 return $this; 304 } 305 306 /** 307 * @return DateTime|string|null 308 */ 309 public function get_deleted_at( $format = null ) { 310 if ( $this->DeletedAt instanceof DateTime && ! empty( $format ) ) { 311 return $this->DeletedAt->format( $format ); 312 } 313 314 return $this->DeletedAt; 315 } 316 317 /** 318 * @param DateTime|string|null $PaymentDate 319 * 320 * @return Invoice 321 */ 322 public function set_payment_date( $PaymentDate ): self { 323 if ( is_string( $PaymentDate ) ) { 324 $PaymentDate = date_create( $PaymentDate ); 325 } 326 $this->PaymentDate = $PaymentDate; 327 328 return $this; 329 } 330 331 /** 332 * @return DateTime|string|null 333 */ 334 public function get_payment_date( $format = null ) { 335 if ( $this->PaymentDate instanceof DateTime && ! empty( $format ) ) { 336 return $this->PaymentDate->format( $format ); 337 } 338 339 return $this->PaymentDate; 340 } 341 342 /** 343 * @param string|null $Status 344 * 345 * @return Invoice 346 */ 347 public function set_status( ?string $Status ): self { 348 $this->Status = $Status; 349 350 return $this; 351 } 352 353 /** 354 * @return string|null 355 */ 356 public function get_status(): ?string { 357 return $this->Status; 358 } 359 360 /** 361 * @param string|null $MailOutStatus 362 * 363 * @return Invoice 364 */ 365 public function set_mail_out_status( ?string $MailOutStatus ): self { 366 $this->MailOutStatus = $MailOutStatus; 367 368 return $this; 369 } 370 371 /** 372 * @return string|null 373 */ 374 public function get_mail_out_status(): ?string { 375 return $this->MailOutStatus; 376 } 377 378 /** 379 * @param string|null $PaymentStatus 380 * 381 * @return Invoice 382 */ 383 public function set_payment_status( ?string $PaymentStatus ): self { 384 $this->PaymentStatus = $PaymentStatus; 385 386 return $this; 387 } 388 389 /** 390 * @return string|null 391 */ 392 public function get_payment_status(): ?string { 393 return $this->PaymentStatus; 183 394 } 184 395 … … 188 399 * @return Invoice 189 400 */ 190 public function set_payment_condition_number_of_days( ?int $PaymentConditionNumberOfDays ): Invoice{401 public function set_payment_condition_number_of_days( ?int $PaymentConditionNumberOfDays ): self { 191 402 $this->PaymentConditionNumberOfDays = $PaymentConditionNumberOfDays; 192 403 … … 195 406 196 407 /** 408 * @return int|null 409 */ 410 public function get_payment_condition_number_of_days(): ?int { 411 return $this->PaymentConditionNumberOfDays; 412 } 413 414 /** 197 415 * @param string|null $PaymentConditionType 198 416 * 199 417 * @return Invoice 200 418 */ 201 public function set_payment_condition_type( ?string $PaymentConditionType ): Invoice{419 public function set_payment_condition_type( ?string $PaymentConditionType ): self { 202 420 $this->PaymentConditionType = $PaymentConditionType; 203 421 … … 206 424 207 425 /** 208 * @param bool $IsMobilePayInvoiceEnabled 209 * 210 * @return Invoice 211 */ 212 public function set_is_mobile_pay_invoice_enabled( bool $IsMobilePayInvoiceEnabled ): Invoice { 213 $this->IsMobilePayInvoiceEnabled = $IsMobilePayInvoiceEnabled; 214 215 return $this; 216 } 217 218 /** 219 * @return string|null 220 */ 221 public function get_invoice_guid(): ?string { 222 return $this->InvoiceGuid; 223 } 224 225 /** 226 * @return string|null 227 */ 228 public function get_currency(): ?string { 229 return $this->Currency; 230 } 231 232 /** 233 * @return string|null 234 */ 235 public function get_language(): ?string { 236 return $this->Language; 237 } 238 239 /** 240 * @return string|null 241 */ 242 public function get_external_reference(): ?string { 243 return $this->ExternalReference; 426 * @return string|null 427 */ 428 public function get_payment_condition_type(): ?string { 429 return $this->PaymentConditionType; 430 } 431 432 /** 433 * @param string|null $FikCode 434 * 435 * @return Invoice 436 */ 437 public function set_fik_code( ?string $FikCode ): self { 438 $this->FikCode = $FikCode; 439 440 return $this; 441 } 442 443 /** 444 * @return string|null 445 */ 446 public function get_fik_code(): ?string { 447 return $this->FikCode; 448 } 449 450 /** 451 * @param int|null $DepositAccountNumber 452 * 453 * @return Invoice 454 */ 455 public function set_deposit_account_number( ?int $DepositAccountNumber ): self { 456 $this->DepositAccountNumber = $DepositAccountNumber; 457 458 return $this; 459 } 460 461 /** 462 * @return int|null 463 */ 464 public function get_deposit_account_number(): ?int { 465 return $this->DepositAccountNumber; 466 } 467 468 /** 469 * @param string|null $LatestMailOutType 470 * 471 * @return Invoice 472 */ 473 public function set_latest_mail_out_type( ?string $LatestMailOutType ): self { 474 $this->LatestMailOutType = $LatestMailOutType; 475 476 return $this; 477 } 478 479 /** 480 * @return string|null 481 */ 482 public function get_latest_mail_out_type(): ?string { 483 return $this->LatestMailOutType; 484 } 485 486 /** 487 * @param string|null $Description 488 * 489 * @return Invoice 490 */ 491 public function set_description( ?string $Description ): self { 492 $this->Description = $Description; 493 494 return $this; 244 495 } 245 496 … … 252 503 253 504 /** 505 * @param string|null $Comment 506 * 507 * @return Invoice 508 */ 509 public function set_comment( ?string $Comment ): self { 510 $this->Comment = $Comment; 511 512 return $this; 513 } 514 515 /** 254 516 * @return string|null 255 517 */ … … 259 521 260 522 /** 261 * @param null $format 262 * 263 * @return DateTime|string|null 264 */ 265 public function get_date( $format = null ) { 266 if ( $this->Date instanceof DateTime && ! empty( $format ) ) { 267 return $this->Date->format( $format ); 268 } 269 270 return $this->Date; 271 } 272 273 /** 274 * @return ProductLine[] 275 */ 276 public function get_product_lines(): array { 277 return $this->ProductLines; 523 * @param string|null $Address 524 * 525 * @return Invoice 526 */ 527 public function set_address( ?string $Address ): self { 528 $this->Address = $Address; 529 530 return $this; 278 531 } 279 532 … … 286 539 287 540 /** 541 * @param int|null $Number 542 * 543 * @return Invoice 544 */ 545 public function set_number( ?int $Number ): self { 546 $this->Number = $Number; 547 548 return $this; 549 } 550 551 /** 552 * @return int|null 553 */ 554 public function get_number(): ?int { 555 return $this->Number; 556 } 557 558 /** 559 * @param string|null $ContactName 560 * 561 * @return Invoice 562 */ 563 public function set_contact_name( ?string $ContactName ): self { 564 $this->ContactName = $ContactName; 565 566 return $this; 567 } 568 569 /** 570 * @return string|null 571 */ 572 public function get_contact_name(): ?string { 573 return $this->ContactName; 574 } 575 576 /** 577 * @param string|null $ShowLinesInclVat 578 * 579 * @return Invoice 580 */ 581 public function set_show_lines_incl_vat( ?string $ShowLinesInclVat ): self { 582 $this->ShowLinesInclVat = $ShowLinesInclVat; 583 584 return $this; 585 } 586 587 /** 588 * @return string|null 589 */ 590 public function get_show_lines_incl_vat(): ?string { 591 return $this->ShowLinesInclVat; 592 } 593 594 /** 595 * @param ProductLine[]|null $ProductLines 596 * 597 * @return Invoice 598 */ 599 public function set_product_lines( ?array $ProductLines ): self { 600 $this->ProductLines = $ProductLines; 601 602 return $this; 603 } 604 605 /** 606 * @return ProductLine[]|null 607 */ 608 public function get_product_lines(): ?array { 609 return $this->ProductLines; 610 } 611 612 /** 613 * @param array|null $TotalLines 614 * 615 * @return Invoice 616 */ 617 public function set_total_lines( ?array $TotalLines ): self { 618 $this->TotalLines = $TotalLines; 619 620 return $this; 621 } 622 623 /** 624 * @return array|null 625 */ 626 public function get_total_lines(): ?array { 627 return $this->TotalLines; 628 } 629 630 /** 631 * @param float|null $TotalExclVat 632 * 633 * @return Invoice 634 */ 635 public function set_total_excl_vat( ?float $TotalExclVat ): self { 636 $this->TotalExclVat = $TotalExclVat; 637 638 return $this; 639 } 640 641 /** 642 * @return float|null 643 */ 644 public function get_total_excl_vat(): ?float { 645 return $this->TotalExclVat; 646 } 647 648 /** 649 * @param float|null $TotalVatableAmount 650 * 651 * @return Invoice 652 */ 653 public function set_total_vatable_amount( ?float $TotalVatableAmount ): self { 654 $this->TotalVatableAmount = $TotalVatableAmount; 655 656 return $this; 657 } 658 659 /** 660 * @return float|null 661 */ 662 public function get_total_vatable_amount(): ?float { 663 return $this->TotalVatableAmount; 664 } 665 666 /** 667 * @param float|null $TotalInclVat 668 * 669 * @return Invoice 670 */ 671 public function set_total_incl_vat( ?float $TotalInclVat ): self { 672 $this->TotalInclVat = $TotalInclVat; 673 674 return $this; 675 } 676 677 /** 678 * @return float|null 679 */ 680 public function get_total_incl_vat(): ?float { 681 return $this->TotalInclVat; 682 } 683 684 /** 685 * @param float|null $TotalNonVatableAmount 686 * 687 * @return Invoice 688 */ 689 public function set_total_non_vatable_amount( ?float $TotalNonVatableAmount ): self { 690 $this->TotalNonVatableAmount = $TotalNonVatableAmount; 691 692 return $this; 693 } 694 695 /** 696 * @return float|null 697 */ 698 public function get_total_non_vatable_amount(): ?float { 699 return $this->TotalNonVatableAmount; 700 } 701 702 /** 703 * @param float|null $TotalVat 704 * 705 * @return Invoice 706 */ 707 public function set_total_vat( ?float $TotalVat ): self { 708 $this->TotalVat = $TotalVat; 709 710 return $this; 711 } 712 713 /** 714 * @return float|null 715 */ 716 public function get_total_vat(): ?float { 717 return $this->TotalVat; 718 } 719 720 /** 721 * @param bool $IsSentToDebtCollection 722 * 723 * @return Invoice 724 */ 725 public function set_is_sent_to_debt_collection( bool $IsSentToDebtCollection ): self { 726 $this->IsSentToDebtCollection = $IsSentToDebtCollection; 727 728 return $this; 729 } 730 731 /** 288 732 * @return bool 289 733 */ 290 public function is_show_lines_incl_vat(): bool { 291 return $this->ShowLinesInclVat; 292 } 293 294 /** 295 * @return string|null 296 */ 297 public function get_invoice_template_id(): ?string { 298 return $this->InvoiceTemplateId; 299 } 300 301 /** 302 * @return string|null 303 */ 304 public function get_contact_guid(): ?string { 305 return $this->ContactGuid; 306 } 307 308 /** 309 * @return int|null 310 */ 311 public function get_payment_condition_number_of_days(): ?int { 312 return $this->PaymentConditionNumberOfDays; 313 } 314 315 /** 316 * @return string|null 317 */ 318 public function get_payment_condition_type(): ?string { 319 return $this->PaymentConditionType; 734 public function is_sent_to_debt_collection(): bool { 735 return $this->IsSentToDebtCollection; 736 } 737 738 /** 739 * @param bool $IsMobilePayInvoiceEnabled 740 * 741 * @return Invoice 742 */ 743 public function set_is_mobile_pay_invoice_enabled( bool $IsMobilePayInvoiceEnabled ): self { 744 $this->IsMobilePayInvoiceEnabled = $IsMobilePayInvoiceEnabled; 745 746 return $this; 320 747 } 321 748 … … 323 750 * @return bool 324 751 */ 325 public function is_ is_mobile_pay_invoice_enabled(): bool {752 public function is_mobile_pay_invoice_enabled(): bool { 326 753 return $this->IsMobilePayInvoiceEnabled; 327 754 } 755 328 756 329 757 public function jsonSerialize() { 330 758 $vars = get_object_vars( $this ); 331 759 $vars['Date'] = $this->get_date( 'Y-m-d' ); 760 $vars = Util::filter_null_from( $vars ); 332 761 333 762 return $vars; -
miqid-woo/trunk/src/Includes/Dinero/DTO/Product.php
r2469411 r2495913 6 6 7 7 class Product extends DTO { 8 const WithVAT = 1000; 9 const WithoutVAT = 1050; 10 8 11 /** @var string|null */ 9 12 protected $ProductGuid; -
miqid-woo/trunk/src/Includes/Dinero/DTO/ProductLine.php
r2469411 r2495913 4 4 5 5 use MIQID\Plugin\WooCommerce\Includes\Dinero\DTO; 6 use MIQID\Plugin\WooCommerce\Util; 6 7 7 8 class ProductLine extends DTO { … … 233 234 public function jsonSerialize() { 234 235 $vars = get_object_vars( $this ); 236 $vars = Util::filter_null_from( $vars ); 235 237 236 238 return $vars; -
miqid-woo/trunk/src/Includes/EConomic/API/Base.php
r2469411 r2495913 10 10 abstract static function Instance(); 11 11 12 protected function RemoteGet( $url, array $headers = [], array $args = [] ): ?HttpResponse {12 protected function RemoteGet( $url, array $headers = [], array $args = [] ): HttpResponse { 13 13 14 14 $headers = wp_parse_args( $headers, [ … … 26 26 } 27 27 28 protected function RemotePost( $url, $body = null, array $headers = [], array $args = [] ): ?HttpResponse {28 protected function RemotePost( $url, $body = null, array $headers = [], array $args = [] ): HttpResponse { 29 29 30 30 if ( is_array( $body ) || is_object( $body ) ) { -
miqid-woo/trunk/src/Includes/EConomic/API/Orders.php
r2469411 r2495913 47 47 function GetDrafts( $orderNumber = null, $filter = null ) { 48 48 $HttpResponse = $this->RemoteGet( 49 implode( DIRECTORY_SEPARATOR, array_filter( [ $this->GetEndpoint( 'orders/drafts' ), $orderNumber , $filter ] ) )49 implode( DIRECTORY_SEPARATOR, array_filter( [ $this->GetEndpoint( 'orders/drafts' ), $orderNumber ] ) ) . $filter 50 50 ); 51 51 … … 98 98 return $HttpResponse; 99 99 } 100 101 function PostSent( Order $order ) { 102 $HttpResponse = $this->RemotePost( 103 implode( DIRECTORY_SEPARATOR, array_filter( [ $this->GetEndpoint( 'orders/sent' ) ] ) ), 104 $order 105 ); 106 107 if ( in_array( $HttpResponse->get_response_code(), [ 200, 201, 202 ] ) ) { 108 return new Order( $HttpResponse->get_body() ); 109 } 110 111 return $HttpResponse; 112 } 100 113 } -
miqid-woo/trunk/src/Includes/EConomic/API/ProductGroups.php
r2469411 r2495913 8 8 class ProductGroups extends Base { 9 9 private static $_instance; 10 11 const Product_With_Vat = 1; 12 const Product_Without_Vat = 2; 10 13 11 14 public static function Instance() { -
miqid-woo/trunk/src/Includes/EConomic/DTO/Account.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 … … 19 18 /** @var bool */ 20 19 private $blockDirectEntries; 21 /** @var array|null */20 /** @var Account|null */ 22 21 private $contraAccount; 23 22 /** @var string|null */ 24 23 private $debitCredit; 24 /** @var string|null */ 25 private $name; 25 26 /** @var array|null */ 26 27 private $vatAccount; 27 28 /** @var array|null */ 28 29 private $accountsSummed; 29 /** @var array|null */30 /** @var Account|null */ 30 31 private $totalFromAccount; 31 32 /** @var string|null */ 32 33 private $accountingYears; 33 34 /** 35 * Account constructor. 36 * 37 * @param int|array|null $accountNumber 38 * @param string|null $accountType 39 * @param float|null $balance 40 * @param float|null $draftBalance 41 * @param bool|null $barred 42 * @param bool|null $blockDirectEntries 43 * @param array|null $contraAccount 44 * @param string|null $debitCredit 45 * @param string|null $name 46 * @param array|null $vatAccount 47 * @param array|null $accountsSummed 48 * @param array|null $totalFromAccount 49 * @param array|null $accountingYears 50 * @param null $self 51 */ 52 public function __construct( 53 $accountNumber = null, 54 $accountType = null, 55 $balance = null, 56 $draftBalance = null, 57 $barred = null, 58 $blockDirectEntries = null, 59 $contraAccount = null, 60 $debitCredit = null, 61 $name = null, 62 $vatAccount = null, 63 $accountsSummed = null, 64 $totalFromAccount = null, 65 $accountingYears = null, 66 $self = null 67 ) { 68 if ( is_array( $accountNumber ) ) { 69 $this->parse_array( $accountNumber ); 70 } 71 72 $this->set_account_type( $accountType ); 73 $this->set_balance( $balance ); 74 $this->set_draft_balance( $draftBalance ); 75 $this->set_barred( $barred ); 76 $this->set_block_direct_entries( $blockDirectEntries ); 77 $this->set_contra_account( $contraAccount ); 78 $this->set_debit_credit( $debitCredit ); 79 $this->set_vat_account( $vatAccount ); 80 $this->set_accounts_summed( $accountsSummed ); 81 $this->set_total_from_account( $totalFromAccount ); 82 $this->set_accounting_years( $accountingYears ); 34 /** @var string|null */ 35 private $self; 36 37 public function __construct( ?array $Account = null ) { 38 if ( is_array( $Account ) ) { 39 $this->parse_array( $Account ); 40 } 83 41 } 84 42 … … 87 45 */ 88 46 public function set_account_number( ?int $accountNumber ): void { 89 $this->accountNumber = $accountNumber ?? $this->accountNumber; 90 } 91 92 /** 93 * @param string|null $accountType 94 */ 95 public function set_account_type( ?string $accountType ): void { 96 $this->accountType = $accountType ?? $this->accountType; 97 } 98 99 /** 100 * @param float|null $balance 101 */ 102 public function set_balance( ?float $balance ): void { 103 $this->balance = $balance ?? $this->balance; 104 } 105 106 /** 107 * @param float|null $draftBalance 108 */ 109 public function set_draft_balance( ?float $draftBalance ): void { 110 $this->draftBalance = $draftBalance ?? $this->draftBalance; 111 } 112 113 /** 114 * @param bool|null $barred 115 */ 116 public function set_barred( ?bool $barred ): void { 117 $this->barred = filter_var( $barred, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) ?? $this->barred; 118 } 119 120 /** 121 * @param bool|null $blockDirectEntries 122 */ 123 public function set_block_direct_entries( ?bool $blockDirectEntries ): void { 124 $this->blockDirectEntries = filter_var( $blockDirectEntries, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) ?? $this->blockDirectEntries; 125 } 126 127 /** 128 * @param array|null $contraAccount 129 */ 130 public function set_contra_account( ?array $contraAccount ): void { 131 $this->contraAccount = $contraAccount ?? $this->contraAccount; 132 } 133 134 /** 135 * @param string|null $debitCredit 136 */ 137 public function set_debit_credit( ?string $debitCredit ): void { 138 $this->debitCredit = $debitCredit ?? $this->debitCredit; 139 } 140 141 /** 142 * @param array|null $vatAccount 143 */ 144 public function set_vat_account( ?array $vatAccount ): void { 145 $this->vatAccount = $vatAccount ?? $this->vatAccount; 146 } 147 148 /** 149 * @param array|null $accountsSummed 150 */ 151 public function set_accounts_summed( ?array $accountsSummed ): void { 152 $this->accountsSummed = $accountsSummed ?? $this->accountsSummed; 153 } 154 155 /** 156 * @param array|null $totalFromAccount 157 */ 158 public function set_total_from_account( ?array $totalFromAccount ): void { 159 $this->totalFromAccount = $totalFromAccount ?? $this->totalFromAccount; 160 } 161 162 /** 163 * @param string|null $accountingYears 164 */ 165 public function set_accounting_years( ?string $accountingYears ): void { 166 $this->accountingYears = $accountingYears ?? $this->accountingYears; 47 $this->accountNumber = $accountNumber; 167 48 } 168 49 … … 175 56 176 57 /** 58 * @param string|null $accountType 59 */ 60 public function set_account_type( ?string $accountType ): void { 61 $this->accountType = $accountType; 62 } 63 64 /** 177 65 * @return string|null 178 66 */ … … 182 70 183 71 /** 72 * @param float|null $balance 73 */ 74 public function set_balance( ?float $balance ): void { 75 $this->balance = $balance; 76 } 77 78 /** 184 79 * @return float|null 185 80 */ … … 189 84 190 85 /** 86 * @param float|null $draftBalance 87 */ 88 public function set_draft_balance( ?float $draftBalance ): void { 89 $this->draftBalance = $draftBalance; 90 } 91 92 /** 191 93 * @return float|null 192 94 */ … … 196 98 197 99 /** 100 * @param bool|int|string|null $barred 101 */ 102 public function set_barred( $barred ): void { 103 if ( ! is_null( $barred ) ) { 104 $barred = filter_var( $barred, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 105 } 106 $this->barred = $barred; 107 } 108 109 /** 198 110 * @return bool 199 111 */ … … 203 115 204 116 /** 117 * @param bool|int|string|null $blockDirectEntries 118 */ 119 public function set_block_direct_entries( $blockDirectEntries ): void { 120 if ( ! is_null( $blockDirectEntries ) ) { 121 $blockDirectEntries = filter_var( $blockDirectEntries, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 122 } 123 $this->blockDirectEntries = $blockDirectEntries; 124 } 125 126 /** 205 127 * @return bool 206 128 */ … … 210 132 211 133 /** 212 * @return array|null 213 */ 214 public function get_contra_account(): ?array { 215 return $this->contraAccount; 134 * @param array|Account|null $contraAccount 135 */ 136 public function set_contra_account( $contraAccount ): void { 137 if ( is_array( $contraAccount ) ) { 138 $contraAccount = new Account( $contraAccount ); 139 } 140 $this->contraAccount = $contraAccount; 141 } 142 143 /** 144 * @return Account|null 145 */ 146 public function get_contra_account(): ?Account { 147 return $this->contraAccount ?? new Account(); 148 } 149 150 /** 151 * @param string|null $debitCredit 152 */ 153 public function set_debit_credit( ?string $debitCredit ): void { 154 $this->debitCredit = $debitCredit; 216 155 } 217 156 … … 224 163 225 164 /** 165 * @param array|null $vatAccount 166 */ 167 public function set_vat_account( ?array $vatAccount ): void { 168 $this->vatAccount = $vatAccount; 169 } 170 171 /** 226 172 * @return array|null 227 173 */ … … 231 177 232 178 /** 179 * @param array|null $accountsSummed 180 */ 181 public function set_accounts_summed( ?array $accountsSummed ): void { 182 $this->accountsSummed = $accountsSummed; 183 } 184 185 /** 233 186 * @return array|null 234 187 */ … … 238 191 239 192 /** 240 * @return array|null 241 */ 242 public function get_total_from_account(): ?array { 243 return $this->totalFromAccount; 193 * @param array|Account|null $totalFromAccount 194 */ 195 public function set_total_from_account( $totalFromAccount ): void { 196 if ( is_array( $totalFromAccount ) ) { 197 $totalFromAccount = new Account( $totalFromAccount ); 198 } 199 $this->totalFromAccount = $totalFromAccount; 200 } 201 202 /** 203 * @return Account|null 204 */ 205 public function get_total_from_account(): Account { 206 return $this->totalFromAccount ?? new Account(); 207 } 208 209 /** 210 * @param string|null $accountingYears 211 */ 212 public function set_accounting_years( ?string $accountingYears ): void { 213 $this->accountingYears = $accountingYears; 244 214 } 245 215 … … 252 222 253 223 public function jsonSerialize(): array { 254 $vars = get_object_vars( $this );255 $vars = Util::filter_null_from( $vars );224 $vars = get_object_vars( $this ); 225 $vars = Util::filter_null_from( $vars ); 256 226 257 227 return $vars; -
miqid-woo/trunk/src/Includes/EConomic/DTO/Accrual.php
r2469411 r2495913 4 4 5 5 use DateTime; 6 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;7 6 use MIQID\Plugin\WooCommerce\Util; 8 7 -
miqid-woo/trunk/src/Includes/EConomic/DTO/Attention.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 -
miqid-woo/trunk/src/Includes/EConomic/DTO/Currency.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 -
miqid-woo/trunk/src/Includes/EConomic/DTO/Customer.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 … … 58 57 private $zip; 59 58 60 public function __construct( 61 $customerNumber = null, 62 $address = null, 63 $balance = null, 64 $barred = null, 65 $city = null, 66 $corporateIdentificationNumber = null, 67 $country = null, 68 $creditLimit = null, 69 $currency = null, 70 $customerGroup = null, 71 $ean = null, 72 $eInvoicingDisabledByDefault = null, 73 $email = null, 74 $layout = null, 75 $mobilePhone = null, 76 $name = null, 77 $paymentTerms = null, 78 $pNumber = null, 79 $publicEntryNumber = null, 80 $salesPerson = null, 81 $telephoneAndFaxNumber = null, 82 $vatNumber = null, 83 $vatZone = null, 84 $website = null, 85 $zip = null, 86 $self = null 87 ) { 88 parent::__construct( $self ); 89 if ( is_array( $customerNumber ) ) { 90 $this->parse_array( $customerNumber ); 91 } 92 93 $this->set_customer_number( $customerNumber ); 94 $this->set_address( $address ); 95 $this->set_balance( $balance ); 96 $this->set_barred( $barred ); 97 $this->set_city( $city ); 98 $this->set_corporate_identification_number( $corporateIdentificationNumber ); 99 $this->set_country( $country ); 100 $this->set_credit_limit( $creditLimit ); 101 $this->set_currency( $currency ); 102 $this->set_customer_group( $customerGroup ); 103 $this->set_ean( $ean ); 104 $this->set_e_invoicing_disabled_by_default( $eInvoicingDisabledByDefault ); 105 $this->set_email( $email ); 106 $this->set_layout( $layout ); 107 $this->set_mobile_phone( $mobilePhone ); 108 $this->set_name( $name ); 109 $this->set_payment_terms( $paymentTerms ); 110 $this->set_p_number( $pNumber ); 111 $this->set_public_entry_number( $publicEntryNumber ); 112 $this->set_sales_person( $salesPerson ); 113 $this->set_telephone_and_fax_number( $telephoneAndFaxNumber ); 114 $this->set_vat_number( $vatNumber ); 115 $this->set_vat_zone( $vatZone ); 116 $this->set_website( $website ); 117 $this->set_zip( $zip ); 59 public function __construct( ?array $Customer = null ) { 60 if ( is_array( $Customer ) ) { 61 $this->parse_array( $Customer ); 62 } 118 63 } 119 64 120 65 /** 121 66 * @param string|null $address 122 */ 123 public function set_address( ?string $address ): void { 124 $this->address = $address ?? $this->address; 67 * 68 * @return Customer 69 */ 70 public function set_address( ?string $address ): self { 71 $this->address = $address; 72 73 return $this; 125 74 } 126 75 127 76 /** 128 77 * @param int|null $balance 129 */ 130 public function set_balance( ?int $balance ): void { 131 $this->balance = $balance ?? $this->balance; 78 * 79 * @return Customer 80 */ 81 public function set_balance( ?int $balance ): self { 82 $this->balance = $balance; 83 84 return $this; 132 85 } 133 86 134 87 /** 135 88 * @param bool|null $barred 136 */ 137 public function set_barred( ?bool $barred ): void { 138 $this->barred = $barred ?? $this->barred; 89 * 90 * @return Customer 91 */ 92 public function set_barred( ?bool $barred ): self { 93 $this->barred = $barred; 94 95 return $this; 139 96 } 140 97 141 98 /** 142 99 * @param string $city 143 */ 144 public function set_city( ?string $city ): void { 145 $this->city = $city ?? $this->city; 100 * 101 * @return Customer 102 */ 103 public function set_city( ?string $city ): self { 104 $this->city = $city; 105 106 return $this; 146 107 } 147 108 148 109 /** 149 110 * @param string $corporateIdentificationNumber 150 */ 151 public function set_corporate_identification_number( ?string $corporateIdentificationNumber ): void { 152 $this->corporateIdentificationNumber = $corporateIdentificationNumber ?? $this->corporateIdentificationNumber; 111 * 112 * @return Customer 113 */ 114 public function set_corporate_identification_number( ?string $corporateIdentificationNumber ): self { 115 $this->corporateIdentificationNumber = $corporateIdentificationNumber; 116 117 return $this; 153 118 } 154 119 155 120 /** 156 121 * @param string $country 157 */ 158 public function set_country( ?string $country ): void { 159 $this->country = $country ?? $this->country; 122 * 123 * @return Customer 124 */ 125 public function set_country( ?string $country ): self { 126 $this->country = $country; 127 128 return $this; 160 129 } 161 130 162 131 /** 163 132 * @param int|null $creditLimit 164 */ 165 public function set_credit_limit( ?int $creditLimit ): void { 166 $this->creditLimit = $creditLimit ?? $this->creditLimit; 133 * 134 * @return Customer 135 */ 136 public function set_credit_limit( ?int $creditLimit ): self { 137 $this->creditLimit = $creditLimit; 138 139 return $this; 167 140 } 168 141 169 142 /** 170 143 * @param Currency|array|string|null $currency 171 */ 172 public function set_currency( $currency ): void { 144 * 145 * @return Customer 146 */ 147 public function set_currency( $currency ): self { 173 148 if ( is_array( $currency ) || is_string( $currency ) ) { 174 149 $currency = new Currency( $currency ); 175 150 } 176 $this->currency = $currency ?? $this->currency; 151 $this->currency = $currency; 152 153 return $this; 177 154 } 178 155 179 156 /** 180 157 * @param array|CustomerGroup $customerGroup 181 */ 182 public function set_customer_group( $customerGroup ): void { 158 * 159 * @return Customer 160 */ 161 public function set_customer_group( $customerGroup ): self { 183 162 if ( is_array( $customerGroup ) ) { 184 163 $customerGroup = new CustomerGroup( $customerGroup ); 185 164 } 186 $this->customerGroup = $customerGroup ?? $this->customerGroup; 165 $this->customerGroup = $customerGroup; 166 167 return $this; 187 168 } 188 169 189 170 /** 190 171 * @param int|null $customerNumber 191 */ 192 public function set_customer_number( ?int $customerNumber ): void { 193 $this->customerNumber = $customerNumber ?? $this->customerNumber; 172 * 173 * @return Customer 174 */ 175 public function set_customer_number( ?int $customerNumber ): self { 176 $this->customerNumber = $customerNumber; 177 178 return $this; 194 179 } 195 180 196 181 /** 197 182 * @param string $ean 198 */ 199 public function set_ean( ?string $ean ): void { 200 $this->ean = $ean ?? $this->ean; 183 * 184 * @return Customer 185 */ 186 public function set_ean( ?string $ean ): self { 187 $this->ean = $ean; 188 189 return $this; 201 190 } 202 191 203 192 /** 204 193 * @param bool|null $eInvoicingDisabledByDefault 205 */ 206 public function set_e_invoicing_disabled_by_default( ?bool $eInvoicingDisabledByDefault ): void { 207 $this->eInvoicingDisabledByDefault = $eInvoicingDisabledByDefault ?? $this->eInvoicingDisabledByDefault; 194 * 195 * @return Customer 196 */ 197 public function set_e_invoicing_disabled_by_default( ?bool $eInvoicingDisabledByDefault ): self { 198 $this->eInvoicingDisabledByDefault = $eInvoicingDisabledByDefault; 199 200 return $this; 208 201 } 209 202 210 203 /** 211 204 * @param string $email 212 */ 213 public function set_email( ?string $email ): void { 214 $this->email = $email ?? $this->email; 205 * 206 * @return Customer 207 */ 208 public function set_email( ?string $email ): self { 209 $this->email = $email; 210 211 return $this; 215 212 } 216 213 217 214 /** 218 215 * @param array|Layout $layout 219 */ 220 public function set_layout( $layout ): void { 216 * 217 * @return Customer 218 */ 219 public function set_layout( $layout ): self { 221 220 if ( is_array( $layout ) ) { 222 221 $layout = new Layout( $layout ); 223 222 } 224 $this->layout = $layout ?? $this->layout; 223 $this->layout = $layout; 224 225 return $this; 225 226 } 226 227 227 228 /** 228 229 * @param string $mobilePhone 229 */ 230 public function set_mobile_phone( ?string $mobilePhone ): void { 231 $this->mobilePhone = $mobilePhone ?? $this->mobilePhone; 230 * 231 * @return Customer 232 */ 233 public function set_mobile_phone( ?string $mobilePhone ): self { 234 $this->mobilePhone = $mobilePhone; 235 236 return $this; 232 237 } 233 238 234 239 /** 235 240 * @param string $name 236 */ 237 public function set_name( ?string $name ): void { 238 $this->name = $name ?? $this->name; 241 * 242 * @return Customer 243 */ 244 public function set_name( ?string $name ): self { 245 $this->name = $name; 246 247 return $this; 239 248 } 240 249 241 250 /** 242 251 * @param array|PaymentTerm $paymentTerms 243 */ 244 public function set_payment_terms( $paymentTerms ): void { 252 * 253 * @return Customer 254 */ 255 public function set_payment_terms( $paymentTerms ): self { 245 256 if ( is_array( $paymentTerms ) ) { 246 257 $paymentTerms = new PaymentTerm( $paymentTerms ); 247 258 } 248 $this->paymentTerms = $paymentTerms ?? $this->paymentTerms; 259 $this->paymentTerms = $paymentTerms; 260 261 return $this; 249 262 } 250 263 251 264 /** 252 265 * @param string $pNumber 253 */ 254 public function set_p_number( ?string $pNumber ): void { 255 $this->pNumber = $pNumber ?? $this->pNumber; 266 * 267 * @return Customer 268 */ 269 public function set_p_number( ?string $pNumber ): self { 270 $this->pNumber = $pNumber; 271 272 return $this; 256 273 } 257 274 258 275 /** 259 276 * @param string $publicEntryNumber 260 */ 261 public function set_public_entry_number( ?string $publicEntryNumber ): void { 262 $this->publicEntryNumber = $publicEntryNumber ?? $this->publicEntryNumber; 277 * 278 * @return Customer 279 */ 280 public function set_public_entry_number( ?string $publicEntryNumber ): self { 281 $this->publicEntryNumber = $publicEntryNumber; 282 283 return $this; 263 284 } 264 285 265 286 /** 266 287 * @param array|SalesPerson $salesPerson 267 */ 268 public function set_sales_person( $salesPerson ): void { 288 * 289 * @return Customer 290 */ 291 public function set_sales_person( $salesPerson ): self { 269 292 if ( is_array( $salesPerson ) ) { 270 293 $salesPerson = new SalesPerson( $salesPerson ); 271 294 } 272 $this->salesPerson = $salesPerson ?? $this->salesPerson; 295 $this->salesPerson = $salesPerson; 296 297 return $this; 273 298 } 274 299 275 300 /** 276 301 * @param string $telephoneAndFaxNumber 277 */ 278 public function set_telephone_and_fax_number( ?string $telephoneAndFaxNumber ): void { 279 $this->telephoneAndFaxNumber = $telephoneAndFaxNumber ?? $this->telephoneAndFaxNumber; 302 * 303 * @return Customer 304 */ 305 public function set_telephone_and_fax_number( ?string $telephoneAndFaxNumber ): self { 306 $this->telephoneAndFaxNumber = $telephoneAndFaxNumber; 307 308 return $this; 280 309 } 281 310 282 311 /** 283 312 * @param string $vatNumber 284 */ 285 public function set_vat_number( ?string $vatNumber ): void { 286 $this->vatNumber = $vatNumber ?? $this->vatNumber; 313 * 314 * @return Customer 315 */ 316 public function set_vat_number( ?string $vatNumber ): self { 317 $this->vatNumber = $vatNumber; 318 319 return $this; 287 320 } 288 321 289 322 /** 290 323 * @param array|VatZone $vatZone 291 */ 292 public function set_vat_zone( $vatZone ): void { 324 * 325 * @return Customer 326 */ 327 public function set_vat_zone( $vatZone ): self { 293 328 if ( is_array( $vatZone ) ) { 294 329 $vatZone = new VatZone( $vatZone ); 295 330 } 296 $this->vatZone = $vatZone ?? $this->vatZone; 331 $this->vatZone = $vatZone; 332 333 return $this; 297 334 } 298 335 299 336 /** 300 337 * @param string $website 301 */ 302 public function set_website( ?string $website ): void { 303 $this->website = $website ?? $this->website; 338 * 339 * @return Customer 340 */ 341 public function set_website( ?string $website ): self { 342 $this->website = $website; 343 344 return $this; 304 345 } 305 346 306 347 /** 307 348 * @param string $zip 308 */ 309 public function set_zip( ?string $zip ): void { 310 $this->zip = $zip ?? $this->zip; 349 * 350 * @return Customer 351 */ 352 public function set_zip( ?string $zip ): self { 353 $this->zip = $zip; 354 355 return $this; 311 356 } 312 357 … … 489 534 $vars = get_object_vars( $this ); 490 535 $vars['currency'] = $this->get_currency()->get_code(); 491 //$vars['self'] = $this->get_self();492 536 $vars = Util::filter_null_from( $vars ); 493 537 -
miqid-woo/trunk/src/Includes/EConomic/DTO/CustomerGroup.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 … … 13 12 /** @var Account|null */ 14 13 private $account; 15 /** @var Customer|string|null */14 /** @var string|null */ 16 15 private $customers; 17 16 /** @var Layout|null */ 18 17 private $layout; 18 /** @var string|null */ 19 private $self; 19 20 20 21 public function __construct( … … 26 27 $self = null 27 28 ) { 28 parent::__construct( $self );29 30 29 if ( is_array( $customerGroupNumber ) ) { 31 30 $this->parse_array( $customerGroupNumber ); 32 31 } 33 34 $this->set_customer_group_number( $customerGroupNumber ); 35 $this->set_name( $name ); 36 $this->set_account( $account ); 37 $this->set_customers( $customers ); 38 $this->set_layout( $layout ); 32 if ( isset( $customerGroupNumber ) ) { 33 $this->set_customer_group_number( $customerGroupNumber ); 34 } 35 if ( isset( $name ) ) { 36 $this->set_name( $name ); 37 } 38 if ( isset( $account ) ) { 39 $this->set_account( $account ); 40 } 41 if ( isset( $customers ) ) { 42 $this->set_customers( $customers ); 43 } 44 if ( isset( $layout ) ) { 45 $this->set_layout( $layout ); 46 } 47 if ( isset( $self ) ) { 48 $this->set_self( $self ); 49 } 39 50 } 40 51 41 52 /** 42 53 * @param int|null $customerGroupNumber 54 * 55 * @return CustomerGroup 43 56 */ 44 public function set_customer_group_number( ?int $customerGroupNumber ): void { 45 $this->customerGroupNumber = $customerGroupNumber ?? $this->customerGroupNumber; 46 } 57 public function set_customer_group_number( ?int $customerGroupNumber ): CustomerGroup { 58 $this->customerGroupNumber = $customerGroupNumber; 47 59 48 /** 49 * @param string|null $name 50 */ 51 public function set_name( ?string $name ): void { 52 $this->name = $name ?? $this->name; 53 } 54 55 /** 56 * @param Account|array|null $account 57 */ 58 public function set_account( $account ): void { 59 if ( is_array( $account ) ) { 60 $account = new Account( $account ); 61 } 62 $this->account = $account ?? $this->account; 63 } 64 65 /** 66 * @param Customer|array|string|null $customers 67 */ 68 public function set_customers( $customers ): void { 69 if ( is_array( $customers ) ) { 70 $customers = new Customer( $customers ); 71 } 72 $this->customers = $customers ?? $this->customers; 73 } 74 75 /** 76 * @param Layout|array|null $layout 77 */ 78 public function set_layout( $layout ): void { 79 if ( is_array( $layout ) ) { 80 $layout = new Layout( $layout ); 81 } 82 $this->layout = $layout ?? $this->layout; 60 return $this; 83 61 } 84 62 … … 91 69 92 70 /** 93 * @return string|null 71 * @param array|Account|null $account 72 * 73 * @return CustomerGroup 94 74 */ 95 public function get_name(): ?string { 96 return $this->name; 75 public function set_account( $account ): CustomerGroup { 76 if ( is_array( $account ) ) { 77 $account = new Account( $account ); 78 } 79 $this->account = $account; 80 81 return $this; 97 82 } 98 83 99 84 /** 100 * @return Account |null85 * @return Account 101 86 */ 102 87 public function get_account(): Account { … … 105 90 106 91 /** 107 * @return Customer|string 92 * @param string|null $customers 93 * 94 * @return CustomerGroup 108 95 */ 109 public function get_customers() { 110 return $this->customers ?? new Customer(); 96 public function set_customers( ?string $customers ): CustomerGroup { 97 $this->customers = $customers; 98 99 return $this; 111 100 } 112 101 113 102 /** 114 * @return Layout|null 103 * @return string|null 104 */ 105 public function get_customers(): ?string { 106 return $this->customers; 107 } 108 109 /** 110 * @param array|Layout|null $layout 111 * 112 * @return CustomerGroup 113 */ 114 public function set_layout( $layout ): CustomerGroup { 115 if ( is_array( $layout ) ) { 116 $layout = new Layout( $layout ); 117 } 118 $this->layout = $layout; 119 120 return $this; 121 } 122 123 /** 124 * @return Layout 115 125 */ 116 126 public function get_layout(): Layout { … … 119 129 120 130 public function jsonSerialize(): array { 121 $arr = get_object_vars( $this ); 122 //$arr['self'] = $this->get_self(); 123 $arr = Util::filter_null_from( $arr ); 131 $arr = get_object_vars( $this ); 132 $arr = Util::filter_null_from( $arr ); 124 133 125 134 return $arr; -
miqid-woo/trunk/src/Includes/EConomic/DTO/Delivery.php
r2469411 r2495913 4 4 5 5 use DateTime; 6 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;7 6 use MIQID\Plugin\WooCommerce\Util; 8 7 … … 21 20 private $zip; 22 21 22 public function __construct( ?array $Delivery = null ) { 23 if ( is_array( $Delivery ) ) { 24 $this->parse_array( $Delivery ); 25 } 26 } 27 28 23 29 /** 24 30 * @param string|null $address 25 31 */ 26 32 public function set_address( ?string $address ): void { 27 $this->address = $address ?? $this->address; 28 } 29 30 /** 31 * @param string|null $city 32 */ 33 public function set_city( ?string $city ): void { 34 $this->city = $city ?? $this->city; 35 } 36 37 /** 38 * @param string|null $country 39 */ 40 public function set_country( ?string $country ): void { 41 $this->country = $country ?? $this->country; 42 } 43 44 /** 45 * @param DateTime|string|null $deliveryDate 46 */ 47 public function set_delivery_date( $deliveryDate ): void { 48 if ( is_string( $deliveryDate ) ) { 49 $deliveryDate = date_create( $deliveryDate ); 50 } 51 $this->deliveryDate = $deliveryDate ?? $this->deliveryDate; 52 } 53 54 /** 55 * @param string|null $deliveryTerms 56 */ 57 public function set_delivery_terms( ?string $deliveryTerms ): void { 58 $this->deliveryTerms = $deliveryTerms ?? $this->deliveryTerms; 59 } 60 61 /** 62 * @param string|null $zip 63 */ 64 public function set_zip( ?string $zip ): void { 65 $this->zip = $zip ?? $this->zip; 33 $this->address = $address; 66 34 } 67 35 … … 74 42 75 43 /** 44 * @param string|null $city 45 */ 46 public function set_city( ?string $city ): void { 47 $this->city = $city; 48 } 49 50 /** 76 51 * @return string|null 77 52 */ 78 53 public function get_city(): ?string { 79 54 return $this->city; 55 } 56 57 /** 58 * @param string|null $country 59 */ 60 public function set_country( ?string $country ): void { 61 $this->country = $country; 80 62 } 81 63 … … 88 70 89 71 /** 72 * @param DateTime|string|null 73 */ 74 public function set_delivery_date( $deliveryDate ): void { 75 if ( is_string( $deliveryDate ) ) { 76 $deliveryDate = date_create( $deliveryDate ); 77 } 78 $this->deliveryDate = $deliveryDate; 79 } 80 81 /** 82 * @param string|null $format 83 * 90 84 * @return DateTime|string|null 91 85 */ 92 public function get_delivery_date( $format = null ) {86 public function get_delivery_date( ?string $format = null ) { 93 87 if ( $this->deliveryDate instanceof DateTime && ! empty( $format ) ) { 94 88 return $this->deliveryDate->format( $format ); … … 96 90 97 91 return $this->deliveryDate; 92 } 93 94 /** 95 * @param string|null $deliveryTerms 96 */ 97 public function set_delivery_terms( ?string $deliveryTerms ): void { 98 $this->deliveryTerms = $deliveryTerms; 98 99 } 99 100 … … 106 107 107 108 /** 109 * @param string|null $zip 110 */ 111 public function set_zip( ?string $zip ): void { 112 $this->zip = $zip; 113 } 114 115 /** 108 116 * @return string|null 109 117 */ … … 113 121 114 122 public function jsonSerialize(): array { 115 $ arr= get_object_vars( $this );116 $ arr['self'] = $this->get_self();117 $ arr = Util::filter_null_from( $arr);123 $vars = get_object_vars( $this ); 124 $vars['deliveryDate'] = $this->get_delivery_date( 'c' ); 125 $vars = Util::filter_null_from( $vars ); 118 126 119 return $ arr;127 return $vars; 120 128 } 121 129 } -
miqid-woo/trunk/src/Includes/EConomic/DTO/DeliveryLocation.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 -
miqid-woo/trunk/src/Includes/EConomic/DTO/DepartmentalDistribution.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 … … 13 12 /** @var string|null */ 14 13 private $distributionType; 14 /** @var array|null */ 15 private $distributions; 16 /** @var string|null */ 17 private $self; 15 18 16 19 public function __construct( … … 18 21 $name = null, 19 22 $distributionType = null, 23 $distributions = null, 20 24 $self = null 21 25 ) { 22 parent::__construct( $self );23 24 26 if ( is_array( $departmentalDistributionNumber ) ) { 25 27 $this->parse_array( $departmentalDistributionNumber ); 26 28 } 27 28 $this->set_departmental_distribution_number( $departmentalDistributionNumber ); 29 $this->set_name( $name ); 30 $this->set_distribution_type( $distributionType ); 29 if ( isset( $departmentalDistributionNumber ) ) { 30 $this->set_departmental_distribution_number( $departmentalDistributionNumber ); 31 } 32 if ( isset( $name ) ) { 33 $this->set_name( $name ); 34 } 35 if ( isset( $distributionType ) ) { 36 $this->set_distribution_type( $distributionType ); 37 } 38 if ( isset( $distributions ) ) { 39 $this->set_distributions( $distributions ); 40 } 41 if ( isset( $self ) ) { 42 $this->set_self( $self ); 43 } 31 44 } 32 45 … … 35 48 */ 36 49 public function set_departmental_distribution_number( ?int $departmentalDistributionNumber ): void { 37 $this->departmentalDistributionNumber = $departmentalDistributionNumber ?? $this->departmentalDistributionNumber; 38 } 39 40 /** 41 * @param string|null $name 42 */ 43 public function set_name( ?string $name ): void { 44 $this->name = $name ?? $this->name; 45 } 46 47 /** 48 * @param string|null $distributionType 49 */ 50 public function set_distribution_type( ?string $distributionType ): void { 51 $this->distributionType = $distributionType ?? $this->distributionType; 50 $this->departmentalDistributionNumber = $departmentalDistributionNumber; 52 51 } 53 52 … … 60 59 61 60 /** 62 * @ return string|null61 * @param string|null $distributionType 63 62 */ 64 public function get_name(): ?string{65 return $this->name;63 public function set_distribution_type( ?string $distributionType ): void { 64 $this->distributionType = $distributionType; 66 65 } 67 66 … … 73 72 } 74 73 74 /** 75 * @param array|null $distributions 76 */ 77 public function set_distributions( ?array $distributions ): void { 78 $this->distributions = $distributions; 79 } 80 81 /** 82 * @return array|null 83 */ 84 public function get_distributions(): ?array { 85 return $this->distributions; 86 } 87 75 88 public function jsonSerialize(): array { 76 $arr = get_object_vars( $this ); 77 $arr['self'] = $this->get_self(); 78 $arr = Util::filter_null_from( $arr ); 89 $arr = get_object_vars( $this ); 90 $arr = Util::filter_null_from( $arr ); 79 91 80 92 return $arr; -
miqid-woo/trunk/src/Includes/EConomic/DTO/Inventory.php
r2469411 r2495913 4 4 5 5 6 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 use DateTime; 7 7 use MIQID\Plugin\WooCommerce\Util; 8 8 9 9 class Inventory extends Base { 10 /** @var int|null */10 /** @var float|null */ 11 11 private $available; 12 12 /** @var float|null */ 13 private $inStock; 14 /** @var float|null */ 15 private $orderedByCustomers; 16 /** @var float|null */ 17 private $orderedFromSuppliers; 18 /** @var float|null */ 19 private $packageVolume; 20 /** @var float|null */ 13 21 private $grossWeight; 14 /** @var int|null */15 private $inStock;16 22 /** @var float|null */ 17 23 private $netWeight; 18 /** @var int|null */ 19 private $orderedByCustomers; 20 /** @var int|null */ 21 private $orderedFromSuppliers; 22 /** @var int|null */ 23 private $packageVolume; 24 /** @var DateTime */ 25 private $inventoryLastUpdated; 24 26 /** @var float|null */ 25 27 private $recommendedCostPrice; 26 28 27 /**28 * Inventory constructor.29 *30 * @param array|int|null $available31 * @param float|null $grossWeight32 * @param int|null $inStock33 * @param float|null $netWeight34 * @param int|null $orderedByCustomers35 * @param int|null $orderedFromSuppliers36 * @param int|null $packageVolume37 * @param float|null $recommendedCostPrice38 */39 29 public function __construct( 40 30 $available = null, 41 $grossWeight = null,42 31 $inStock = null, 43 $netWeight = null,44 32 $orderedByCustomers = null, 45 33 $orderedFromSuppliers = null, 46 34 $packageVolume = null, 35 $grossWeight = null, 36 $netWeight = null, 37 $inventoryLastUpdated = null, 47 38 $recommendedCostPrice = null 48 39 ) { … … 50 41 $this->parse_array( $available ); 51 42 } 52 $this->set_available( $available ); 53 $this->set_gross_weight( $grossWeight ); 54 $this->set_in_stock( $inStock ); 55 $this->set_net_weight( $netWeight ); 56 $this->set_ordered_by_customers( $orderedByCustomers ); 57 $this->set_ordered_from_suppliers( $orderedFromSuppliers ); 58 $this->set_package_volume( $packageVolume ); 59 $this->set_recommended_cost_price( $recommendedCostPrice ); 60 } 61 62 /** 63 * @param int|null $available 64 */ 65 public function set_available( ?int $available ): void { 66 $this->available = $available ?? $this->available; 43 if ( isset( $available ) ) { 44 $this->set_available( $available ); 45 } 46 if ( isset( $inStock ) ) { 47 $this->set_in_stock( $inStock ); 48 } 49 if ( isset( $orderedByCustomers ) ) { 50 $this->set_ordered_by_customers( $orderedByCustomers ); 51 } 52 if ( isset( $orderedFromSuppliers ) ) { 53 $this->set_ordered_from_suppliers( $orderedFromSuppliers ); 54 } 55 if ( isset( $packageVolume ) ) { 56 $this->set_package_volume( $packageVolume ); 57 } 58 if ( isset( $grossWeight ) ) { 59 $this->set_gross_weight( $grossWeight ); 60 } 61 if ( isset( $netWeight ) ) { 62 $this->set_net_weight( $netWeight ); 63 } 64 if ( isset( $inventoryLastUpdated ) ) { 65 $this->set_inventory_last_updated( $inventoryLastUpdated ); 66 } 67 if ( isset( $recommendedCostPrice ) ) { 68 $this->set_recommended_cost_price( $recommendedCostPrice ); 69 } 70 } 71 72 /** 73 * @param float|null $available 74 * 75 * @return Inventory 76 */ 77 public function set_available( ?float $available ): Inventory { 78 $this->available = $available; 79 80 return $this; 81 } 82 83 /** 84 * @return float|null 85 */ 86 public function get_available(): ?float { 87 return $this->available; 88 } 89 90 /** 91 * @param float|null $inStock 92 * 93 * @return Inventory 94 */ 95 public function set_in_stock( ?float $inStock ): Inventory { 96 $this->inStock = $inStock; 97 98 return $this; 99 } 100 101 /** 102 * @return float|null 103 */ 104 public function get_in_stock(): ?float { 105 return $this->inStock; 106 } 107 108 /** 109 * @param float|null $orderedByCustomers 110 * 111 * @return Inventory 112 */ 113 public function set_ordered_by_customers( ?float $orderedByCustomers ): Inventory { 114 $this->orderedByCustomers = $orderedByCustomers; 115 116 return $this; 117 } 118 119 /** 120 * @return float|null 121 */ 122 public function get_ordered_by_customers(): ?float { 123 return $this->orderedByCustomers; 124 } 125 126 /** 127 * @param float|null $orderedFromSuppliers 128 * 129 * @return Inventory 130 */ 131 public function set_ordered_from_suppliers( ?float $orderedFromSuppliers ): Inventory { 132 $this->orderedFromSuppliers = $orderedFromSuppliers; 133 134 return $this; 135 } 136 137 /** 138 * @return float|null 139 */ 140 public function get_ordered_from_suppliers(): ?float { 141 return $this->orderedFromSuppliers; 142 } 143 144 /** 145 * @param float|null $packageVolume 146 * 147 * @return Inventory 148 */ 149 public function set_package_volume( ?float $packageVolume ): Inventory { 150 $this->packageVolume = $packageVolume; 151 152 return $this; 153 } 154 155 /** 156 * @return float|null 157 */ 158 public function get_package_volume(): ?float { 159 return $this->packageVolume; 67 160 } 68 161 69 162 /** 70 163 * @param float|null $grossWeight 71 */ 72 public function set_gross_weight( ?float $grossWeight ): void { 73 $this->grossWeight = $grossWeight ?? $this->grossWeight; 74 } 75 76 /** 77 * @param int|null $inStock 78 */ 79 public function set_in_stock( ?int $inStock ): void { 80 $this->inStock = $inStock ?? $this->inStock; 81 } 82 83 /** 84 * @param float|null $netWeight 85 */ 86 public function set_net_weight( ?float $netWeight ): void { 87 $this->netWeight = $netWeight ?? $this->netWeight; 88 } 89 90 /** 91 * @param int|null $orderedByCustomers 92 */ 93 public function set_ordered_by_customers( ?int $orderedByCustomers ): void { 94 $this->orderedByCustomers = $orderedByCustomers ?? $this->orderedByCustomers; 95 } 96 97 /** 98 * @param int|null $orderedFromSuppliers 99 */ 100 public function set_ordered_from_suppliers( ?int $orderedFromSuppliers ): void { 101 $this->orderedFromSuppliers = $orderedFromSuppliers ?? $this->orderedFromSuppliers; 102 } 103 104 /** 105 * @param int|null $packageVolume 106 */ 107 public function set_package_volume( ?int $packageVolume ): void { 108 $this->packageVolume = $packageVolume ?? $this->packageVolume; 109 } 110 111 /** 112 * @param float|null $recommendedCostPrice 113 */ 114 public function set_recommended_cost_price( ?float $recommendedCostPrice ): void { 115 $this->recommendedCostPrice = $recommendedCostPrice ?? $this->recommendedCostPrice; 116 } 117 118 /** 119 * @return int|null 120 */ 121 public function get_available(): ?int { 122 return $this->available; 164 * 165 * @return Inventory 166 */ 167 public function set_gross_weight( ?float $grossWeight ): Inventory { 168 $this->grossWeight = $grossWeight; 169 170 return $this; 123 171 } 124 172 … … 131 179 132 180 /** 133 * @return int|null 134 */ 135 public function get_in_stock(): ?int { 136 return $this->inStock; 181 * @param float|null $netWeight 182 * 183 * @return Inventory 184 */ 185 public function set_net_weight( ?float $netWeight ): Inventory { 186 $this->netWeight = $netWeight; 187 188 return $this; 137 189 } 138 190 … … 145 197 146 198 /** 147 * @return int|null 148 */ 149 public function get_ordered_by_customers(): ?int { 150 return $this->orderedByCustomers; 151 } 152 153 /** 154 * @return int|null 155 */ 156 public function get_ordered_from_suppliers(): ?int { 157 return $this->orderedFromSuppliers; 158 } 159 160 /** 161 * @return int|null 162 */ 163 public function get_package_volume(): ?int { 164 return $this->packageVolume; 199 * @param DateTime|string $inventoryLastUpdated 200 * 201 * @return Inventory 202 */ 203 public function set_inventory_last_updated( $inventoryLastUpdated ): Inventory { 204 if ( is_string( $inventoryLastUpdated ) ) { 205 $inventoryLastUpdated = date_create( $inventoryLastUpdated ); 206 } 207 $this->inventoryLastUpdated = $inventoryLastUpdated; 208 209 return $this; 210 } 211 212 /** 213 * @return DateTime 214 */ 215 public function get_inventory_last_updated(): DateTime { 216 return $this->inventoryLastUpdated; 217 } 218 219 /** 220 * @param float|null $recommendedCostPrice 221 * 222 * @return Inventory 223 */ 224 public function set_recommended_cost_price( ?float $recommendedCostPrice ): Inventory { 225 $this->recommendedCostPrice = $recommendedCostPrice; 226 227 return $this; 165 228 } 166 229 … … 173 236 174 237 public function jsonSerialize(): array { 175 $arr = get_object_vars( $this ); 176 $arr['self'] = $this->get_self(); 177 $arr = Util::filter_null_from( $arr ); 238 $arr = get_object_vars( $this ); 239 $arr = Util::filter_null_from( $arr ); 178 240 179 241 return $arr; -
miqid-woo/trunk/src/Includes/EConomic/DTO/Layout.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 … … 11 10 /** @var string|null */ 12 11 private $name; 13 /** @var bool |null*/12 /** @var bool */ 14 13 private $deleted; 14 /** @var string|null */ 15 private $self; 15 16 16 public function __construct( 17 $LayoutNumber = null, 18 $name = null, 19 $deleted = null, 20 $Self = null 21 ) { 22 if ( is_array( $LayoutNumber ) ) { 23 $this->parse_array( $LayoutNumber ); 17 public function __construct( ?array $Layout = null ) { 18 if ( is_array( $Layout ) ) { 19 $this->parse_array( $Layout ); 24 20 } 25 26 $this->set_layout_number( $LayoutNumber );27 $this->set_name( $name );28 $this->set_deleted( $deleted );29 $this->set_self( $Self );30 21 } 31 22 32 23 /** 33 24 * @param int|null $layoutNumber 25 * 26 * @return Layout 34 27 */ 35 public function set_layout_number( ?int $layoutNumber ): void { 36 $this->layoutNumber = $layoutNumber ?? $this->layoutNumber; 28 public function set_layout_number( ?int $layoutNumber ): self { 29 $this->layoutNumber = $layoutNumber; 30 31 return $this; 37 32 } 38 33 39 34 /** 40 * @param string|null $name 35 * @param bool|int|string|null $deleted 36 * 37 * @return Layout 41 38 */ 42 public function set_name( ?string $name ): void { 43 $this->name = $name ?? $this->name; 44 } 39 public function set_deleted( $deleted ): self { 40 if ( ! is_null( $deleted ) ) { 41 $deleted = filter_var( $deleted, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 42 } 43 $this->deleted = $deleted; 45 44 46 /** 47 * @param bool|null $deleted 48 */ 49 public function set_deleted( ?bool $deleted ): void { 50 $this->deleted = $deleted ?? $this->deleted; 45 return $this; 51 46 } 52 47 … … 59 54 60 55 /** 61 * @return string|null56 * @return bool 62 57 */ 63 public function get_name(): ?string{64 return $this-> name;58 public function is_deleted(): bool { 59 return $this->deleted ?? false; 65 60 } 66 61 67 /**68 * @return bool|null69 */70 public function get_deleted(): ?bool {71 return $this->deleted;72 }73 62 74 63 public function jsonSerialize(): array { 75 $arr = get_object_vars( $this ); 76 $arr['self'] = $this->get_self(); 77 $arr = Util::filter_null_from( $arr ); 64 $arr = get_object_vars( $this ); 65 $arr = Util::filter_null_from( $arr ); 78 66 79 67 return $arr; -
miqid-woo/trunk/src/Includes/EConomic/DTO/Line.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 … … 34 33 private $departmentalDistribution; 35 34 36 public function __construct( 37 $lineNumber = null, 38 $sortKey = null, 39 $description = null, 40 $accrual = null, 41 $unit = null, 42 $product = null, 43 $quantity = null, 44 $unitNetPrice = null, 45 $discountPercentage = null, 46 $unitCostPrice = null, 47 $marginInBaseCurrency = null, 48 $marginPercentage = null, 49 $departmentalDistribution = null 50 ) { 51 if ( is_array( $lineNumber ) ) { 52 $this->parse_array( $lineNumber ); 53 } 54 55 $this->set_line_number( $lineNumber ); 56 $this->set_sort_key( $sortKey ); 57 $this->set_description( $description ); 58 $this->set_accrual( $accrual ); 59 $this->set_unit( $unit ); 60 $this->set_product( $product ); 61 $this->set_quantity( $quantity ); 62 $this->set_unit_net_price( $unitNetPrice ); 63 $this->set_discount_percentage( $discountPercentage ); 64 $this->set_unit_cost_price( $unitCostPrice ); 65 $this->set_margin_in_base_currency( $marginInBaseCurrency ); 66 $this->set_margin_percentage( $marginPercentage ); 67 $this->set_departmental_distribution( $departmentalDistribution ); 35 public function __construct( ?array $Line = null ) { 36 if ( is_array( $Line ) ) { 37 $this->parse_array( $Line ); 38 } 68 39 } 69 40 70 41 /** 71 42 * @param array|Accrual|null $accrual 72 */ 73 public function set_accrual( $accrual ): void { 43 * 44 * @return Line 45 */ 46 public function set_accrual( $accrual ): self { 74 47 if ( is_array( $accrual ) ) { 75 48 $accrual = new Accrual( $accrual ); 76 49 } 77 $this->accrual = $accrual ?? $this->accrual; 50 $this->accrual = $accrual; 51 52 return $this; 78 53 } 79 54 80 55 /** 81 56 * @param array|DepartmentalDistribution|null $departmentalDistribution 82 */ 83 public function set_departmental_distribution( $departmentalDistribution ): void { 57 * 58 * @return Line 59 */ 60 public function set_departmental_distribution( $departmentalDistribution ): self { 84 61 if ( is_array( $departmentalDistribution ) ) { 85 62 $departmentalDistribution = new DepartmentalDistribution( $departmentalDistribution ); 86 63 } 87 $this->departmentalDistribution = $departmentalDistribution ?? $this->departmentalDistribution; 64 $this->departmentalDistribution = $departmentalDistribution; 65 66 return $this; 88 67 } 89 68 90 69 /** 91 70 * @param string|null $description 92 */ 93 public function set_description( ?string $description ): void { 94 $this->description = $description ?? $this->description; 71 * 72 * @return Line 73 */ 74 public function set_description( ?string $description ): self { 75 $this->description = $description; 76 77 return $this; 95 78 } 96 79 97 80 /** 98 81 * @param float|null $discountPercentage 99 */ 100 public function set_discount_percentage( ?float $discountPercentage ): void { 101 $this->discountPercentage = $discountPercentage ?? $this->discountPercentage; 82 * 83 * @return Line 84 */ 85 public function set_discount_percentage( ?float $discountPercentage ): self { 86 $this->discountPercentage = $discountPercentage; 87 88 return $this; 102 89 } 103 90 104 91 /** 105 92 * @param int|null $lineNumber 106 */ 107 public function set_line_number( ?int $lineNumber ): void { 108 $this->lineNumber = $lineNumber ?? $this->lineNumber; 93 * 94 * @return Line 95 */ 96 public function set_line_number( ?int $lineNumber ): self { 97 $this->lineNumber = $lineNumber; 98 99 return $this; 109 100 } 110 101 111 102 /** 112 103 * @param float|null $marginInBaseCurrency 113 */ 114 public function set_margin_in_base_currency( ?float $marginInBaseCurrency ): void { 115 $this->marginInBaseCurrency = $marginInBaseCurrency ?? $this->marginInBaseCurrency; 104 * 105 * @return Line 106 */ 107 public function set_margin_in_base_currency( ?float $marginInBaseCurrency ): self { 108 $this->marginInBaseCurrency = $marginInBaseCurrency; 109 110 return $this; 116 111 } 117 112 118 113 /** 119 114 * @param float|null $marginPercentage 120 */ 121 public function set_margin_percentage( ?float $marginPercentage ): void { 122 $this->marginPercentage = $marginPercentage ?? $this->marginPercentage; 115 * 116 * @return Line 117 */ 118 public function set_margin_percentage( ?float $marginPercentage ): self { 119 $this->marginPercentage = $marginPercentage; 120 121 return $this; 123 122 } 124 123 125 124 /** 126 125 * @param array|Product|null $product 127 */ 128 public function set_product( $product ): void { 126 * 127 * @return Line 128 */ 129 public function set_product( $product ): self { 129 130 if ( is_array( $product ) ) { 130 131 $product = new Product( $product ); 131 132 } 132 $this->product = $product ?? $this->product; 133 $this->product = $product; 134 135 return $this; 133 136 } 134 137 135 138 /** 136 139 * @param float|null $quantity 137 */ 138 public function set_quantity( ?float $quantity ): void { 139 $this->quantity = $quantity ?? $this->quantity; 140 * 141 * @return Line 142 */ 143 public function set_quantity( ?float $quantity ): self { 144 $this->quantity = $quantity; 145 146 return $this; 140 147 } 141 148 142 149 /** 143 150 * @param int|null $sortKey 144 */ 145 public function set_sort_key( ?int $sortKey ): void { 146 $this->sortKey = $sortKey ?? $this->sortKey; 151 * 152 * @return Line 153 */ 154 public function set_sort_key( ?int $sortKey ): self { 155 $this->sortKey = $sortKey; 156 157 return $this; 147 158 } 148 159 149 160 /** 150 161 * @param array|Unit|null $unit 151 */ 152 public function set_unit( $unit ): void { 162 * 163 * @return Line 164 */ 165 public function set_unit( $unit ): self { 153 166 if ( is_array( $unit ) ) { 154 167 $unit = new Unit( $unit ); 155 168 } 156 $this->unit = $unit ?? $this->unit; 169 $this->unit = $unit; 170 171 return $this; 157 172 } 158 173 159 174 /** 160 175 * @param float|null $unitCostPrice 161 */ 162 public function set_unit_cost_price( ?float $unitCostPrice ): void { 163 $this->unitCostPrice = $unitCostPrice ?? $this->unitCostPrice; 176 * 177 * @return Line 178 */ 179 public function set_unit_cost_price( ?float $unitCostPrice ): self { 180 $this->unitCostPrice = $unitCostPrice; 181 182 return $this; 164 183 } 165 184 166 185 /** 167 186 * @param float|null $unitNetPrice 168 */ 169 public function set_unit_net_price( ?float $unitNetPrice ): void { 170 $this->unitNetPrice = $unitNetPrice ?? $this->unitNetPrice; 187 * 188 * @return Line 189 */ 190 public function set_unit_net_price( ?float $unitNetPrice ): self { 191 $this->unitNetPrice = $unitNetPrice; 192 193 return $this; 171 194 } 172 195 -
miqid-woo/trunk/src/Includes/EConomic/DTO/Order.php
r2469411 r2495913 4 4 5 5 use DateTime; 6 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;7 6 use MIQID\Plugin\WooCommerce\Util; 8 7 … … 65 64 private $lines; 66 65 67 public function __construct( 68 $orderNumber = null, 69 $date = null, 70 $currency = null, 71 $exchangeRate = null, 72 $netAmount = null, 73 $netAmountInBaseCurrency = null, 74 $grossAmount = null, 75 $grossAmountInBaseCurrency = null, 76 $marginInBaseCurrency = null, 77 $marginPercentage = null, 78 $vatAmount = null, 79 $roundingAmount = null, 80 $costPriceInBaseCurrency = null, 81 $dueDate = null, 82 $paymentTerms = null, 83 $customer = null, 84 $recipient = null, 85 $deliveryLocation = null, 86 $delivery = null, 87 $notes = null, 88 $references = null, 89 $project = null, 90 $pdf = null, 91 $soap = null, 92 $templates = null, 93 $lines = null, 94 $layout = null, 95 $self = null 96 ) { 97 parent::__construct( $self ); 98 99 if ( is_array( $orderNumber ) ) { 100 $this->parse_array( $orderNumber ); 101 } 102 103 $this->set_order_number( $orderNumber ); 104 $this->set_date( $date ); 105 $this->set_currency( $currency ); 106 $this->set_exchange_rate( $exchangeRate ); 107 $this->set_net_amount( $netAmount ); 108 $this->set_net_amount_in_base_currency( $netAmountInBaseCurrency ); 109 $this->set_gross_amount( $grossAmount ); 110 $this->set_gross_amount_in_base_currency( $grossAmountInBaseCurrency ); 111 $this->set_margin_in_base_currency( $marginInBaseCurrency ); 112 $this->set_margin_percentage( $marginPercentage ); 113 $this->set_vat_amount( $vatAmount ); 114 $this->set_rounding_amount( $roundingAmount ); 115 $this->set_cost_price_in_base_currency( $costPriceInBaseCurrency ); 116 $this->set_due_date( $dueDate ); 117 $this->set_payment_terms( $paymentTerms ); 118 $this->set_customer( $customer ); 119 $this->set_recipient( $recipient ); 120 $this->set_delivery_location( $deliveryLocation ); 121 $this->set_delivery( $delivery ); 122 $this->set_notes( $notes ); 123 $this->set_references( $references ); 124 $this->set_project( $project ); 125 $this->set_pdf( $pdf ); 126 $this->set_soap( $soap ); 127 $this->set_templates( $templates ); 128 $this->set_lines( $lines ); 129 $this->set_layout( $layout ); 66 public function __construct( ?array $Order = null ) { 67 if ( is_array( $Order ) ) { 68 $this->parse_array( $Order ); 69 } 130 70 } 131 71 132 72 /** 133 73 * @param int|null $orderNumber 134 */ 135 public function set_order_number( ?int $orderNumber ): void { 136 $this->orderNumber = $orderNumber ?? $this->orderNumber; 74 * 75 * @return Order 76 */ 77 public function set_order_number( ?int $orderNumber ): self { 78 $this->orderNumber = $orderNumber; 79 80 return $this; 137 81 } 138 82 139 83 /** 140 84 * @param DateTime|string|null $date 141 */ 142 public function set_date( $date ): void { 85 * 86 * @return Order 87 */ 88 public function set_date( $date ): self { 143 89 if ( is_string( $date ) ) { 144 90 $date = date_create( $date ); 145 91 } 146 $this->date = $date ?? $this->date; 92 $this->date = $date; 93 94 return $this; 147 95 } 148 96 149 97 /** 150 98 * @param Currency|array|string|null $currency 151 */ 152 public function set_currency( $currency ): void { 99 * 100 * @return Order 101 */ 102 public function set_currency( $currency ): self { 153 103 if ( is_array( $currency ) || is_string( $currency ) ) { 154 104 $currency = new Currency( $currency ); 155 105 } 156 $this->currency = $currency ?? $this->currency; 106 $this->currency = $currency; 107 108 return $this; 157 109 } 158 110 159 111 /** 160 112 * @param float|null $exchangeRate 161 */ 162 public function set_exchange_rate( ?float $exchangeRate ): void { 163 $this->exchangeRate = $exchangeRate ?? $this->exchangeRate; 113 * 114 * @return Order 115 */ 116 public function set_exchange_rate( ?float $exchangeRate ): self { 117 $this->exchangeRate = $exchangeRate; 118 119 return $this; 164 120 } 165 121 166 122 /** 167 123 * @param float|null $netAmount 168 */ 169 public function set_net_amount( ?float $netAmount ): void { 170 $this->netAmount = $netAmount ?? $this->netAmount; 124 * 125 * @return Order 126 */ 127 public function set_net_amount( ?float $netAmount ): self { 128 $this->netAmount = $netAmount; 129 130 return $this; 171 131 } 172 132 173 133 /** 174 134 * @param float|null $netAmountInBaseCurrency 175 */ 176 public function set_net_amount_in_base_currency( ?float $netAmountInBaseCurrency ): void { 177 $this->netAmountInBaseCurrency = $netAmountInBaseCurrency ?? $this->netAmountInBaseCurrency; 135 * 136 * @return Order 137 */ 138 public function set_net_amount_in_base_currency( ?float $netAmountInBaseCurrency ): self { 139 $this->netAmountInBaseCurrency = $netAmountInBaseCurrency; 140 141 return $this; 178 142 } 179 143 180 144 /** 181 145 * @param float|null $grossAmount 182 */ 183 public function set_gross_amount( ?float $grossAmount ): void { 184 $this->grossAmount = $grossAmount ?? $this->grossAmount; 146 * 147 * @return Order 148 */ 149 public function set_gross_amount( ?float $grossAmount ): self { 150 $this->grossAmount = $grossAmount; 151 152 return $this; 185 153 } 186 154 187 155 /** 188 156 * @param float|null $grossAmountInBaseCurrency 189 */ 190 public function set_gross_amount_in_base_currency( ?float $grossAmountInBaseCurrency ): void { 191 $this->grossAmountInBaseCurrency = $grossAmountInBaseCurrency ?? $this->grossAmountInBaseCurrency; 157 * 158 * @return Order 159 */ 160 public function set_gross_amount_in_base_currency( ?float $grossAmountInBaseCurrency ): self { 161 $this->grossAmountInBaseCurrency = $grossAmountInBaseCurrency; 162 163 return $this; 192 164 } 193 165 194 166 /** 195 167 * @param float|null $marginInBaseCurrency 196 */ 197 public function set_margin_in_base_currency( ?float $marginInBaseCurrency ): void { 198 $this->marginInBaseCurrency = $marginInBaseCurrency ?? $this->marginInBaseCurrency; 168 * 169 * @return Order 170 */ 171 public function set_margin_in_base_currency( ?float $marginInBaseCurrency ): self { 172 $this->marginInBaseCurrency = $marginInBaseCurrency; 173 174 return $this; 199 175 } 200 176 201 177 /** 202 178 * @param float|null $marginPercentage 203 */ 204 public function set_margin_percentage( ?float $marginPercentage ): void { 205 $this->marginPercentage = $marginPercentage ?? $this->marginPercentage; 179 * 180 * @return Order 181 */ 182 public function set_margin_percentage( ?float $marginPercentage ): self { 183 $this->marginPercentage = $marginPercentage; 184 185 return $this; 206 186 } 207 187 208 188 /** 209 189 * @param float|null $vatAmount 210 */ 211 public function set_vat_amount( ?float $vatAmount ): void { 212 $this->vatAmount = $vatAmount ?? $this->vatAmount; 190 * 191 * @return Order 192 */ 193 public function set_vat_amount( ?float $vatAmount ): self { 194 $this->vatAmount = $vatAmount; 195 196 return $this; 213 197 } 214 198 215 199 /** 216 200 * @param float|null $roundingAmount 217 */ 218 public function set_rounding_amount( ?float $roundingAmount ): void { 219 $this->roundingAmount = $roundingAmount ?? $this->roundingAmount; 201 * 202 * @return Order 203 */ 204 public function set_rounding_amount( ?float $roundingAmount ): self { 205 $this->roundingAmount = $roundingAmount; 206 207 return $this; 220 208 } 221 209 222 210 /** 223 211 * @param float|null $costPriceInBaseCurrency 224 */ 225 public function set_cost_price_in_base_currency( ?float $costPriceInBaseCurrency ): void { 226 $this->costPriceInBaseCurrency = $costPriceInBaseCurrency ?? $this->costPriceInBaseCurrency; 212 * 213 * @return Order 214 */ 215 public function set_cost_price_in_base_currency( ?float $costPriceInBaseCurrency ): self { 216 $this->costPriceInBaseCurrency = $costPriceInBaseCurrency; 217 218 return $this; 227 219 } 228 220 229 221 /** 230 222 * @param DateTime|string|null $dueDate 231 */ 232 public function set_due_date( $dueDate ): void { 223 * 224 * @return Order 225 */ 226 public function set_due_date( $dueDate ): self { 233 227 if ( is_string( $dueDate ) ) { 234 228 $dueDate = date_create( $dueDate ); 235 229 } 236 $this->dueDate = $dueDate ?? $this->dueDate; 230 $this->dueDate = $dueDate; 231 232 return $this; 237 233 } 238 234 239 235 /** 240 236 * @param array|PaymentTerm|null $paymentTerms 241 */ 242 public function set_payment_terms( $paymentTerms ): void { 237 * 238 * @return Order 239 */ 240 public function set_payment_terms( $paymentTerms ): self { 243 241 if ( is_array( $paymentTerms ) ) { 244 242 $paymentTerms = new PaymentTerm( $paymentTerms ); 245 243 } 246 $this->paymentTerms = $paymentTerms ?? $this->paymentTerms; 244 $this->paymentTerms = $paymentTerms; 245 246 return $this; 247 247 } 248 248 249 249 /** 250 250 * @param array|Customer|null $customer 251 */ 252 public function set_customer( $customer ): void { 251 * 252 * @return Order 253 */ 254 public function set_customer( $customer ): self { 253 255 if ( is_array( $customer ) ) { 254 256 $customer = new Customer( $customer ); 255 257 } 256 $this->customer = $customer ?? $this->customer; 258 $this->customer = $customer; 259 260 return $this; 257 261 } 258 262 259 263 /** 260 264 * @param Recipient|array|null $recipient 261 */ 262 public function set_recipient( $recipient ): void { 265 * 266 * @return Order 267 */ 268 public function set_recipient( $recipient ): self { 263 269 if ( is_array( $recipient ) ) { 264 270 $recipient = new Recipient( $recipient ); 265 271 } 266 $this->recipient = $recipient ?? $this->recipient; 272 $this->recipient = $recipient; 273 274 return $this; 267 275 } 268 276 269 277 /** 270 278 * @param array|DeliveryLocation|null $deliveryLocation 271 */ 272 public function set_delivery_location( $deliveryLocation ): void { 279 * 280 * @return Order 281 */ 282 public function set_delivery_location( $deliveryLocation ): self { 273 283 if ( is_array( $deliveryLocation ) ) { 274 284 $deliveryLocation = new DeliveryLocation( $deliveryLocation ); 275 285 } 276 $this->deliveryLocation = $deliveryLocation ?? $this->deliveryLocation; 277 } 278 279 /** 280 * @param array|Delivery|null $delivery 281 */ 282 public function set_delivery( $delivery ): void { 286 $this->deliveryLocation = $deliveryLocation; 287 288 return $this; 289 } 290 291 /** 292 * @param Delivery|array|null $delivery 293 * 294 * @return Order 295 */ 296 public function set_delivery( $delivery ): self { 283 297 if ( is_array( $delivery ) ) { 284 298 $delivery = new Delivery( $delivery ); 285 299 } 286 $this->delivery = $delivery ?? $this->delivery; 300 $this->delivery = $delivery; 301 302 return $this; 287 303 } 288 304 289 305 /** 290 306 * @param array|null $notes 291 */ 292 public function set_notes( ?array $notes ): void { 293 $this->notes = $notes ?? $this->notes; 307 * 308 * @return Order 309 */ 310 public function set_notes( ?array $notes ): self { 311 $this->notes = $notes; 312 313 return $this; 294 314 } 295 315 296 316 /** 297 317 * @param array|null $references 298 */ 299 public function set_references( ?array $references ): void { 300 $this->references = $references ?? $this->references; 318 * 319 * @return Order 320 */ 321 public function set_references( ?array $references ): self { 322 $this->references = $references; 323 324 return $this; 301 325 } 302 326 303 327 /** 304 328 * @param array|null $project 305 */ 306 public function set_project( ?array $project ): void { 307 $this->project = $project ?? $this->project; 329 * 330 * @return Order 331 */ 332 public function set_project( ?array $project ): self { 333 $this->project = $project; 334 335 return $this; 308 336 } 309 337 310 338 /** 311 339 * @param array|null $pdf 312 */ 313 public function set_pdf( ?array $pdf ): void { 314 $this->pdf = $pdf ?? $this->pdf; 340 * 341 * @return Order 342 */ 343 public function set_pdf( ?array $pdf ): self { 344 $this->pdf = $pdf; 345 346 return $this; 315 347 } 316 348 317 349 /** 318 350 * @param array|null $soap 319 */ 320 public function set_soap( ?array $soap ): void { 321 $this->soap = $soap ?? $this->soap; 351 * 352 * @return Order 353 */ 354 public function set_soap( ?array $soap ): self { 355 $this->soap = $soap; 356 357 return $this; 322 358 } 323 359 324 360 /** 325 361 * @param array|null $templates 326 */ 327 public function set_templates( ?array $templates ): void { 328 $this->templates = $templates ?? $this->templates; 362 * 363 * @return Order 364 */ 365 public function set_templates( ?array $templates ): self { 366 $this->templates = $templates; 367 368 return $this; 329 369 } 330 370 331 371 /** 332 372 * @param Line[]|null $lines 333 */ 334 public function set_lines( ?array $lines ): void { 335 $this->lines = $lines ?? $this->lines; 373 * 374 * @return Order 375 */ 376 public function set_lines( ?array $lines ): self { 377 $this->lines = $lines; 378 379 return $this; 336 380 } 337 381 338 382 /** 339 383 * @param Layout|array|null $layout 340 */ 341 public function set_layout( $layout ): void { 384 * 385 * @return Order 386 */ 387 public function set_layout( $layout ): self { 342 388 if ( is_array( $layout ) ) { 343 389 $layout = new Layout( $layout ); 344 390 } 345 $this->layout = $layout ?? $this->layout; 391 $this->layout = $layout; 392 393 return $this; 346 394 } 347 395 … … 548 596 $vars['dueDate'] = $this->get_due_date( 'Y-m-d' ); 549 597 $vars['currency'] = $this->get_currency()->get_code(); 550 $vars['customer'] = new Customer( $this->get_customer()->get_customer_number() );551 $vars['layout'] = new Layout( $this->get_layout()->get_layout_number() );552 $vars['paymentTerms'] = new PaymentTerm( $this->get_payment_terms()->get_payment_terms_number() );598 $vars['customer'] = ( new Customer )->set_customer_number( $this->get_customer()->get_customer_number() ); 599 $vars['layout'] = ( new Layout )->set_layout_number( $this->get_layout()->get_layout_number() ); 600 $vars['paymentTerms'] = ( new PaymentTerm )->set_payment_terms_number( $this->get_payment_terms()->get_payment_terms_number() ); 553 601 $vars = Util::filter_null_from( $vars ); 554 602 -
miqid-woo/trunk/src/Includes/EConomic/DTO/PaymentTerm.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 … … 13 12 /** @var string|null */ 14 13 private $description; 15 /** @var string |null*/14 /** @var string */ 16 15 private $paymentTermsType; 16 /** @var Account */ 17 private $contraAccountForPrepaidAmount; 18 /** @var Account */ 19 private $contraAccountForRemainderAmount; 17 20 /** @var float|null */ 18 21 private $percentageForPrepaidAmount; 19 22 /** @var float|null */ 20 23 private $percentageForRemainderAmount; 21 /** @var array |null*/24 /** @var array */ 22 25 private $creditCardCompany; 23 /** @var Account|null */ 24 private $contraAccountForPrepaidAmount; 25 /** @var Account|null */ 26 private $contraAccountForRemainderAmount; 27 28 public function __construct( 29 $paymentTermsNumber = null, 30 $daysOfCredit = null, 31 $description = null, 32 $paymentTermsType = null, 33 $percentageForPrepaidAmount = null, 34 $percentageForRemainderAmount = null, 35 $creditCardCompany = null, 36 $contraAccountForPrepaidAmount = null, 37 $contraAccountForRemainderAmount = null, 38 $name = null, 39 $self = null 40 ) { 41 parent::__construct( $name, $self ); 42 43 if ( is_array( $paymentTermsNumber ) ) { 44 $this->parse_array( $paymentTermsNumber ); 26 27 public function __construct( ?array $PaymentTerm = null ) { 28 if ( is_array( $PaymentTerm ) ) { 29 $this->parse_array( $PaymentTerm ); 45 30 } 46 47 $this->set_payment_terms_number( $paymentTermsNumber );48 $this->set_days_of_credit( $daysOfCredit );49 $this->set_description( $description );50 $this->set_payment_terms_type( $paymentTermsType );51 $this->set_percentage_for_prepaid_amount( $percentageForPrepaidAmount );52 $this->set_percentage_for_remainder_amount( $percentageForRemainderAmount );53 $this->set_credit_card_company( $creditCardCompany );54 $this->set_contra_account_for_prepaid_amount( $contraAccountForPrepaidAmount );55 $this->set_contra_account_for_remainder_amount( $contraAccountForRemainderAmount );56 31 } 57 32 58 33 /** 59 34 * @param int|null $paymentTermsNumber 60 */ 61 public function set_payment_terms_number( ?int $paymentTermsNumber ): void { 62 $this->paymentTermsNumber = $paymentTermsNumber ?? $this->paymentTermsNumber; 35 * 36 * @return PaymentTerm 37 */ 38 public function set_payment_terms_number( ?int $paymentTermsNumber ): self { 39 $this->paymentTermsNumber = $paymentTermsNumber; 40 41 return $this; 63 42 } 64 43 65 44 /** 66 45 * @param int|null $daysOfCredit 67 */ 68 public function set_days_of_credit( ?int $daysOfCredit ): void { 69 $this->daysOfCredit = $daysOfCredit ?? $this->daysOfCredit; 46 * 47 * @return PaymentTerm 48 */ 49 public function set_days_of_credit( ?int $daysOfCredit ): self { 50 $this->daysOfCredit = $daysOfCredit; 51 52 return $this; 70 53 } 71 54 72 55 /** 73 56 * @param string|null $description 74 */ 75 public function set_description( ?string $description ): void { 76 $this->description = $description ?? $this->description; 57 * 58 * @return PaymentTerm 59 */ 60 public function set_description( ?string $description ): self { 61 $this->description = $description; 62 63 return $this; 77 64 } 78 65 79 66 /** 80 67 * @param string|null $paymentTermsType 81 */ 82 public function set_payment_terms_type( ?string $paymentTermsType ): void { 83 $this->paymentTermsType = $paymentTermsType ?? $this->paymentTermsType; 68 * 69 * @return PaymentTerm 70 */ 71 public function set_payment_terms_type( ?string $paymentTermsType ): self { 72 $this->paymentTermsType = $paymentTermsType; 73 74 return $this; 75 } 76 77 /** 78 * @param Account|null $contraAccountForPrepaidAmount 79 * 80 * @return PaymentTerm 81 */ 82 public function set_contra_account_for_prepaid_amount( ?Account $contraAccountForPrepaidAmount ): self { 83 $this->contraAccountForPrepaidAmount = $contraAccountForPrepaidAmount; 84 85 return $this; 86 } 87 88 /** 89 * @param Account|null $contraAccountForRemainderAmount 90 * 91 * @return PaymentTerm 92 */ 93 public function set_contra_account_for_remainder_amount( ?Account $contraAccountForRemainderAmount ): self { 94 $this->contraAccountForRemainderAmount = $contraAccountForRemainderAmount; 95 96 return $this; 84 97 } 85 98 86 99 /** 87 100 * @param float|null $percentageForPrepaidAmount 88 */ 89 public function set_percentage_for_prepaid_amount( ?float $percentageForPrepaidAmount ): void { 90 $this->percentageForPrepaidAmount = $percentageForPrepaidAmount ?? $this->percentageForPrepaidAmount; 101 * 102 * @return PaymentTerm 103 */ 104 public function set_percentage_for_prepaid_amount( ?float $percentageForPrepaidAmount ): self { 105 $this->percentageForPrepaidAmount = $percentageForPrepaidAmount; 106 107 return $this; 91 108 } 92 109 93 110 /** 94 111 * @param float|null $percentageForRemainderAmount 95 */ 96 public function set_percentage_for_remainder_amount( ?float $percentageForRemainderAmount ): void { 97 $this->percentageForRemainderAmount = $percentageForRemainderAmount ?? $this->percentageForRemainderAmount; 112 * 113 * @return PaymentTerm 114 */ 115 public function set_percentage_for_remainder_amount( ?float $percentageForRemainderAmount ): self { 116 $this->percentageForRemainderAmount = $percentageForRemainderAmount; 117 118 return $this; 98 119 } 99 120 100 121 /** 101 122 * @param array|null $creditCardCompany 102 */ 103 public function set_credit_card_company( ?array $creditCardCompany ): void { 104 $this->creditCardCompany = $creditCardCompany ?? $this->creditCardCompany; 105 } 106 107 /** 108 * @param Account|null $contraAccountForPrepaidAmount 109 */ 110 public function set_contra_account_for_prepaid_amount( ?Account $contraAccountForPrepaidAmount ): void { 111 $this->contraAccountForPrepaidAmount = $contraAccountForPrepaidAmount ?? $this->contraAccountForPrepaidAmount; 112 } 113 114 /** 115 * @param Account|null $contraAccountForRemainderAmount 116 */ 117 public function set_contra_account_for_remainder_amount( ?Account $contraAccountForRemainderAmount ): void { 118 $this->contraAccountForRemainderAmount = $contraAccountForRemainderAmount ?? $this->contraAccountForRemainderAmount; 123 * 124 * @return PaymentTerm 125 */ 126 public function set_credit_card_company( ?array $creditCardCompany ): self { 127 $this->creditCardCompany = $creditCardCompany; 128 129 return $this; 119 130 } 120 131 … … 186 197 $arr['name'] = $this->get_name(); 187 198 //$arr['self'] = $this->get_self(); 188 $arr = Util::filter_null_from( $arr );199 $arr = Util::filter_null_from( $arr ); 189 200 190 201 return $arr; -
miqid-woo/trunk/src/Includes/EConomic/DTO/Product.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;5 use DateTime; 6 6 use MIQID\Plugin\WooCommerce\Util; 7 7 8 8 class Product extends Base { 9 9 /** @var string|null */ 10 private $ barCode;11 /** @var bool|null */12 private $ barred;10 private $productNumber; 11 /** @var string|null */ 12 private $description; 13 13 /** @var float|null */ 14 14 private $costPrice; 15 /** @var DepartmentalDistribution|null */16 private $departmentalDistribution;17 /** @var string|null */18 private $description;19 /** @var Inventory|null */20 private $inventory;21 /** @var string|null */22 private $name;23 /** @var ProductGroup|null */24 private $productGroup;25 /** @var string|null */26 private $productNumber;27 15 /** @var float|null */ 28 16 private $recommendedPrice; 29 17 /** @var float|null */ 30 18 private $salesPrice; 31 /** @var Unit|null */ 19 /** @var string|null */ 20 private $barCode; 21 /** @var bool */ 22 private $barred; 23 /** @var DateTime|null */ 24 private $lastUpdated; 25 /** @var ProductInvoice[]|null */ 26 private $invoices; 27 /** @var Inventory[]|null */ 28 private $inventory; 29 /** @var Unit */ 32 30 private $unit; 31 /** @var ProductGroup */ 32 private $productGroup; 33 /** @var DepartmentalDistribution */ 34 private $departmentalDistribution; 35 /** @var string|null */ 36 private $self; 33 37 34 38 public function __construct( 39 $productNumber = null, 40 $description = null, 41 $name = null, 42 $costPrice = null, 43 $recommendedPrice = null, 44 $salesPrice = null, 35 45 $barCode = null, 36 46 $barred = null, 37 $costPrice = null, 47 $lastUpdated = null, 48 $invoices = null, 49 $inventory = null, 50 $unit = null, 51 $productGroup = null, 38 52 $departmentalDistribution = null, 39 $description = null, 40 $inventory = null, 41 $name = null, 42 $productGroup = null, 43 $productNumber = null, 44 $recommendedPrice = null, 45 $salesPrice = null, 46 $unit = null 53 $self = null 47 54 ) { 48 if ( is_array( $barCode ) ) { 49 $this->parse_array( $barCode ); 50 } 51 52 $this->set_bar_code( $barCode ); 53 $this->set_barred( $barred ); 54 $this->set_cost_price( $costPrice ); 55 $this->set_departmental_distribution( $departmentalDistribution ); 56 $this->set_description( $description ); 57 $this->set_inventory( $inventory ); 58 $this->set_name( $name ); 59 $this->set_product_group( $productGroup ); 60 $this->set_product_number( $productNumber ); 61 $this->set_recommended_price( $recommendedPrice ); 62 $this->set_sales_price( $salesPrice ); 63 $this->set_unit( $unit ); 55 if ( is_array( $productNumber ) ) { 56 $this->parse_array( $productNumber ); 57 } 58 if ( isset( $productNumber ) ) { 59 $this->set_product_number( $productNumber ); 60 } 61 if ( isset( $description ) ) { 62 $this->set_description( $description ); 63 } 64 if ( isset( $name ) ) { 65 $this->set_name( $name ); 66 } 67 if ( isset( $costPrice ) ) { 68 $this->set_cost_price( $costPrice ); 69 } 70 if ( isset( $recommendedPrice ) ) { 71 $this->set_recommended_price( $recommendedPrice ); 72 } 73 if ( isset( $salesPrice ) ) { 74 $this->set_sales_price( $salesPrice ); 75 } 76 if ( isset( $barCode ) ) { 77 $this->set_bar_code( $barCode ); 78 } 79 if ( isset( $barred ) ) { 80 $this->set_barred( $barred ); 81 } 82 if ( isset( $lastUpdated ) ) { 83 $this->set_last_updated( $lastUpdated ); 84 } 85 if ( isset( $invoices ) ) { 86 $this->set_invoices( $invoices ); 87 } 88 if ( isset( $inventory ) ) { 89 $this->set_inventory( $inventory ); 90 } 91 if ( isset( $unit ) ) { 92 $this->set_unit( $unit ); 93 } 94 if ( isset( $productGroup ) ) { 95 $this->set_product_group( $productGroup ); 96 } 97 if ( isset( $departmentalDistribution ) ) { 98 $this->set_departmental_distribution( $departmentalDistribution ); 99 } 100 if ( isset( $self ) ) { 101 $this->set_self( $self ); 102 } 103 } 104 105 /** 106 * @param string|null $productNumber 107 * 108 * @return Product 109 */ 110 public function set_product_number( ?string $productNumber ): self { 111 $this->productNumber = $productNumber; 112 113 return $this; 114 } 115 116 /** 117 * @return string|null 118 */ 119 public function get_product_number(): ?string { 120 return $this->productNumber; 121 } 122 123 /** 124 * @param string|null $description 125 * 126 * @return Product 127 */ 128 public function set_description( ?string $description ): self { 129 $this->description = $description; 130 131 return $this; 132 } 133 134 /** 135 * @return string|null 136 */ 137 public function get_description(): ?string { 138 return $this->description; 139 } 140 141 /** 142 * @param float|null $costPrice 143 * 144 * @return Product 145 */ 146 public function set_cost_price( ?float $costPrice ): self { 147 $this->costPrice = $costPrice; 148 149 return $this; 150 } 151 152 /** 153 * @return float|null 154 */ 155 public function get_cost_price(): ?float { 156 return $this->costPrice; 157 } 158 159 /** 160 * @param float|null $recommendedPrice 161 * 162 * @return Product 163 */ 164 public function set_recommended_price( ?float $recommendedPrice ): self { 165 $this->recommendedPrice = $recommendedPrice; 166 167 return $this; 168 } 169 170 /** 171 * @return float|null 172 */ 173 public function get_recommended_price(): ?float { 174 return $this->recommendedPrice; 175 } 176 177 /** 178 * @param float|null $salesPrice 179 * 180 * @return Product 181 */ 182 public function set_sales_price( ?float $salesPrice ): self { 183 $this->salesPrice = $salesPrice; 184 185 return $this; 186 } 187 188 /** 189 * @return float|null 190 */ 191 public function get_sales_price(): ?float { 192 return $this->salesPrice; 64 193 } 65 194 66 195 /** 67 196 * @param string|null $barCode 68 */ 69 public function set_bar_code( ?string $barCode ): void { 70 $this->barCode = $barCode ?? $this->barCode; 71 } 72 73 /** 74 * @param bool|null $barred 75 */ 76 public function set_barred( ?bool $barred ): void { 77 $this->barred = filter_var( $barred, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) ?? $this->barred; 78 } 79 80 /** 81 * @param float|null $costPrice 82 */ 83 public function set_cost_price( ?float $costPrice ): void { 84 $this->costPrice = $costPrice ?? $this->costPrice; 197 * 198 * @return Product 199 */ 200 public function set_bar_code( ?string $barCode ): self { 201 $this->barCode = $barCode; 202 203 return $this; 204 } 205 206 /** 207 * @return string|null 208 */ 209 public function get_bar_code(): ?string { 210 return $this->barCode; 211 } 212 213 /** 214 * @param bool|int|string|null $barred 215 * 216 * @return Product 217 */ 218 public function set_barred( $barred ): self { 219 if ( ! is_null( $barred ) ) { 220 $barred = filter_var( $barred, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 221 } 222 $this->barred = $barred; 223 224 return $this; 225 } 226 227 /** 228 * @return bool 229 */ 230 public function is_barred(): bool { 231 return $this->barred ?? false; 232 } 233 234 /** 235 * @param DateTime|string|null $lastUpdated 236 * 237 * @return Product 238 */ 239 public function set_last_updated( $lastUpdated ): self { 240 if ( is_string( $lastUpdated ) ) { 241 $lastUpdated = date_create( $lastUpdated ); 242 } 243 $this->lastUpdated = $lastUpdated; 244 245 return $this; 246 } 247 248 /** 249 * @return DateTime|string|null 250 */ 251 public function get_last_updated( $format = null ) { 252 if ( $this->lastUpdated instanceof DateTime && ! empty( $format ) ) { 253 return $this->lastUpdated->format( $format ); 254 } 255 256 return $this->lastUpdated; 257 } 258 259 /** 260 * @param ProductInvoice[]|null $invoices 261 * 262 * @return Product 263 */ 264 public function set_invoices( ?array $invoices ): self { 265 $this->invoices = $invoices; 266 267 return $this; 268 } 269 270 /** 271 * @return ProductInvoice[]|null 272 */ 273 public function get_invoices(): ?array { 274 return $this->invoices; 275 } 276 277 /** 278 * @param Inventory[]|null $inventory 279 * 280 * @return Product 281 */ 282 public function set_inventory( ?array $inventory ): self { 283 $this->inventory = $inventory; 284 285 return $this; 286 } 287 288 /** 289 * @return Inventory[]|null 290 */ 291 public function get_inventory(): ?array { 292 return $this->inventory; 293 } 294 295 /** 296 * @param array|Unit|null $unit 297 * 298 * @return Product 299 */ 300 public function set_unit( $unit ): self { 301 if ( is_array( $unit ) ) { 302 $unit = new Unit( $unit ); 303 } 304 $this->unit = $unit; 305 306 return $this; 307 } 308 309 /** 310 * @return Unit 311 */ 312 public function get_unit(): Unit { 313 return $this->unit; 314 } 315 316 /** 317 * @param array|ProductGroup|null $productGroup 318 * 319 * @return Product 320 */ 321 public function set_product_group( $productGroup ): self { 322 if ( is_array( $productGroup ) ) { 323 $productGroup = new ProductGroup( $productGroup ); 324 } 325 $this->productGroup = $productGroup; 326 327 return $this; 328 } 329 330 /** 331 * @return ProductGroup 332 */ 333 public function get_product_group(): ProductGroup { 334 return $this->productGroup ?? new ProductGroup(); 85 335 } 86 336 87 337 /** 88 338 * @param array|DepartmentalDistribution|null $departmentalDistribution 89 */ 90 public function set_departmental_distribution( $departmentalDistribution ): void { 339 * 340 * @return Product 341 */ 342 public function set_departmental_distribution( $departmentalDistribution ): self { 91 343 if ( is_array( $departmentalDistribution ) ) { 92 344 $departmentalDistribution = new DepartmentalDistribution( $departmentalDistribution ); 93 345 } 94 $this->departmentalDistribution = $departmentalDistribution ?? $this->departmentalDistribution; 95 } 96 97 /** 98 * @param string|null $description 99 */ 100 public function set_description( ?string $description ): void { 101 $this->description = $description ?? $this->description; 102 } 103 104 /** 105 * @param array|Inventory|null $inventory 106 */ 107 public function set_inventory( $inventory ): void { 108 if ( is_array( $inventory ) ) { 109 $inventory = new Inventory( $inventory ); 110 } 111 $this->inventory = $inventory ?? $this->inventory; 112 } 113 114 /** 115 * @param string|null $name 116 */ 117 public function set_name( ?string $name ): void { 118 $this->name = $name ?? $this->name; 119 } 120 121 /** 122 * @param array|ProductGroup|null $productGroup 123 */ 124 public function set_product_group( $productGroup ): void { 125 if ( is_array( $productGroup ) ) { 126 $productGroup = new ProductGroup( $productGroup ); 127 } 128 $this->productGroup = $productGroup ?? $this->productGroup; 129 } 130 131 /** 132 * @param string|null $productNumber 133 */ 134 public function set_product_number( ?string $productNumber ): void { 135 $this->productNumber = $productNumber ?? $this->productNumber; 136 } 137 138 /** 139 * @param float|null $recommendedPrice 140 */ 141 public function set_recommended_price( ?float $recommendedPrice ): void { 142 $this->recommendedPrice = $recommendedPrice ?? $this->recommendedPrice; 143 } 144 145 /** 146 * @param float|null $salesPrice 147 */ 148 public function set_sales_price( ?float $salesPrice ): void { 149 $this->salesPrice = $salesPrice ?? $this->salesPrice; 150 } 151 152 /** 153 * @param array|Unit|null $unit 154 */ 155 public function set_unit( $unit ): void { 156 if ( is_array( $unit ) ) { 157 $unit = new Unit( $unit ); 158 } 159 $this->unit = $unit ?? $this->unit; 160 } 161 162 /** 163 * @return string|null 164 */ 165 public function get_bar_code(): ?string { 166 return $this->barCode; 167 } 168 169 /** 170 * @return bool|null 171 */ 172 public function get_barred(): ?bool { 173 return $this->barred; 174 } 175 176 /** 177 * @return float|null 178 */ 179 public function get_cost_price(): ?float { 180 return $this->costPrice; 346 $this->departmentalDistribution = $departmentalDistribution; 347 348 return $this; 181 349 } 182 350 … … 188 356 } 189 357 190 /**191 * @return string|null192 */193 public function get_description(): ?string {194 return $this->description;195 }196 197 /**198 * @return Inventory199 */200 public function get_inventory(): Inventory {201 return $this->inventory ?? new Inventory();202 }203 204 /**205 * @return string|null206 */207 public function get_name(): ?string {208 return $this->name;209 }210 211 /**212 * @return ProductGroup213 */214 public function get_product_group(): ProductGroup {215 return $this->productGroup ?? new ProductGroup();216 }217 218 /**219 * @return string|null220 */221 public function get_product_number(): ?string {222 return $this->productNumber;223 }224 225 /**226 * @return float|null227 */228 public function get_recommended_price(): ?float {229 return $this->recommendedPrice;230 }231 232 /**233 * @return float|null234 */235 public function get_sales_price(): ?float {236 return $this->salesPrice;237 }238 239 /**240 * @return Unit241 */242 public function get_unit(): Unit {243 return $this->unit ?? new Unit();244 }245 246 358 public function jsonSerialize(): array { 247 $vars = get_object_vars( $this ); 248 $vars['self'] = $this->get_self(); 249 $vars = Util::filter_null_from( $vars ); 359 $vars = get_object_vars( $this ); 360 $vars['name'] = $this->get_name(); 361 $vars['lastUpdated'] = $this->get_last_updated( 'c' ); 362 $vars = Util::filter_null_from( $vars ); 250 363 251 364 return $vars; -
miqid-woo/trunk/src/Includes/EConomic/DTO/ProductGroup.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 … … 9 8 /** @var int|null */ 10 9 private $productGroupNumber; 10 /** @var string|null */ 11 private $name; 12 /** @var string|null */ 13 private $salesAccounts; 14 /** @var string|null */ 15 private $products; 16 /** @var bool */ 17 private $inventoryEnabled; 18 /** @var Accrual|null */ 19 private $accrual; 20 /** @var string|null */ 21 private $self; 11 22 12 23 public function __construct( 13 24 $productGroupNumber = null, 25 $name = null, 26 $salesAccounts = null, 27 $products = null, 28 $inventoryEnabled = null, 29 $accrual = null, 14 30 $self = null 15 31 ) { … … 17 33 $this->parse_array( $productGroupNumber ); 18 34 } 19 20 $this->set_product_group_number( $productGroupNumber ); 21 $this->set_self( $self ); 35 if ( isset( $productGroupNumber ) ) { 36 $this->set_product_group_number( $productGroupNumber ); 37 } 38 if ( isset( $name ) ) { 39 $this->set_name( $name ); 40 } 41 if ( isset( $salesAccounts ) ) { 42 $this->set_sales_accounts( $salesAccounts ); 43 } 44 if ( isset( $products ) ) { 45 $this->set_products( $products ); 46 } 47 if ( isset( $inventoryEnabled ) ) { 48 $this->set_inventory_enabled( $inventoryEnabled ); 49 } 50 if ( isset( $accrual ) ) { 51 $this->set_accrual( $accrual ); 52 } 53 if ( isset( $self ) ) { 54 $this->set_self( $self ); 55 } 22 56 } 23 57 … … 26 60 */ 27 61 public function set_product_group_number( ?int $productGroupNumber ): void { 28 $this->productGroupNumber = $productGroupNumber ?? $this->productGroupNumber;62 $this->productGroupNumber = $productGroupNumber; 29 63 } 30 64 … … 36 70 } 37 71 72 /** 73 * @param string|null $salesAccounts 74 */ 75 public function set_sales_accounts( ?string $salesAccounts ): void { 76 $this->salesAccounts = $salesAccounts; 77 } 78 79 /** 80 * @return string|null 81 */ 82 public function get_sales_accounts(): ?string { 83 return $this->salesAccounts; 84 } 85 86 /** 87 * @param string|null $products 88 */ 89 public function set_products( ?string $products ): void { 90 $this->products = $products; 91 } 92 93 /** 94 * @return string|null 95 */ 96 public function get_products(): ?string { 97 return $this->products; 98 } 99 100 /** 101 * @param bool|int|string|null $inventoryEnabled 102 */ 103 public function set_inventory_enabled( $inventoryEnabled ): void { 104 if ( ! is_null( $inventoryEnabled ) ) { 105 $inventoryEnabled = filter_var( $inventoryEnabled, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 106 } 107 $this->inventoryEnabled = $inventoryEnabled; 108 } 109 110 /** 111 * @return bool 112 */ 113 public function is_inventory_enabled(): bool { 114 return $this->inventoryEnabled ?? false; 115 } 116 117 /** 118 * @param array|Accrual|null $accrual 119 */ 120 public function set_accrual( $accrual ): void { 121 if ( is_array( $accrual ) ) { 122 $accrual = new Accrual( $accrual ); 123 } 124 $this->accrual = $accrual; 125 } 126 127 /** 128 * @return Accrual 129 */ 130 public function get_accrual(): Accrual { 131 return $this->accrual ?? new Accrual(); 132 } 133 38 134 public function jsonSerialize(): array { 39 $vars = get_object_vars( $this ); 40 //$vars['self'] = $this->get_self(); 41 $vars = Util::filter_null_from( $vars ); 135 $vars = get_object_vars( $this ); 136 $vars = Util::filter_null_from( $vars ); 42 137 43 138 return $vars; -
miqid-woo/trunk/src/Includes/EConomic/DTO/Recipient.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 … … 28 27 private $vatZone; 29 28 30 public function __construct( 31 $publicEntryNumber = null, 32 $address = null, 33 $zip = null, 34 $city = null, 35 $country = null, 36 $ean = null, 37 $mobilePhone = null, 38 $nemHandelType = null, 39 $attention = null, 40 $vatZone = null, 41 $name = null, 42 $self = null 43 ) { 44 parent::__construct( $name, $self ); 45 46 if ( is_array( $publicEntryNumber ) ) { 47 $this->parse_array( $publicEntryNumber ); 29 public function __construct( ?array $Recipient = null ) { 30 if ( is_array( $Recipient ) ) { 31 $this->parse_array( $Recipient ); 48 32 } 49 50 $this->set_public_entry_number( $publicEntryNumber );51 $this->set_address( $address );52 $this->set_zip( $zip );53 $this->set_city( $city );54 $this->set_country( $country );55 $this->set_ean( $ean );56 $this->set_mobile_phone( $mobilePhone );57 $this->set_nem_handel_type( $nemHandelType );58 $this->set_attention( $attention );59 $this->set_vat_zone( $vatZone );60 33 } 61 34 62 35 /** 63 36 * @param string|null $publicEntryNumber 64 */ 65 public function set_public_entry_number( ?string $publicEntryNumber ): void { 66 $this->publicEntryNumber = $publicEntryNumber ?? $this->publicEntryNumber; 37 * 38 * @return Recipient 39 */ 40 public function set_public_entry_number( ?string $publicEntryNumber ): self { 41 $this->publicEntryNumber = $publicEntryNumber; 42 43 return $this; 67 44 } 68 45 69 46 /** 70 47 * @param string|null $address 71 */ 72 public function set_address( ?string $address ): void { 73 $this->address = $address ?? $this->address; 48 * 49 * @return Recipient 50 */ 51 public function set_address( ?string $address ): self { 52 $this->address = $address; 53 54 return $this; 74 55 } 75 56 76 57 /** 77 58 * @param string|null $zip 78 */ 79 public function set_zip( ?string $zip ): void { 80 $this->zip = $zip ?? $this->zip; 59 * 60 * @return Recipient 61 */ 62 public function set_zip( ?string $zip ): self { 63 $this->zip = $zip; 64 65 return $this; 81 66 } 82 67 83 68 /** 84 69 * @param string|null $city 85 */ 86 public function set_city( ?string $city ): void { 87 $this->city = $city ?? $this->city; 70 * 71 * @return Recipient 72 */ 73 public function set_city( ?string $city ): self { 74 $this->city = $city; 75 76 return $this; 88 77 } 89 78 90 79 /** 91 80 * @param string|null $country 92 */ 93 public function set_country( ?string $country ): void { 94 $this->country = $country ?? $this->country; 81 * 82 * @return Recipient 83 */ 84 public function set_country( ?string $country ): self { 85 $this->country = $country; 86 87 return $this; 95 88 } 96 89 97 90 /** 98 91 * @param string|null $ean 99 */ 100 public function set_ean( ?string $ean ): void { 101 $this->ean = $ean ?? $this->ean; 92 * 93 * @return Recipient 94 */ 95 public function set_ean( ?string $ean ): self { 96 $this->ean = $ean; 97 98 return $this; 102 99 } 103 100 104 101 /** 105 102 * @param string|null $mobilePhone 106 */ 107 public function set_mobile_phone( ?string $mobilePhone ): void { 108 $this->mobilePhone = $mobilePhone ?? $this->mobilePhone; 103 * 104 * @return Recipient 105 */ 106 public function set_mobile_phone( ?string $mobilePhone ): self { 107 $this->mobilePhone = $mobilePhone; 108 109 return $this; 109 110 } 110 111 111 112 /** 112 113 * @param string|null $nemHandelType 113 */ 114 public function set_nem_handel_type( ?string $nemHandelType ): void { 115 $this->nemHandelType = $nemHandelType ?? $this->nemHandelType; 114 * 115 * @return Recipient 116 */ 117 public function set_nem_handel_type( ?string $nemHandelType ): self { 118 $this->nemHandelType = $nemHandelType; 119 120 return $this; 116 121 } 117 122 118 123 /** 119 124 * @param Attention|array|null $attention 120 */ 121 public function set_attention( $attention ): void { 125 * 126 * @return Recipient 127 */ 128 public function set_attention( $attention ): self { 122 129 if ( is_array( $attention ) ) { 123 130 $attention = new Attention( $attention ); 124 131 } 125 $this->attention = $attention ?? $this->attention; 132 $this->attention = $attention; 133 134 return $this; 126 135 } 127 136 128 137 /** 129 138 * @param VatZone|array|null $vatZone 130 */ 131 public function set_vat_zone( $vatZone ): void { 139 * 140 * @return Recipient 141 */ 142 public function set_vat_zone( $vatZone ): self { 132 143 if ( is_array( $vatZone ) ) { 133 144 $vatZone = new VatZone( $vatZone ); 134 145 } 135 $this->vatZone = $vatZone ?? $this->vatZone; 146 $this->vatZone = $vatZone; 147 148 return $this; 136 149 } 137 150 -
miqid-woo/trunk/src/Includes/EConomic/DTO/SalesPerson.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 -
miqid-woo/trunk/src/Includes/EConomic/DTO/Unit.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 -
miqid-woo/trunk/src/Includes/EConomic/DTO/VatType.php
r2469411 r2495913 4 4 5 5 use MIQID\Plugin\WooCommerce\Util; 6 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;7 6 8 7 class VatType extends Base { 9 8 /** @var int|null */ 10 9 private $vatTypeNumber; 10 /** @var string|null */ 11 private $name; 12 /** @var string|null */ 13 private $self; 11 14 12 15 public function __construct( … … 15 18 $self = null 16 19 ) { 17 parent::__construct( $name, $self );18 19 20 if ( is_array( $vatTypeNumber ) ) { 20 21 $this->parse_array( $vatTypeNumber ); 21 22 } 22 23 $this->set_vat_type_number( $vatTypeNumber ); 23 if ( isset( $vatTypeNumber ) ) { 24 $this->set_vat_type_number( $vatTypeNumber ); 25 } 26 if ( isset( $name ) ) { 27 $this->set_name( $name ); 28 } 29 if ( isset( $self ) ) { 30 $this->set_self( $self ); 31 } 24 32 } 25 33 … … 28 36 */ 29 37 public function set_vat_type_number( ?int $vatTypeNumber ): void { 30 $this->vatTypeNumber = $vatTypeNumber ?? $this->vatTypeNumber;38 $this->vatTypeNumber = $vatTypeNumber; 31 39 } 32 40 -
miqid-woo/trunk/src/Includes/EConomic/DTO/VatZone.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 … … 9 8 /** @var int|null */ 10 9 private $vatZoneNumber; 10 /** @var string|null */ 11 private $name; 11 12 /** @var bool */ 12 13 private $enabledForCustomer; 13 14 /** @var bool */ 14 15 private $enabledForSupplier; 16 /** @var string|null */ 17 private $self; 15 18 16 19 public function __construct( 17 20 $vatZoneNumber = null, 21 $name = null, 18 22 $enabledForCustomer = null, 19 23 $enabledForSupplier = null, 20 $name = null,21 24 $self = null 22 25 ) { 23 parent::__construct( $name, $self );24 25 26 if ( is_array( $vatZoneNumber ) ) { 26 27 $this->parse_array( $vatZoneNumber ); 27 28 } 28 29 29 $this->set_vat_zone_number( $vatZoneNumber ); 30 $this->set_enabled_for_customer( $enabledForCustomer ); 31 $this->set_enabled_for_supplier( $enabledForSupplier ); 30 if ( isset( $vatZoneNumber ) ) { 31 $this->set_vat_zone_number( $vatZoneNumber ); 32 } 33 if ( isset( $name ) ) { 34 $this->set_name( $name ); 35 } 36 if ( isset( $enabledForCustomer ) ) { 37 $this->set_enabled_for_customer( $enabledForCustomer ); 38 } 39 if ( isset( $enabledForSupplier ) ) { 40 $this->set_enabled_for_supplier( $enabledForSupplier ); 41 } 42 if ( isset( $self ) ) { 43 $this->set_self( $self ); 44 } 32 45 } 33 46 … … 40 53 41 54 /** 42 * @param bool| null $enabledForCustomer55 * @param bool|int|string|null $enabledForCustomer 43 56 */ 44 public function set_enabled_for_customer( ?bool $enabledForCustomer ): void { 45 $this->enabledForCustomer = filter_var( $enabledForCustomer, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) ?? $this->enabledForCustomer; 57 public function set_enabled_for_customer( $enabledForCustomer ): void { 58 if ( ! is_null( $enabledForCustomer ) ) { 59 $enabledForCustomer = filter_var( $enabledForCustomer, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 60 } 61 $this->enabledForCustomer = $enabledForCustomer; 46 62 } 47 63 48 64 /** 49 * @param bool| null $enabledForSupplier65 * @param bool|int|string|null $enabledForSupplier 50 66 */ 51 public function set_enabled_for_supplier( ?bool $enabledForSupplier ): void { 52 $this->enabledForSupplier = filter_var( $enabledForSupplier, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) ?? $this->enabledForSupplier; 67 public function set_enabled_for_supplier( $enabledForSupplier ): void { 68 if ( ! is_null( $enabledForSupplier ) ) { 69 $enabledForSupplier = filter_var( $enabledForSupplier, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 70 } 71 $this->enabledForSupplier = $enabledForSupplier; 53 72 } 54 73 … … 75 94 76 95 public function jsonSerialize(): array { 77 $vars = get_object_vars( $this ); 78 $vars['name'] = $this->get_name(); 79 //$vars['self'] = $this->get_self(); 80 $vars = Util::filter_null_from( $vars ); 96 $vars = get_object_vars( $this ); 97 $vars = Util::filter_null_from( $vars ); 81 98 82 99 return $vars; -
miqid-woo/trunk/src/Includes/EConomic/DTO/objSelf.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO; 4 4 5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;6 5 use MIQID\Plugin\WooCommerce\Util; 7 6 -
miqid-woo/trunk/src/Includes/Extensions.php
r2469411 r2495913 12 12 /** @var bool */ 13 13 private $EConomic; 14 /** @var bool */ 15 private $Dinero; 14 16 15 17 public function __construct( … … 49 51 /** 50 52 * @param bool|int|string|null $EConomic 53 * 54 * @return self 51 55 */ 52 public function set_e_conomic( $EConomic ): void{56 public function set_e_conomic( $EConomic ): self { 53 57 if ( ! is_null( $EConomic ) ) { 54 58 $EConomic = filter_var( $EConomic, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 55 59 } 56 60 $this->EConomic = $EConomic ?? $this->EConomic; 61 62 return $this; 63 } 64 65 /** 66 * @param bool|int|string|null $Dinero 67 * 68 * @return self 69 */ 70 public function set_dinero( $Dinero ): self { 71 if ( ! is_null( $Dinero ) ) { 72 $Dinero = filter_var( $Dinero, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 73 } 74 $this->Dinero = $Dinero; 75 76 return $this; 57 77 } 58 78 … … 76 96 public function is_e_conomic(): bool { 77 97 return $this->EConomic ?? false; 98 } 99 100 /** 101 * @return bool 102 */ 103 public function is_dinero(): bool { 104 return $this->Dinero ?? false; 78 105 } 79 106 -
miqid-woo/trunk/src/Init.php
r2469411 r2495913 3 3 namespace MIQID\Plugin\WooCommerce; 4 4 5 use MIQID\Plugin\WooCommerce\Frontend\{Conditional_Shipping, EConomic, gtin};5 use MIQID\Plugin\WooCommerce\Frontend\{Conditional_Shipping, Dinero, EConomic, gtin}; 6 6 use MIQID\Plugin\WooCommerce\Includes\Extensions; 7 7 … … 33 33 } 34 34 35 /*if ( $this->extensions->is_e_conomic() ) {35 if ( $this->extensions->is_e_conomic() ) { 36 36 EConomic::Instance(); 37 }*/ 37 } 38 39 if ( $this->extensions->is_dinero() ) { 40 Dinero::Instance(); 41 } 38 42 39 43 if ( is_admin() ) {
Note: See TracChangeset
for help on using the changeset viewer.