Changeset 26257


Ignore:
Timestamp:
06/01/10 17:19:12 (7 years ago)
Author:
gudd
Message:

Refs #1808

  • added table for billing data
  • added handler etc. to o.o.invoices
  • added invoice-function to work with new billing data
  • added locales
Location:
branches/ragnaroek/midcom
Files:
6 added
20 edited

Legend:

Unmodified
Added
Removed
  • branches/ragnaroek/midcom/org.openpsa.contacts/config/schemadb_default_organization.inc

    r25891 r26257  
    184184            'end_fieldset' => '',
    185185        ),
    186        'invoice_label' => array
     186       'postal_label' => array
    187187        (
    188188            'title'    => 'name',
     
    192192            'start_fieldset' => array
    193193            (
    194                 'title' => 'invoice address',
    195                 'css_group' => 'area contact invoice',
    196             ),
    197         ),
    198        'invoice_street' => array
    199         (
    200             'title'    => 'street',
    201             'storage'  => 'invoiceStreet',
    202             'type'     => 'text',
    203             'widget'   => 'text',
    204         ),
    205         'invoice_postcode' => array
    206         (
    207             'title'    => 'postcode',
    208             'storage'  => 'invoicePostcode',
    209             'type'     => 'text',
    210             'widget'   => 'text',
    211         ),
    212         'invoice_city' => array
    213         (
    214             'title'    => 'city',
    215             'storage'  => 'invoiceCity',
    216             'type'     => 'text',
    217             'widget'   => 'text',
    218         ),
    219         'invoice_country' => array
    220         (
    221             'title'    => 'country',
    222             'storage'  => 'invoiceCountry',
    223             'type'     => 'text',
    224             'widget'   => 'text',
    225             'end_fieldset' => '',
    226         ),
    227         'vatno' => array
    228         (
    229             'title'    => $_MIDCOM->i18n->get_string('VAT No.' , 'org.openpsa.invoices'),
    230             'storage'  => 'vatNo',
    231             'type'     => 'text',
    232             'widget'   => 'text',
    233             'start_fieldset' => array
    234             (
    235                 'title' => 'invoice defaults',
    236                 'css_group' => 'area contact invoice',
    237             ),
    238             'hidden' => !$_MIDCOM->componentloader->is_installed('org.openpsa.invoices'),
    239         ),
    240         'due' => array
    241         (
    242             'title'    => 'due',
    243             'storage'  => 'invoiceDue',
    244             'type'     => 'text',
    245             'widget'   => 'text',
    246             'hidden' => !$_MIDCOM->componentloader->is_installed('org.openpsa.invoices'),
    247         ),
    248         'vat' => array
    249         (
    250             'title'    => $_MIDCOM->i18n->get_string('vat' , 'org.openpsa.invoices'),
    251             'storage'  => 'invoiceVat',
    252             'type'     => 'select',
    253             'type_config' => Array
    254             (
    255                 'options' => Array(),
    256             ),
    257             'widget'   => 'select',
    258             'end_fieldset' => '',
    259             'hidden' => !$_MIDCOM->componentloader->is_installed('org.openpsa.invoices'),
    260         ),
    261        'postal_label' => array
    262         (
    263             'title'    => 'name',
    264             'storage'  => 'parameter',
    265             'type'     => 'text',
    266             'widget'   => 'text',
    267             'start_fieldset' => array
    268             (
    269194                'title' => 'postal address',
    270195                'css_group' => 'area contact postal',
  • branches/ragnaroek/midcom/org.openpsa.contacts/config/schemadb_default_person.inc

    r26154 r26257  
    1919            'widget'   => 'text',
    2020            'required' => true,
     21        ),
     22        'street' => array
     23        (
     24            'title'    => 'street',
     25            'storage'  => 'street',
     26            'type'     => 'text',
     27            'widget'   => 'text',
     28        ),
     29        'postcode' => array
     30        (
     31            'title'    => 'postcode',
     32            'storage'  => 'postcode',
     33            'type'     => 'text',
     34            'widget'   => 'text',
     35        ),
     36        'city' => array
     37        (
     38            'title'    => 'city',
     39            'storage'  => 'city',
     40            'type'     => 'text',
     41            'widget'   => 'text',
     42        ),
     43        'country' => array
     44        (
     45            'title'    => 'country',
     46            'storage'  => 'country',
     47            'type'     => 'text',
     48            'widget'   => 'text',
    2149        ),
    2250        'person_homepage' => array
  • branches/ragnaroek/midcom/org.openpsa.contacts/documentation/CHANGES

    r4794 r26257  
    77- All items marked with "+" represent completely new features.
    88
     9
     102010-06-01 gudd
     11  - removed invoice-information from schema oforganization
     12    (new table in o.o.invoices)
     13   
    9142006-11-27 bergie
    1015  + Fixed account creation
  • branches/ragnaroek/midcom/org.openpsa.contacts/handler/group/edit.php

    r25698 r26257  
    8484        $this->_controller = midcom_helper_datamanager2_controller::create('simple');
    8585        $this->_controller->schemadb =& $this->_schemadb;
    86         org_openpsa_contacts_viewer::modify_schema_invoice_defaults($this->_controller);
     86
    8787        $this->_controller->set_storage($this->_group, $this->_schema);
    8888        if (! $this->_controller->initialize())
     
    190190    function _show_edit($handler_id, &$data)
    191191    {
    192        
    193192        midcom_show_style("show-group-edit");
    194193    }
  • branches/ragnaroek/midcom/org.openpsa.contacts/handler/group/view.php

    r22916 r26257  
    107107        }
    108108
     109        //pass billing-data if invoices is installed
     110        if($_MIDCOM->componentloader->is_installed('org.openpsa.invoices'))
     111        {
     112            $qb_billing_data = org_openpsa_invoices_billing_data_dba::new_query_builder();
     113            $qb_billing_data->add_constraint('linkGuid' , '=' , $this->_group->guid);
     114            $billing_data = $qb_billing_data->execute();
     115            if(count($billing_data) > 0)
     116            {
     117                $this->_request_data['billing_data'] = $billing_data[0];
     118            }
     119        }
     120
    109121        // Add toolbar items
    110122        $this->_populate_toolbar();
     
    144156            )
    145157        );
     158        //add button for editing billing data
     159        if($_MIDCOM->componentloader->is_installed('org.openpsa.invoices'))
     160        {
     161            $siteconfig = org_openpsa_core_siteconfig::get_instance();
     162            $invoices_url = $siteconfig->get_node_full_url('org.openpsa.invoices');
     163            $this->_view_toolbar->add_item
     164            (
     165                array
     166                (
     167                    MIDCOM_TOOLBAR_URL => $invoices_url."billingdata/{$this->_group->guid}/",
     168                    MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('edit billingdata'),
     169                    MIDCOM_TOOLBAR_HELPTEXT => null,
     170                    MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png',
     171                    MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:update'),
     172                )
     173            );
     174        }
    146175
    147176        $this->_view_toolbar->add_item
  • branches/ragnaroek/midcom/org.openpsa.contacts/handler/person/view.php

    r25716 r26257  
    199199            )
    200200        );
     201        if($_MIDCOM->componentloader->is_installed('org.openpsa.invoices'))
     202        {
     203            $siteconfig = org_openpsa_core_siteconfig::get_instance();
     204            $invoices_url = $siteconfig->get_node_full_url('org.openpsa.invoices');
     205            $this->_view_toolbar->add_item
     206            (
     207                array
     208                (
     209                    MIDCOM_TOOLBAR_URL => $invoices_url."billingdata/{$this->_contact->guid}/",
     210                    MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('edit billingdata'),
     211                    MIDCOM_TOOLBAR_HELPTEXT => null,
     212                    MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png',
     213                    MIDCOM_TOOLBAR_ENABLED => $this->_contact->can_do('midgard:update'),
     214                )
     215            );
     216        }
    201217
    202218        if ($this->_contact->username)
  • branches/ragnaroek/midcom/org.openpsa.contacts/locale/default.de.txt

    r26174 r26257  
    136136---STRINGEND
    137137
     138---STRING edit billingdata
     139Rechnungsdaten bearbeiten
     140---STRINGEND
     141
    138142---STRING email
    139143E-Mail
  • branches/ragnaroek/midcom/org.openpsa.contacts/locale/default.en.txt

    r26174 r26257  
    136136---STRINGEND
    137137
     138---STRING edit billingdata
     139Edit billing data
     140---STRINGEND
     141
    138142---STRING edit user account: %s %s
    139143Edit user account: %s %s
     
    484488---STRINGEND
    485489
     490
     491
    486492---STRING vendor
    487493Vendor
  • branches/ragnaroek/midcom/org.openpsa.contacts/style/show-group.php

    r25698 r26257  
    6868        }
    6969    }
    70     if($_MIDCOM->componentloader->is_installed('org.openpsa.invoices'))
     70    if(array_key_exists('billing_data' , $data))
    7171    {
    7272        echo "<h2>" . $data['l10n']->get('invoice defaults') . "</h2>\n";
    7373        echo "<div><strong>" . $_MIDCOM->i18n->get_string('vat' , 'org.openpsa.invoices') . ": </strong>";
    74         echo $data['group']->invoiceVat . "</div>\n";
     74        echo $data['billing_data']->vat . "</div>\n";
    7575        echo "<div><strong>" . $data['l10n']->get('due') . ": </strong>";
    76         echo $data['group']->invoiceDue . "</div>\n";
     76        echo $data['billing_data']->due . "</div>\n";
     77        $data['billing_data']->render_address();
    7778    }
    78     org_openpsa_contactwidget::show_address_card($data['group'], array('visiting', 'invoice', 'postal'));
     79    org_openpsa_contactwidget::show_address_card($data['group'], array('visiting' , 'postal'));
    7980    ?>
    8081</div>
  • branches/ragnaroek/midcom/org.openpsa.contacts/viewer.php

    r25891 r26257  
    353353        $indexer->index($document);
    354354    }
    355 
    356     /**
    357      * Sets defaults for due & vat to the schema of the passed controller
    358      *
    359      * @param midcom_helper_datamanager2_datamanager_controller controller with the schema to change
    360      */
    361     static function modify_schema_invoice_defaults($controller)
    362     {
    363         if ($_MIDCOM->componentloader->is_installed('org.openpsa.invoices'))
    364         {
    365             $_MIDCOM->componentloader->load('org.openpsa.invoices');
    366             //get default values
    367             $dummy_invoice = new org_openpsa_invoices_invoice_dba();
    368             $schema_name = 'default';
    369             if (property_exists($controller , 'schemaname' ))
    370             {
    371                 $schema_name = $controller->schemaname;
    372             }
    373             $controller->schemadb[$schema_name]->fields['due']['default'] = $dummy_invoice->get_default_due();
    374             $controller->schemadb[$schema_name]->fields['vat']['default'] = $dummy_invoice->get_default_vat();
    375 
    376             //set possible values for vat
    377             $vat_percentages = array();
    378             foreach (explode( ',', $GLOBALS['midcom_component_data']['org.openpsa.invoices']['config']->get('vat_percentages')) as $percentage)
    379             {
    380                 $vat_percentages[$percentage] = $percentage;
    381             }
    382             $controller->schemadb[$schema_name]->fields['vat']['type_config']['options'] = $vat_percentages;
    383         }
    384     }
    385355}
    386356
  • branches/ragnaroek/midcom/org.openpsa.invoices/config/config.inc

    r25823 r26257  
    11'schemadb'             => 'file:/org/openpsa/invoices/config/schemadb_default.inc',
    22'schemadb_config'      => 'file:/org/openpsa/invoices/config/schemadb_config.inc',
     3'schemadb_billing_data' => 'file:/org/openpsa/invoices/config/schemadb_default_billing_data.inc',
    34'default_hourly_price' => 0,
    45'default_due_days'     => 14,
  • branches/ragnaroek/midcom/org.openpsa.invoices/config/mgdschema.xml

    r26073 r26257  
    5252        <property name="hourReport" link="org_openpsa_hour_report:id" type="unsigned integer"/>
    5353    </type>
     54   
     55    <type name="org_openpsa_billing_data" table="org_openpsa_billing_data">
     56        <property name="id" type="unsigned integer" primaryfield="id">
     57            <description>Local non-replication-safe database identifier</description>
     58        </property>
     59
     60        <property name="recipient" type="text" />
     61        <property name="street" type="string" />
     62        <property name="postcode" type="string" />
     63        <property name="city" type="string" />
     64        <property name="country" type="string" />
     65        <property name="email" type="string" />
     66       
     67        <property name="accountNumber" type="string" />
     68        <property name="bankCode" type="string" />
     69        <property name="iban" type="string" />
     70        <property name="bic" type="string" />
     71        <property name="bankName" type="string" />
     72        <property name="vatNo" type="string" />
     73        <property name="vat" type="integer" />
     74        <property name="delivery" type="string" />
     75        <property name="due" type="unsigned integer" />
     76        <property name="vatNo" type="string" />
     77       
     78        <property name="useContactAddress" type="bool" />
     79        <!-- guid of the object the billing data belongs to -->
     80        <property name="linkGuid" type="string" />
     81       
     82    </type>
    5483</Schema>
  • branches/ragnaroek/midcom/org.openpsa.invoices/config/midcom_dba_classes.inc

    r26073 r26257  
    1111    'midcom_class_name' => 'org_openpsa_invoices_invoice_item_dba'
    1212),
     13array(
     14    'mgdschema_class_name' => 'org_openpsa_billing_data',
     15    'midcom_class_name' => 'org_openpsa_invoices_billing_data_dba'
     16),
  • branches/ragnaroek/midcom/org.openpsa.invoices/documentation/CHANGES

    r26073 r26257  
    66  which might even break existing functionality.
    77- All items marked with "+" represent completely new features.
     8
     92010-06-01 gudd
     10  + added new table with billing data ,
     11    now persons & organizations have billing data
    812
    9132010-05-11 gudd
  • branches/ragnaroek/midcom/org.openpsa.invoices/handler/crud.php

    r26220 r26257  
    526526            $this->_request_data['customer'] = org_openpsa_contacts_group_dba::get_cached($this->_object->customer);
    527527            $this->_request_data['customer_contact'] = org_openpsa_contacts_person_dba::get_cached($this->_object->customerContact);
     528            $this->_request_data['billing_data'] = $this->_object->get_billing_data();
    528529            $_MIDCOM->skip_page_style = true;
    529530        }
  • branches/ragnaroek/midcom/org.openpsa.invoices/invoice.php

    r26143 r26257  
    203203    function get_default_due()
    204204    {
    205         //get due of customer if present
    206         if (!empty($this->customer))
    207         {
    208             $customer = org_openpsa_contacts_group_dba::get_cached($this->customer);
    209             if (!empty($customer->invoiceDue))
    210             {
    211                 return $customer->invoiceDue;
    212             }
    213         }
    214         if (!array_key_exists('org.openpsa.invoices' , $GLOBALS['midcom_component_data']))
    215         {
    216             if (!$_MIDCOM->componentloader->load('org.openpsa.invoices'))
    217             {
    218                 debug_push_class(__CLASS__, __FUNCTION__);
    219                 debug_add("Failed to load org.openpsa.invoices: " . midcom_application::get_error_string(), MIDCOM_LOG_ERROR);
    220                 debug_pop();
    221                 return false;
    222             }
    223         }
    224 
    225         $due = $GLOBALS['midcom_component_data']['org.openpsa.invoices']['config']->get('default_due_days');
    226 
    227         return $due;
     205        $billing_data = $this->get_billing_data();
     206        return $billing_data->due;
    228207    }
    229208
     
    233212    function get_default_vat()
    234213    {
    235         //get vat of customer if present
    236         if (!empty($this->customer))
    237         {
    238             $customer = org_openpsa_contacts_group_dba::get_cached($this->customer);
    239 
    240             /**
    241              * we do the empty check against invoiceDue here, because 0 might be a valid
    242              * VAT value
    243              */
    244             if (!empty($customer->invoiceDue))
    245             {
    246                 return (int) $customer->invoiceVat;
    247             }
    248         }
    249         if (!array_key_exists('org.openpsa.invoices', $GLOBALS['midcom_component_data']))
    250         {
    251             if (!$_MIDCOM->componentloader->load('org.openpsa.invoices'))
    252             {
    253                 debug_push_class(__CLASS__, __FUNCTION__);
    254                 debug_add("Failed to load org.openpsa.invoices: " . midcom_application::get_error_string(), MIDCOM_LOG_ERROR);
    255                 debug_pop();
    256                 return false;
    257             }
    258         }
    259 
    260         $vat = explode(',' , $GLOBALS['midcom_component_data']['org.openpsa.invoices']['config']->get('vat_percentages'));
    261 
    262         return (int) $vat[0];
     214        $billing_data = $this->get_billing_data();
     215        return (int) $billing_data->vat;
    263216    }
    264217
     
    406359        return $qb_invoice_items->execute();
    407360    }
     361
     362    function get_billing_data()
     363    {
     364        //check if there is a customer set with invoice_data
     365        if (!empty($this->customer))
     366        {
     367            $customer = org_openpsa_contacts_group_dba::get_cached($this->customer);
     368            $qb = org_openpsa_invoices_billing_data_dba::new_query_builder();
     369            $qb->add_constraint('linkGuid' , '=' , $customer->guid);
     370            $billing_data = $qb->execute();
     371            if(count($billing_data) > 0)
     372            {
     373                // call set_address so the billing_data contains address of the linked contact
     374                // if the property useContactAddress is set
     375                $billing_data[0]->set_address();
     376                return $billing_data[0];
     377            }
     378        }
     379        //check if the customerContact is set & has invoice_data
     380        if (!empty($this->customerContact))
     381        {
     382            $customerContact = org_openpsa_contacts_person_dba::get_cached($this->customerContact);
     383            $qb = org_openpsa_invoices_billing_data_dba::new_query_builder();
     384            $qb->add_constraint('linkGuid' , '=' , $customerContact->guid);
     385            $billing_data = $qb->execute();
     386            if(count($billing_data) > 0)
     387            {
     388                // call set_address so the billing_data contains address of the linked contact
     389                // if the property useContactAddress is set
     390                $billing_data[0]->set_address();
     391                return $billing_data[0];
     392            }
     393        }
     394
     395        //set the default-values for vat&due from config
     396        if (!array_key_exists('org.openpsa.invoices', $GLOBALS['midcom_component_data']))
     397        {
     398            if (!$_MIDCOM->componentloader->load('org.openpsa.invoices'))
     399            {
     400                debug_push_class(__CLASS__, __FUNCTION__);
     401                debug_add("Failed to load org.openpsa.invoices: " . midcom_application::get_error_string(), MIDCOM_LOG_ERROR);
     402                debug_pop();
     403                return false;
     404            }
     405        }
     406        $billing_data = new org_openpsa_invoices_billing_data_dba();
     407        $due = $GLOBALS['midcom_component_data']['org.openpsa.invoices']['config']->get('default_due_days');
     408        $vat = explode(',' , $GLOBALS['midcom_component_data']['org.openpsa.invoices']['config']->get('vat_percentages'));
     409
     410        $billing_data->vat = $vat[0];
     411        $billing_data->due = $due;
     412
     413        return $billing_data;
     414    }
    408415}
    409416?>
  • branches/ragnaroek/midcom/org.openpsa.invoices/locale/default.de.txt

    r26161 r26257  
    44---LANGUAGE de
    55
     6---STRING account number
     7Konto-Nummer
     8---STRINGEND
     9
    610---STRING add new invoice item
    711Neue Rechnungsposition hinzufÃŒgen
     
    2832---STRINGEND
    2933
     34---STRING bank code
     35BLZ
     36---STRINGEND
     37
    3038---STRING basic information
    3139Basisdaten
    3240---STRINGEND
    3341
     42---STRING billing data
     43Rechnungsdaten
     44---STRINGEND
     45
    3446---STRING create invoice
    3547Rechnung erstellen
     
    88100---STRINGEND
    89101
     102---STRING invoice address
     103Rechnungsadresse
     104---STRINGEND
     105
    90106---STRING invoice date
    91107Rechnungsdatum
     
    144160---STRINGEND
    145161
     162---STRING name of bank
     163Name des Geldinstituts
     164---STRINGEND
     165
    146166---STRING next action
    147167NÀchste Aktion
     
    212232---STRINGEND
    213233
     234---STRING recipient
     235EmpfÀnger
     236---STRINGEND
     237
    214238---STRING recently paid invoices
    215239Neueste ZahlungseingÀnge
     
    312336---STRINGEND
    313337
     338---STRING use contact address
     339Adresse aus Kontaktdaten benutzen
     340---STRINGEND
     341
    314342---STRING no description given
    315343Keine Beschreibung angegeben
  • branches/ragnaroek/midcom/org.openpsa.invoices/locale/default.en.txt

    r26161 r26257  
    44---LANGUAGE en
    55
     6---STRING account number
     7Account number
     8---STRINGEND
     9
    610---STRING add new invoice item
    711Add a new invoice item
     
    2832---STRINGEND
    2933
     34---STRING bank code
     35Bankcode
     36---STRINGEND
     37
    3038---STRING basic information
    3139Basic information
    3240---STRINGEND
    3341
     42---STRING billing data
     43Billing data
     44---STRINGEND
     45
    3446---STRING create invoice
    3547Create invoice
     
    96108---STRINGEND
    97109
     110---STRING invoice address
     111Invoice address
     112---STRINGEND
     113
    98114---STRING invoice date
    99115Invoice date
     
    156172---STRINGEND
    157173
     174---STRING name of bank
     175Name of institute
     176---STRING
     177
    158178---STRING next action
    159179Next Action
     
    196216---STRINGEND
    197217
     218---STRING recipient
     219Recipient
     220---STRINGEND
     221
    198222---STRING paid
    199223paid
     
    312336---STRINGEND
    313337
     338---STRING use contact address
     339Use the address given in contact
     340---STRINGEND
     341
    314342---STRING current pdf file was manually uploaded shall it be replaced ?
    315343The current pdf-file was manually uploaded. So shall it really be replaced ?
  • branches/ragnaroek/midcom/org.openpsa.invoices/style/admin-read.php

    r26161 r26257  
    1919        if ($customer)
    2020        {
    21             org_openpsa_contactwidget::show_address_card($customer, array('invoice', 'postal'));
     21            $billing_data = $invoice->get_billing_data();
     22            $billing_data->render_address();
     23            org_openpsa_contactwidget::show_address_card($customer, array('postal'));
    2224        } ?>
    2325    </div>
     
    9395        <?php
    9496        $invoice_sum = 0;
    95         //var_dump($data['invoice_items']);
    9697        foreach ($data['invoice_items'] as $item)
    9798        {
  • branches/ragnaroek/midcom/org.openpsa.invoices/viewer.php

    r26073 r26257  
    126126            'variable_args' => 1,
    127127        );
     128        // Match /billingdata/GUID
     129        $this->_request_switch['invoice_data'] = array
     130        (
     131            'handler' => array('org_openpsa_invoices_handler_billingdata', 'billingdata'),
     132            'fixed_args' => array('billingdata'),
     133            'variable_args' => 1,
     134        );
    128135
    129136        // Match /config/
Note: See TracChangeset for help on using the changeset viewer.