Plugin Directory

Changeset 2495913


Ignore:
Timestamp:
03/15/2021 12:38:01 PM (5 years ago)
Author:
karlogitlea
Message:

Added EConomic / Dinero

Location:
miqid-woo/trunk
Files:
6 added
40 edited

Legend:

Unmodified
Added
Removed
  • miqid-woo/trunk/miqid-woo.php

    r2469422 r2495913  
    33 * Plugin Name:       MIQID-Woo
    44 * Description:       MIQID-Woo extension for WooCommerce.
    5  * Version:           1.1.2
     5 * Version:           1.6.3
    66 * Requires at least: 5.2
    77 * Requires PHP:      7.2
     
    1414
    1515require_once __DIR__ . '/vendor/autoload.php';
     16ini_set( 'serialize_precision', - 1 );
    1617
    1718\MIQID\Plugin\WooCommerce\Init::Instance();
  • miqid-woo/trunk/readme.md

    r2469422 r2495913  
    22Contributors: karlogit, miqid 
    33Tags: MIQID, gtin 
    4 Tested up to: 5.5.3 
     4Tested up to: 5.7 
    55Requires PHP: 7.2 
    6 Stable tag: 1.1.2 
     6Stable tag: 1.6.3 
    77License: GPL v3 or Later 
    88
  • miqid-woo/trunk/src/Admin/Admin.php

    r2469411 r2495913  
    55
    66use 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;
     7use MIQID\Plugin\WooCommerce\Includes\EConomic\{DTO\Account, DTO\Accrual};
    98use MIQID\Plugin\WooCommerce\Includes\Extensions;
    10 use MIQID\Plugin\WooCommerce\Util;
    119
    1210class Admin {
     
    3836        }
    3937
    40         /*if ( $this->extensions->is_e_conomic() ) {
     38        if ( $this->extensions->is_e_conomic() ) {
    4139            EConomic::Instance();
    42         }*/
     40        }
     41
     42        if ( $this->extensions->is_dinero() ) {
     43            Dinero::Instance();
     44        }
    4345    }
    4446
     
    6163            <h1 class="wp-heading-inline"><?= get_admin_page_title() ?></h1>
    6264            <hr class="wp-header-end"/>
     65            <p>Upload Test</p>
    6366            <form action="<?= esc_attr( admin_url( 'options.php' ) ) ?>" method="post">
    6467                <?php
     
    106109            ''
    107110        );
    108         /*add_settings_field(
     111        add_settings_field(
    109112            'e_conomic',
    110113            'e-conomic',
     
    116119            'miqid-woo',
    117120            ''
    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        );
    119133    }
    120134
  • miqid-woo/trunk/src/Frontend/EConomic.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Frontend;
    44
     5use Automattic\WooCommerce\Admin\DateTimeProvider\CurrentDateTimeProvider;
    56use 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};
     7use 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};
    78
    89class EConomic {
     
    2728        $this->sync_completed  = filter_var( get_option( Util::generate_id( self::SECTION_SETTINGS, 'sync', 'completed' ) ), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE );
    2829
    29         /*if ( $this->sync_processing ) {
     30        if ( $this->sync_processing ) {
    3031            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        }
    3236    }
    3337
     
    7478        }
    7579
    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() ) ) {
    8898            $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
    137103
    138104        $LineNumber = 1;
     
    142108            /** @var \WC_Product|bool $wc_product */
    143109            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() ) ) {
    152130                    $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() );
    171142            }
    172143        }
     
    174145        /** @var \WC_Order_Item_Shipping $order_item */
    175146        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() ) ) {
    185170                $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 );
    189173            }
    190174
     
    199183        }
    200184
    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 );
    207259        }
    208260    }
  • miqid-woo/trunk/src/Includes/DTO/Base.php

    r2469411 r2495913  
    66    public function __construct( $must_be_null = null ) {
    77        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 ) ) );
    99        }
    1010    }
  • miqid-woo/trunk/src/Includes/Dinero/API/Base.php

    r2469411 r2495913  
    1414        $headers = wp_parse_args( $headers, [
    1515            'Content-Type'  => 'application/json',
    16             'Authorization' => sprintf( 'bearer %s', $this->Authenticate() ),
     16            'Authorization' => sprintf( 'bearer %s', $this->Authenticate()['access_token'] ?? '' ),
    1717        ] );
    1818
     
    3333        $headers = wp_parse_args( $headers, [
    3434            'Content-Type'  => 'application/json',
    35             'Authorization' => sprintf( 'bearer %s', $this->Authenticate() ),
     35            'Authorization' => sprintf( 'bearer %s', $this->Authenticate()['access_token'] ?? '' ),
    3636        ] );
    3737
     
    4848    protected function GetEndpoint( ...$endpoint ): string {
    4949        $class = $this;
     50        if ( empty( $endpoint ) ) {
     51            try {
     52                $endpoint[] = ( new \ReflectionClass( $this ) )->getShortName();
     53            } catch ( \ReflectionException $e ) {
    5054
    51         try {
    52             $class = new \ReflectionClass( $this );
    53             if ( empty( $endpoint ) ) {
    54                 $endpoint[] = $class->getShortName();
    5555            }
    56         } catch ( \ReflectionException $e ) {
    57 
    5856        }
    5957
     
    6563    private $authenticate;
    6664
     65    /**
     66     * @return array|null
     67     */
    6768    public function Authenticate() {
    6869        if ( is_null( $this->authenticate ) ) {
     
    7071                'headers' => [
    7172                    '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                        ) ),
    7377                ],
    7478                'method'  => 'POST',
    7579                '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' ) ),
    7882                    'scope'      => 'read write',
    7983                    'grant_type' => 'password',
     84                    //8CjPGo3m6Qp9JO79qVuPsCfUA02Lvvz!
    8085                ] ),
    8186            ] );
     
    8691        }
    8792
    88         return $this->authenticate['access_token'] ?? '';
     93        return $this->authenticate;
    8994    }
    9095
    91     protected function GetOrganizationId(){
    92         return 320738;
     96    protected function GetOrganizationId() {
     97        return get_option( Util::generate_id( 'dinero', 'access', 'organization_id' ) );//320738;
    9398    }
    9499}
  • miqid-woo/trunk/src/Includes/Dinero/API/Contacts.php

    r2469411 r2495913  
    3232                'fields'      => $fields,
    3333                'queryFilter' => $queryFilter,
    34             ], $this->GetEndpoint( 320738, 'contacts' ) )
     34            ], $this->GetEndpoint( $this->GetOrganizationId(), 'contacts' ) )
    3535        );
    3636
     
    4949    function CreateContact( Contact $contact ) {
    5050        $HttpReponse = $this->RemotePost(
    51             $this->GetEndpoint( 320738, 'contacts' ),
     51            $this->GetEndpoint( $this->GetOrganizationId(), 'contacts' ),
    5252            $contact
    5353        );
    5454
    5555        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'] );
    5757        }
    5858
     
    6767    function GetContact( $guid ) {
    6868        $HttpResponse = $this->RemoteGet(
    69             $this->GetEndpoint( 320738, 'contacts', $guid ),
     69            $this->GetEndpoint( $this->GetOrganizationId(), 'contacts', $guid )
    7070        );
    7171
     
    7979    function UpdateContact( $guid, Contact $contact ) {
    8080        $httpResponse = $this->RemotePost(
    81             $this->GetEndpoint( 320738, 'contacts', $guid ),
     81            $this->GetEndpoint( $this->GetOrganizationId(), 'contacts', $guid ),
    8282            $contact,
    8383            [],
  • miqid-woo/trunk/src/Includes/Dinero/API/Invoices.php

    r2469411 r2495913  
    3232
    3333        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'] );
    3535        }
    3636
     
    8989    function UpdateInvoice( $guid, Invoice $invoice ) {
    9090        $HttpResponse = $this->RemotePost(
    91             strtr( $this->GetEndpoint( $this->GetOrganizationId(), 'invoices' ), [ '/v1/' => '/v1.2/' ] ),
     91            strtr( $this->GetEndpoint( $this->GetOrganizationId(), 'invoices', $guid ), [ '/v1/' => '/v1.2/' ] ),
    9292            $invoice,
    9393            [],
     
    9696
    9797        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 );
    99122        }
    100123
  • miqid-woo/trunk/src/Includes/Dinero/API/Products.php

    r2469411 r2495913  
    2828    function GetProduct( $guid ) {
    2929        $HttpResponse = $this->RemoteGet(
    30             $this->GetEndpoint( 320738, 'products', $guid )
     30            $this->GetEndpoint( $this->GetOrganizationId(), 'products', $guid )
    3131        );
    3232
     
    4646    function UpdateProduct( $guid, Product $product ) {
    4747        $HttpResponse = $this->RemotePost(
    48             $this->GetEndpoint( 320738, 'products', $guid ),
     48            $this->GetEndpoint( $this->GetOrganizationId(), 'products', $guid ),
    4949            $product,
    5050            [],
  • miqid-woo/trunk/src/Includes/Dinero/DTO/Contact.php

    r2469411 r2495913  
    55use DateTime;
    66use MIQID\Plugin\WooCommerce\Includes\Dinero\DTO;
     7use MIQID\Plugin\WooCommerce\Util;
    78
    89class Contact extends DTO {
     
    693694    public function jsonSerialize() {
    694695        $vars = get_object_vars( $this );
     696        $vars = Util::filter_null_from( $vars );
    695697
    696698        return $vars;
  • miqid-woo/trunk/src/Includes/Dinero/DTO/Invoice.php

    r2469411 r2495913  
    55use DateTime;
    66use MIQID\Plugin\WooCommerce\Includes\Dinero\DTO;
     7use MIQID\Plugin\WooCommerce\Util;
    78
    89class Invoice extends DTO {
    910    /** @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;
    1120    /** @var string|null */
    1221    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 */
    2223    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;
    3340    /** @var int|null */
    3441    private $PaymentConditionNumberOfDays;
    3542    /** @var string|null */
    3643    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;
    3778    /** @var bool */
    3879    private $IsMobilePayInvoiceEnabled;
    3980
    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;
    49175    }
    50176
     
    54180     * @return Invoice
    55181     */
    56     public function set_currency( ?string $Currency ): Invoice {
     182    public function set_currency( ?string $Currency ): self {
    57183        $this->Currency = $Currency;
    58184
     
    61187
    62188    /**
    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;
    104193    }
    105194
     
    109198     * @return Invoice
    110199     */
    111     public function set_date( $Date ): Invoice {
     200    public function set_date( $Date ): self {
    112201        if ( is_string( $Date ) ) {
    113202            $Date = date_create( $Date );
     
    119208
    120209    /**
    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;
    183394    }
    184395
     
    188399     * @return Invoice
    189400     */
    190     public function set_payment_condition_number_of_days( ?int $PaymentConditionNumberOfDays ): Invoice {
     401    public function set_payment_condition_number_of_days( ?int $PaymentConditionNumberOfDays ): self {
    191402        $this->PaymentConditionNumberOfDays = $PaymentConditionNumberOfDays;
    192403
     
    195406
    196407    /**
     408     * @return int|null
     409     */
     410    public function get_payment_condition_number_of_days(): ?int {
     411        return $this->PaymentConditionNumberOfDays;
     412    }
     413
     414    /**
    197415     * @param string|null $PaymentConditionType
    198416     *
    199417     * @return Invoice
    200418     */
    201     public function set_payment_condition_type( ?string $PaymentConditionType ): Invoice {
     419    public function set_payment_condition_type( ?string $PaymentConditionType ): self {
    202420        $this->PaymentConditionType = $PaymentConditionType;
    203421
     
    206424
    207425    /**
    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;
    244495    }
    245496
     
    252503
    253504    /**
     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    /**
    254516     * @return string|null
    255517     */
     
    259521
    260522    /**
    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;
    278531    }
    279532
     
    286539
    287540    /**
     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    /**
    288732     * @return bool
    289733     */
    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;
    320747    }
    321748
     
    323750     * @return bool
    324751     */
    325     public function is_is_mobile_pay_invoice_enabled(): bool {
     752    public function is_mobile_pay_invoice_enabled(): bool {
    326753        return $this->IsMobilePayInvoiceEnabled;
    327754    }
     755
    328756
    329757    public function jsonSerialize() {
    330758        $vars         = get_object_vars( $this );
    331759        $vars['Date'] = $this->get_date( 'Y-m-d' );
     760        $vars         = Util::filter_null_from( $vars );
    332761
    333762        return $vars;
  • miqid-woo/trunk/src/Includes/Dinero/DTO/Product.php

    r2469411 r2495913  
    66
    77class Product extends DTO {
     8    const WithVAT    = 1000;
     9    const WithoutVAT = 1050;
     10
    811    /** @var string|null */
    912    protected $ProductGuid;
  • miqid-woo/trunk/src/Includes/Dinero/DTO/ProductLine.php

    r2469411 r2495913  
    44
    55use MIQID\Plugin\WooCommerce\Includes\Dinero\DTO;
     6use MIQID\Plugin\WooCommerce\Util;
    67
    78class ProductLine extends DTO {
     
    233234    public function jsonSerialize() {
    234235        $vars = get_object_vars( $this );
     236        $vars = Util::filter_null_from( $vars );
    235237
    236238        return $vars;
  • miqid-woo/trunk/src/Includes/EConomic/API/Base.php

    r2469411 r2495913  
    1010    abstract static function Instance();
    1111
    12     protected function RemoteGet( $url, array $headers = [], array $args = [] ): ?HttpResponse {
     12    protected function RemoteGet( $url, array $headers = [], array $args = [] ): HttpResponse {
    1313
    1414        $headers = wp_parse_args( $headers, [
     
    2626    }
    2727
    28     protected function RemotePost( $url, $body = null, array $headers = [], array $args = [] ): ?HttpResponse {
     28    protected function RemotePost( $url, $body = null, array $headers = [], array $args = [] ): HttpResponse {
    2929
    3030        if ( is_array( $body ) || is_object( $body ) ) {
  • miqid-woo/trunk/src/Includes/EConomic/API/Orders.php

    r2469411 r2495913  
    4747    function GetDrafts( $orderNumber = null, $filter = null ) {
    4848        $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
    5050        );
    5151
     
    9898        return $HttpResponse;
    9999    }
     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    }
    100113}
  • miqid-woo/trunk/src/Includes/EConomic/API/ProductGroups.php

    r2469411 r2495913  
    88class ProductGroups extends Base {
    99    private static $_instance;
     10
     11    const Product_With_Vat    = 1;
     12    const Product_Without_Vat = 2;
    1013
    1114    public static function Instance() {
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Account.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
     
    1918    /** @var bool */
    2019    private $blockDirectEntries;
    21     /** @var array|null */
     20    /** @var Account|null */
    2221    private $contraAccount;
    2322    /** @var string|null */
    2423    private $debitCredit;
     24    /** @var string|null */
     25    private $name;
    2526    /** @var array|null */
    2627    private $vatAccount;
    2728    /** @var array|null */
    2829    private $accountsSummed;
    29     /** @var array|null */
     30    /** @var Account|null */
    3031    private $totalFromAccount;
    3132    /** @var string|null */
    3233    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        }
    8341    }
    8442
     
    8745     */
    8846    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;
    16748    }
    16849
     
    17556
    17657    /**
     58     * @param string|null $accountType
     59     */
     60    public function set_account_type( ?string $accountType ): void {
     61        $this->accountType = $accountType;
     62    }
     63
     64    /**
    17765     * @return string|null
    17866     */
     
    18270
    18371    /**
     72     * @param float|null $balance
     73     */
     74    public function set_balance( ?float $balance ): void {
     75        $this->balance = $balance;
     76    }
     77
     78    /**
    18479     * @return float|null
    18580     */
     
    18984
    19085    /**
     86     * @param float|null $draftBalance
     87     */
     88    public function set_draft_balance( ?float $draftBalance ): void {
     89        $this->draftBalance = $draftBalance;
     90    }
     91
     92    /**
    19193     * @return float|null
    19294     */
     
    19698
    19799    /**
     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    /**
    198110     * @return bool
    199111     */
     
    203115
    204116    /**
     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    /**
    205127     * @return bool
    206128     */
     
    210132
    211133    /**
    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;
    216155    }
    217156
     
    224163
    225164    /**
     165     * @param array|null $vatAccount
     166     */
     167    public function set_vat_account( ?array $vatAccount ): void {
     168        $this->vatAccount = $vatAccount;
     169    }
     170
     171    /**
    226172     * @return array|null
    227173     */
     
    231177
    232178    /**
     179     * @param array|null $accountsSummed
     180     */
     181    public function set_accounts_summed( ?array $accountsSummed ): void {
     182        $this->accountsSummed = $accountsSummed;
     183    }
     184
     185    /**
    233186     * @return array|null
    234187     */
     
    238191
    239192    /**
    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;
    244214    }
    245215
     
    252222
    253223    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 );
    256226
    257227        return $vars;
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Accrual.php

    r2469411 r2495913  
    44
    55use DateTime;
    6 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    76use MIQID\Plugin\WooCommerce\Util;
    87
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Attention.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Currency.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Customer.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
     
    5857    private $zip;
    5958
    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        }
    11863    }
    11964
    12065    /**
    12166     * @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;
    12574    }
    12675
    12776    /**
    12877     * @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;
    13285    }
    13386
    13487    /**
    13588     * @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;
    13996    }
    14097
    14198    /**
    14299     * @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;
    146107    }
    147108
    148109    /**
    149110     * @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;
    153118    }
    154119
    155120    /**
    156121     * @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;
    160129    }
    161130
    162131    /**
    163132     * @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;
    167140    }
    168141
    169142    /**
    170143     * @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 {
    173148        if ( is_array( $currency ) || is_string( $currency ) ) {
    174149            $currency = new Currency( $currency );
    175150        }
    176         $this->currency = $currency ?? $this->currency;
     151        $this->currency = $currency;
     152
     153        return $this;
    177154    }
    178155
    179156    /**
    180157     * @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 {
    183162        if ( is_array( $customerGroup ) ) {
    184163            $customerGroup = new CustomerGroup( $customerGroup );
    185164        }
    186         $this->customerGroup = $customerGroup ?? $this->customerGroup;
     165        $this->customerGroup = $customerGroup;
     166
     167        return $this;
    187168    }
    188169
    189170    /**
    190171     * @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;
    194179    }
    195180
    196181    /**
    197182     * @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;
    201190    }
    202191
    203192    /**
    204193     * @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;
    208201    }
    209202
    210203    /**
    211204     * @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;
    215212    }
    216213
    217214    /**
    218215     * @param array|Layout $layout
    219      */
    220     public function set_layout( $layout ): void {
     216     *
     217     * @return Customer
     218     */
     219    public function set_layout( $layout ): self {
    221220        if ( is_array( $layout ) ) {
    222221            $layout = new Layout( $layout );
    223222        }
    224         $this->layout = $layout ?? $this->layout;
     223        $this->layout = $layout;
     224
     225        return $this;
    225226    }
    226227
    227228    /**
    228229     * @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;
    232237    }
    233238
    234239    /**
    235240     * @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;
    239248    }
    240249
    241250    /**
    242251     * @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 {
    245256        if ( is_array( $paymentTerms ) ) {
    246257            $paymentTerms = new PaymentTerm( $paymentTerms );
    247258        }
    248         $this->paymentTerms = $paymentTerms ?? $this->paymentTerms;
     259        $this->paymentTerms = $paymentTerms;
     260
     261        return $this;
    249262    }
    250263
    251264    /**
    252265     * @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;
    256273    }
    257274
    258275    /**
    259276     * @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;
    263284    }
    264285
    265286    /**
    266287     * @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 {
    269292        if ( is_array( $salesPerson ) ) {
    270293            $salesPerson = new SalesPerson( $salesPerson );
    271294        }
    272         $this->salesPerson = $salesPerson ?? $this->salesPerson;
     295        $this->salesPerson = $salesPerson;
     296
     297        return $this;
    273298    }
    274299
    275300    /**
    276301     * @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;
    280309    }
    281310
    282311    /**
    283312     * @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;
    287320    }
    288321
    289322    /**
    290323     * @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 {
    293328        if ( is_array( $vatZone ) ) {
    294329            $vatZone = new VatZone( $vatZone );
    295330        }
    296         $this->vatZone = $vatZone ?? $this->vatZone;
     331        $this->vatZone = $vatZone;
     332
     333        return $this;
    297334    }
    298335
    299336    /**
    300337     * @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;
    304345    }
    305346
    306347    /**
    307348     * @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;
    311356    }
    312357
     
    489534        $vars             = get_object_vars( $this );
    490535        $vars['currency'] = $this->get_currency()->get_code();
    491         //$vars['self']     = $this->get_self();
    492536        $vars             = Util::filter_null_from( $vars );
    493537
  • miqid-woo/trunk/src/Includes/EConomic/DTO/CustomerGroup.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
     
    1312    /** @var Account|null */
    1413    private $account;
    15     /** @var Customer|string|null */
     14    /** @var string|null */
    1615    private $customers;
    1716    /** @var Layout|null */
    1817    private $layout;
     18    /** @var string|null */
     19    private $self;
    1920
    2021    public function __construct(
     
    2627        $self = null
    2728    ) {
    28         parent::__construct( $self );
    29 
    3029        if ( is_array( $customerGroupNumber ) ) {
    3130            $this->parse_array( $customerGroupNumber );
    3231        }
    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        }
    3950    }
    4051
    4152    /**
    4253     * @param int|null $customerGroupNumber
     54     *
     55     * @return CustomerGroup
    4356     */
    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;
    4759
    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;
    8361    }
    8462
     
    9169
    9270    /**
    93      * @return string|null
     71     * @param array|Account|null $account
     72     *
     73     * @return CustomerGroup
    9474     */
    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;
    9782    }
    9883
    9984    /**
    100      * @return Account|null
     85     * @return Account
    10186     */
    10287    public function get_account(): Account {
     
    10590
    10691    /**
    107      * @return Customer|string
     92     * @param string|null $customers
     93     *
     94     * @return CustomerGroup
    10895     */
    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;
    111100    }
    112101
    113102    /**
    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
    115125     */
    116126    public function get_layout(): Layout {
     
    119129
    120130    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 );
    124133
    125134        return $arr;
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Delivery.php

    r2469411 r2495913  
    44
    55use DateTime;
    6 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    76use MIQID\Plugin\WooCommerce\Util;
    87
     
    2120    private $zip;
    2221
     22    public function __construct( ?array $Delivery = null ) {
     23        if ( is_array( $Delivery ) ) {
     24            $this->parse_array( $Delivery );
     25        }
     26    }
     27
     28
    2329    /**
    2430     * @param string|null $address
    2531     */
    2632    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;
    6634    }
    6735
     
    7442
    7543    /**
     44     * @param string|null $city
     45     */
     46    public function set_city( ?string $city ): void {
     47        $this->city = $city;
     48    }
     49
     50    /**
    7651     * @return string|null
    7752     */
    7853    public function get_city(): ?string {
    7954        return $this->city;
     55    }
     56
     57    /**
     58     * @param string|null $country
     59     */
     60    public function set_country( ?string $country ): void {
     61        $this->country = $country;
    8062    }
    8163
     
    8870
    8971    /**
     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     *
    9084     * @return DateTime|string|null
    9185     */
    92     public function get_delivery_date( $format = null ) {
     86    public function get_delivery_date( ?string $format = null ) {
    9387        if ( $this->deliveryDate instanceof DateTime && ! empty( $format ) ) {
    9488            return $this->deliveryDate->format( $format );
     
    9690
    9791        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;
    9899    }
    99100
     
    106107
    107108    /**
     109     * @param string|null $zip
     110     */
     111    public function set_zip( ?string $zip ): void {
     112        $this->zip = $zip;
     113    }
     114
     115    /**
    108116     * @return string|null
    109117     */
     
    113121
    114122    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 );
    118126
    119         return $arr;
     127        return $vars;
    120128    }
    121129}
  • miqid-woo/trunk/src/Includes/EConomic/DTO/DeliveryLocation.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
  • miqid-woo/trunk/src/Includes/EConomic/DTO/DepartmentalDistribution.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
     
    1312    /** @var string|null */
    1413    private $distributionType;
     14    /** @var array|null */
     15    private $distributions;
     16    /** @var string|null */
     17    private $self;
    1518
    1619    public function __construct(
     
    1821        $name = null,
    1922        $distributionType = null,
     23        $distributions = null,
    2024        $self = null
    2125    ) {
    22         parent::__construct( $self );
    23 
    2426        if ( is_array( $departmentalDistributionNumber ) ) {
    2527            $this->parse_array( $departmentalDistributionNumber );
    2628        }
    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        }
    3144    }
    3245
     
    3548     */
    3649    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;
    5251    }
    5352
     
    6059
    6160    /**
    62      * @return string|null
     61     * @param string|null $distributionType
    6362     */
    64     public function get_name(): ?string {
    65         return $this->name;
     63    public function set_distribution_type( ?string $distributionType ): void {
     64        $this->distributionType = $distributionType;
    6665    }
    6766
     
    7372    }
    7473
     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
    7588    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 );
    7991
    8092        return $arr;
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Inventory.php

    r2469411 r2495913  
    44
    55
    6 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
     6use DateTime;
    77use MIQID\Plugin\WooCommerce\Util;
    88
    99class Inventory extends Base {
    10     /** @var int|null */
     10    /** @var float|null */
    1111    private $available;
    1212    /** @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 */
    1321    private $grossWeight;
    14     /** @var int|null */
    15     private $inStock;
    1622    /** @var float|null */
    1723    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;
    2426    /** @var float|null */
    2527    private $recommendedCostPrice;
    2628
    27     /**
    28      * Inventory constructor.
    29      *
    30      * @param array|int|null $available
    31      * @param float|null $grossWeight
    32      * @param int|null $inStock
    33      * @param float|null $netWeight
    34      * @param int|null $orderedByCustomers
    35      * @param int|null $orderedFromSuppliers
    36      * @param int|null $packageVolume
    37      * @param float|null $recommendedCostPrice
    38      */
    3929    public function __construct(
    4030        $available = null,
    41         $grossWeight = null,
    4231        $inStock = null,
    43         $netWeight = null,
    4432        $orderedByCustomers = null,
    4533        $orderedFromSuppliers = null,
    4634        $packageVolume = null,
     35        $grossWeight = null,
     36        $netWeight = null,
     37        $inventoryLastUpdated = null,
    4738        $recommendedCostPrice = null
    4839    ) {
     
    5041            $this->parse_array( $available );
    5142        }
    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;
    67160    }
    68161
    69162    /**
    70163     * @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;
    123171    }
    124172
     
    131179
    132180    /**
    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;
    137189    }
    138190
     
    145197
    146198    /**
    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;
    165228    }
    166229
     
    173236
    174237    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 );
    178240
    179241        return $arr;
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Layout.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
     
    1110    /** @var string|null */
    1211    private $name;
    13     /** @var bool|null */
     12    /** @var bool */
    1413    private $deleted;
     14    /** @var string|null */
     15    private $self;
    1516
    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 );
    2420        }
    25 
    26         $this->set_layout_number( $LayoutNumber );
    27         $this->set_name( $name );
    28         $this->set_deleted( $deleted );
    29         $this->set_self( $Self );
    3021    }
    3122
    3223    /**
    3324     * @param int|null $layoutNumber
     25     *
     26     * @return Layout
    3427     */
    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;
    3732    }
    3833
    3934    /**
    40      * @param string|null $name
     35     * @param bool|int|string|null $deleted
     36     *
     37     * @return Layout
    4138     */
    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;
    4544
    46     /**
    47      * @param bool|null $deleted
    48      */
    49     public function set_deleted( ?bool $deleted ): void {
    50         $this->deleted = $deleted ?? $this->deleted;
     45        return $this;
    5146    }
    5247
     
    5954
    6055    /**
    61      * @return string|null
     56     * @return bool
    6257     */
    63     public function get_name(): ?string {
    64         return $this->name;
     58    public function is_deleted(): bool {
     59        return $this->deleted ?? false;
    6560    }
    6661
    67     /**
    68      * @return bool|null
    69      */
    70     public function get_deleted(): ?bool {
    71         return $this->deleted;
    72     }
    7362
    7463    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 );
    7866
    7967        return $arr;
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Line.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
     
    3433    private $departmentalDistribution;
    3534
    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        }
    6839    }
    6940
    7041    /**
    7142     * @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 {
    7447        if ( is_array( $accrual ) ) {
    7548            $accrual = new Accrual( $accrual );
    7649        }
    77         $this->accrual = $accrual ?? $this->accrual;
     50        $this->accrual = $accrual;
     51
     52        return $this;
    7853    }
    7954
    8055    /**
    8156     * @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 {
    8461        if ( is_array( $departmentalDistribution ) ) {
    8562            $departmentalDistribution = new DepartmentalDistribution( $departmentalDistribution );
    8663        }
    87         $this->departmentalDistribution = $departmentalDistribution ?? $this->departmentalDistribution;
     64        $this->departmentalDistribution = $departmentalDistribution;
     65
     66        return $this;
    8867    }
    8968
    9069    /**
    9170     * @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;
    9578    }
    9679
    9780    /**
    9881     * @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;
    10289    }
    10390
    10491    /**
    10592     * @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;
    109100    }
    110101
    111102    /**
    112103     * @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;
    116111    }
    117112
    118113    /**
    119114     * @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;
    123122    }
    124123
    125124    /**
    126125     * @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 {
    129130        if ( is_array( $product ) ) {
    130131            $product = new Product( $product );
    131132        }
    132         $this->product = $product ?? $this->product;
     133        $this->product = $product;
     134
     135        return $this;
    133136    }
    134137
    135138    /**
    136139     * @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;
    140147    }
    141148
    142149    /**
    143150     * @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;
    147158    }
    148159
    149160    /**
    150161     * @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 {
    153166        if ( is_array( $unit ) ) {
    154167            $unit = new Unit( $unit );
    155168        }
    156         $this->unit = $unit ?? $this->unit;
     169        $this->unit = $unit;
     170
     171        return $this;
    157172    }
    158173
    159174    /**
    160175     * @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;
    164183    }
    165184
    166185    /**
    167186     * @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;
    171194    }
    172195
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Order.php

    r2469411 r2495913  
    44
    55use DateTime;
    6 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    76use MIQID\Plugin\WooCommerce\Util;
    87
     
    6564    private $lines;
    6665
    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        }
    13070    }
    13171
    13272    /**
    13373     * @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;
    13781    }
    13882
    13983    /**
    14084     * @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 {
    14389        if ( is_string( $date ) ) {
    14490            $date = date_create( $date );
    14591        }
    146         $this->date = $date ?? $this->date;
     92        $this->date = $date;
     93
     94        return $this;
    14795    }
    14896
    14997    /**
    15098     * @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 {
    153103        if ( is_array( $currency ) || is_string( $currency ) ) {
    154104            $currency = new Currency( $currency );
    155105        }
    156         $this->currency = $currency ?? $this->currency;
     106        $this->currency = $currency;
     107
     108        return $this;
    157109    }
    158110
    159111    /**
    160112     * @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;
    164120    }
    165121
    166122    /**
    167123     * @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;
    171131    }
    172132
    173133    /**
    174134     * @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;
    178142    }
    179143
    180144    /**
    181145     * @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;
    185153    }
    186154
    187155    /**
    188156     * @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;
    192164    }
    193165
    194166    /**
    195167     * @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;
    199175    }
    200176
    201177    /**
    202178     * @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;
    206186    }
    207187
    208188    /**
    209189     * @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;
    213197    }
    214198
    215199    /**
    216200     * @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;
    220208    }
    221209
    222210    /**
    223211     * @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;
    227219    }
    228220
    229221    /**
    230222     * @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 {
    233227        if ( is_string( $dueDate ) ) {
    234228            $dueDate = date_create( $dueDate );
    235229        }
    236         $this->dueDate = $dueDate ?? $this->dueDate;
     230        $this->dueDate = $dueDate;
     231
     232        return $this;
    237233    }
    238234
    239235    /**
    240236     * @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 {
    243241        if ( is_array( $paymentTerms ) ) {
    244242            $paymentTerms = new PaymentTerm( $paymentTerms );
    245243        }
    246         $this->paymentTerms = $paymentTerms ?? $this->paymentTerms;
     244        $this->paymentTerms = $paymentTerms;
     245
     246        return $this;
    247247    }
    248248
    249249    /**
    250250     * @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 {
    253255        if ( is_array( $customer ) ) {
    254256            $customer = new Customer( $customer );
    255257        }
    256         $this->customer = $customer ?? $this->customer;
     258        $this->customer = $customer;
     259
     260        return $this;
    257261    }
    258262
    259263    /**
    260264     * @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 {
    263269        if ( is_array( $recipient ) ) {
    264270            $recipient = new Recipient( $recipient );
    265271        }
    266         $this->recipient = $recipient ?? $this->recipient;
     272        $this->recipient = $recipient;
     273
     274        return $this;
    267275    }
    268276
    269277    /**
    270278     * @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 {
    273283        if ( is_array( $deliveryLocation ) ) {
    274284            $deliveryLocation = new DeliveryLocation( $deliveryLocation );
    275285        }
    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 {
    283297        if ( is_array( $delivery ) ) {
    284298            $delivery = new Delivery( $delivery );
    285299        }
    286         $this->delivery = $delivery ?? $this->delivery;
     300        $this->delivery = $delivery;
     301
     302        return $this;
    287303    }
    288304
    289305    /**
    290306     * @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;
    294314    }
    295315
    296316    /**
    297317     * @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;
    301325    }
    302326
    303327    /**
    304328     * @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;
    308336    }
    309337
    310338    /**
    311339     * @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;
    315347    }
    316348
    317349    /**
    318350     * @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;
    322358    }
    323359
    324360    /**
    325361     * @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;
    329369    }
    330370
    331371    /**
    332372     * @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;
    336380    }
    337381
    338382    /**
    339383     * @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 {
    342388        if ( is_array( $layout ) ) {
    343389            $layout = new Layout( $layout );
    344390        }
    345         $this->layout = $layout ?? $this->layout;
     391        $this->layout = $layout;
     392
     393        return $this;
    346394    }
    347395
     
    548596        $vars['dueDate']      = $this->get_due_date( 'Y-m-d' );
    549597        $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() );
    553601        $vars                 = Util::filter_null_from( $vars );
    554602
  • miqid-woo/trunk/src/Includes/EConomic/DTO/PaymentTerm.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
     
    1312    /** @var string|null */
    1413    private $description;
    15     /** @var string|null */
     14    /** @var string */
    1615    private $paymentTermsType;
     16    /** @var Account */
     17    private $contraAccountForPrepaidAmount;
     18    /** @var Account */
     19    private $contraAccountForRemainderAmount;
    1720    /** @var float|null */
    1821    private $percentageForPrepaidAmount;
    1922    /** @var float|null */
    2023    private $percentageForRemainderAmount;
    21     /** @var array|null */
     24    /** @var array */
    2225    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 );
    4530        }
    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 );
    5631    }
    5732
    5833    /**
    5934     * @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;
    6342    }
    6443
    6544    /**
    6645     * @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;
    7053    }
    7154
    7255    /**
    7356     * @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;
    7764    }
    7865
    7966    /**
    8067     * @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;
    8497    }
    8598
    8699    /**
    87100     * @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;
    91108    }
    92109
    93110    /**
    94111     * @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;
    98119    }
    99120
    100121    /**
    101122     * @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;
    119130    }
    120131
     
    186197        $arr['name'] = $this->get_name();
    187198        //$arr['self'] = $this->get_self();
    188         $arr         = Util::filter_null_from( $arr );
     199        $arr = Util::filter_null_from( $arr );
    189200
    190201        return $arr;
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Product.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
     5use DateTime;
    66use MIQID\Plugin\WooCommerce\Util;
    77
    88class Product extends Base {
    99    /** @var string|null */
    10     private $barCode;
    11     /** @var bool|null */
    12     private $barred;
     10    private $productNumber;
     11    /** @var string|null */
     12    private $description;
    1313    /** @var float|null */
    1414    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;
    2715    /** @var float|null */
    2816    private $recommendedPrice;
    2917    /** @var float|null */
    3018    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 */
    3230    private $unit;
     31    /** @var ProductGroup */
     32    private $productGroup;
     33    /** @var DepartmentalDistribution */
     34    private $departmentalDistribution;
     35    /** @var string|null */
     36    private $self;
    3337
    3438    public function __construct(
     39        $productNumber = null,
     40        $description = null,
     41        $name = null,
     42        $costPrice = null,
     43        $recommendedPrice = null,
     44        $salesPrice = null,
    3545        $barCode = null,
    3646        $barred = null,
    37         $costPrice = null,
     47        $lastUpdated = null,
     48        $invoices = null,
     49        $inventory = null,
     50        $unit = null,
     51        $productGroup = null,
    3852        $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
    4754    ) {
    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;
    64193    }
    65194
    66195    /**
    67196     * @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();
    85335    }
    86336
    87337    /**
    88338     * @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 {
    91343        if ( is_array( $departmentalDistribution ) ) {
    92344            $departmentalDistribution = new DepartmentalDistribution( $departmentalDistribution );
    93345        }
    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;
    181349    }
    182350
     
    188356    }
    189357
    190     /**
    191      * @return string|null
    192      */
    193     public function get_description(): ?string {
    194         return $this->description;
    195     }
    196 
    197     /**
    198      * @return Inventory
    199      */
    200     public function get_inventory(): Inventory {
    201         return $this->inventory ?? new Inventory();
    202     }
    203 
    204     /**
    205      * @return string|null
    206      */
    207     public function get_name(): ?string {
    208         return $this->name;
    209     }
    210 
    211     /**
    212      * @return ProductGroup
    213      */
    214     public function get_product_group(): ProductGroup {
    215         return $this->productGroup ?? new ProductGroup();
    216     }
    217 
    218     /**
    219      * @return string|null
    220      */
    221     public function get_product_number(): ?string {
    222         return $this->productNumber;
    223     }
    224 
    225     /**
    226      * @return float|null
    227      */
    228     public function get_recommended_price(): ?float {
    229         return $this->recommendedPrice;
    230     }
    231 
    232     /**
    233      * @return float|null
    234      */
    235     public function get_sales_price(): ?float {
    236         return $this->salesPrice;
    237     }
    238 
    239     /**
    240      * @return Unit
    241      */
    242     public function get_unit(): Unit {
    243         return $this->unit ?? new Unit();
    244     }
    245 
    246358    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 );
    250363
    251364        return $vars;
  • miqid-woo/trunk/src/Includes/EConomic/DTO/ProductGroup.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
     
    98    /** @var int|null */
    109    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;
    1122
    1223    public function __construct(
    1324        $productGroupNumber = null,
     25        $name = null,
     26        $salesAccounts = null,
     27        $products = null,
     28        $inventoryEnabled = null,
     29        $accrual = null,
    1430        $self = null
    1531    ) {
     
    1733            $this->parse_array( $productGroupNumber );
    1834        }
    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        }
    2256    }
    2357
     
    2660     */
    2761    public function set_product_group_number( ?int $productGroupNumber ): void {
    28         $this->productGroupNumber = $productGroupNumber ?? $this->productGroupNumber;
     62        $this->productGroupNumber = $productGroupNumber;
    2963    }
    3064
     
    3670    }
    3771
     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
    38134    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 );
    42137
    43138        return $vars;
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Recipient.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
     
    2827    private $vatZone;
    2928
    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 );
    4832        }
    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 );
    6033    }
    6134
    6235    /**
    6336     * @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;
    6744    }
    6845
    6946    /**
    7047     * @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;
    7455    }
    7556
    7657    /**
    7758     * @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;
    8166    }
    8267
    8368    /**
    8469     * @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;
    8877    }
    8978
    9079    /**
    9180     * @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;
    9588    }
    9689
    9790    /**
    9891     * @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;
    10299    }
    103100
    104101    /**
    105102     * @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;
    109110    }
    110111
    111112    /**
    112113     * @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;
    116121    }
    117122
    118123    /**
    119124     * @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 {
    122129        if ( is_array( $attention ) ) {
    123130            $attention = new Attention( $attention );
    124131        }
    125         $this->attention = $attention ?? $this->attention;
     132        $this->attention = $attention;
     133
     134        return $this;
    126135    }
    127136
    128137    /**
    129138     * @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 {
    132143        if ( is_array( $vatZone ) ) {
    133144            $vatZone = new VatZone( $vatZone );
    134145        }
    135         $this->vatZone = $vatZone ?? $this->vatZone;
     146        $this->vatZone = $vatZone;
     147
     148        return $this;
    136149    }
    137150
  • miqid-woo/trunk/src/Includes/EConomic/DTO/SalesPerson.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
  • miqid-woo/trunk/src/Includes/EConomic/DTO/Unit.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
  • miqid-woo/trunk/src/Includes/EConomic/DTO/VatType.php

    r2469411 r2495913  
    44
    55use MIQID\Plugin\WooCommerce\Util;
    6 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    76
    87class VatType extends Base {
    98    /** @var int|null */
    109    private $vatTypeNumber;
     10    /** @var string|null */
     11    private $name;
     12    /** @var string|null */
     13    private $self;
    1114
    1215    public function __construct(
     
    1518        $self = null
    1619    ) {
    17         parent::__construct( $name, $self );
    18 
    1920        if ( is_array( $vatTypeNumber ) ) {
    2021            $this->parse_array( $vatTypeNumber );
    2122        }
    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        }
    2432    }
    2533
     
    2836     */
    2937    public function set_vat_type_number( ?int $vatTypeNumber ): void {
    30         $this->vatTypeNumber = $vatTypeNumber ?? $this->vatTypeNumber;
     38        $this->vatTypeNumber = $vatTypeNumber;
    3139    }
    3240
  • miqid-woo/trunk/src/Includes/EConomic/DTO/VatZone.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
     
    98    /** @var int|null */
    109    private $vatZoneNumber;
     10    /** @var string|null */
     11    private $name;
    1112    /** @var bool */
    1213    private $enabledForCustomer;
    1314    /** @var bool */
    1415    private $enabledForSupplier;
     16    /** @var string|null */
     17    private $self;
    1518
    1619    public function __construct(
    1720        $vatZoneNumber = null,
     21        $name = null,
    1822        $enabledForCustomer = null,
    1923        $enabledForSupplier = null,
    20         $name = null,
    2124        $self = null
    2225    ) {
    23         parent::__construct( $name, $self );
    24 
    2526        if ( is_array( $vatZoneNumber ) ) {
    2627            $this->parse_array( $vatZoneNumber );
    2728        }
    2829
    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        }
    3245    }
    3346
     
    4053
    4154    /**
    42      * @param bool|null $enabledForCustomer
     55     * @param bool|int|string|null $enabledForCustomer
    4356     */
    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;
    4662    }
    4763
    4864    /**
    49      * @param bool|null $enabledForSupplier
     65     * @param bool|int|string|null $enabledForSupplier
    5066     */
    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;
    5372    }
    5473
     
    7594
    7695    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 );
    8198
    8299        return $vars;
  • miqid-woo/trunk/src/Includes/EConomic/DTO/objSelf.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce\Includes\EConomic\DTO;
    44
    5 use MIQID\Plugin\WooCommerce\Includes\DTO\Base;
    65use MIQID\Plugin\WooCommerce\Util;
    76
  • miqid-woo/trunk/src/Includes/Extensions.php

    r2469411 r2495913  
    1212    /** @var bool */
    1313    private $EConomic;
     14    /** @var bool */
     15    private $Dinero;
    1416
    1517    public function __construct(
     
    4951    /**
    5052     * @param bool|int|string|null $EConomic
     53     *
     54     * @return self
    5155     */
    52     public function set_e_conomic( $EConomic ): void {
     56    public function set_e_conomic( $EConomic ): self {
    5357        if ( ! is_null( $EConomic ) ) {
    5458            $EConomic = filter_var( $EConomic, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE );
    5559        }
    5660        $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;
    5777    }
    5878
     
    7696    public function is_e_conomic(): bool {
    7797        return $this->EConomic ?? false;
     98    }
     99
     100    /**
     101     * @return bool
     102     */
     103    public function is_dinero(): bool {
     104        return $this->Dinero ?? false;
    78105    }
    79106
  • miqid-woo/trunk/src/Init.php

    r2469411 r2495913  
    33namespace MIQID\Plugin\WooCommerce;
    44
    5 use MIQID\Plugin\WooCommerce\Frontend\{Conditional_Shipping, EConomic, gtin};
     5use MIQID\Plugin\WooCommerce\Frontend\{Conditional_Shipping, Dinero, EConomic, gtin};
    66use MIQID\Plugin\WooCommerce\Includes\Extensions;
    77
     
    3333        }
    3434
    35         /*if ( $this->extensions->is_e_conomic() ) {
     35        if ( $this->extensions->is_e_conomic() ) {
    3636            EConomic::Instance();
    37         }*/
     37        }
     38
     39        if ( $this->extensions->is_dinero() ) {
     40            Dinero::Instance();
     41        }
    3842
    3943        if ( is_admin() ) {
Note: See TracChangeset for help on using the changeset viewer.