function get_order_customer($order_summary)
{
    $name = !empty($order_summary['billing_company']) ? $order_summary['billing_company'] : $order_summary['billing_name'];
    $customer = new KontrahentFlyweightBuilder($name, $order_summary['billing_postcode'], $order_summary['billing_city']);
    if (!empty($order_summary['tax_number'])) {
        $customer->NIP($order_summary['tax_number']);
    }
    if (!empty($order_summary['billing_street_address'])) {
        $address = $order_summary['billing_street_address'];
        $customer->Ulica($address);
    }
    if (!empty($order_summary['billing_telephone'])) {
        $customer->Telefon($order_summary['billing_telephone']);
    }
    if (!($order_summary['billing_company'] != $order_summary['customers_company'] || $order_summary['billing_name'] != $order_summary['customers_name'])) {
        if (!empty($order_summary['customers_id'])) {
            $customer->Identyfikator('IFI' . $order_summary['customers_id']);
        }
    }
    return $customer;
}
function get_order_customer($order_summary)
{
    $cust_summary = get_customer($order_summary['id_customer']);
    $cust_addr = get_customer_invoice_address($order_summary['id_address_invoice']);
    $name = !empty($cust_addr['company']) ? $cust_addr['company'] : $cust_addr['lastname'] . " " . $cust_addr['firstname'];
    $customer = new KontrahentFlyweightBuilder($name, $cust_addr['postcode'], $cust_addr['city']);
    if (!empty($cust_addr['vat_number'])) {
        $customer->NIP($cust_addr['vat_number']);
    }
    if (!empty($cust_addr['address1'])) {
        $address = $cust_addr['address1'];
        if (!empty($cust_addr['address2'])) {
            $address .= ' ' . $cust_addr['address2'];
        }
        $customer->Ulica($address);
    }
    if (!empty($cust_addr['phone'])) {
        $customer->Telefon($cust_addr['phone']);
    }
    if (!($cust_summary['company'] != $cust_addr['company'] || $cust_summary['lastname'] != $cust_addr['lastname'])) {
        if (!empty($cust_summary['id_customer'])) {
            $customer->Identyfikator('IFI' . $cust_summary['id_customer']);
        }
    }
    return $customer;
}