---
name: "LedgerSMB::DBObject::Company"
section: "3pm"
platform: "linux"
package: "ledgersmb"
version: "1.3.40-1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/LedgerSMB::DBObject::Company"
---

# LedgerSMB::DBObject::Company(3pm)

Base utility functions for processing customers and vendors.

## NAME

LedgerSMB::DBObject::Company - Base utility functions for processing customers and vendors.

## SYNOPSIS

This library contains the base utility functions for creating, saving, and retrieving customers and vendors.

## METHODS

- $company-\>*set\_entity\_class()*

  This is a stub for a private method that subclasses are expected to overwrite.  It will be set to the account class of the entity (1 for vendor, 2 for customer, etc).

- get\_by\_cc

  This retrieves the company header information by control code.  Leaves the  overall account class untouched.

- *save()*

  This stores the company record including a credit account in the database.

  TODO:  Separate company from credit account storage.

- delete\_contact

  required request variables:

  contact\_class\_id:  int id of contact class contact: text of contact information

  Must include at least one of:

  credit\_id: int of entity\_credit\_account.id, preferred value company\_id:  int of company.id, only used if credit\_id not set.

  returns true of a record was deleted.

- delete\_location

  Deletes a record from the location side.

  Required request variables:

  location\_id location\_class\_id

  One of:

  credit\_id (preferred) company\_id (as fallback)

  Returns true if a record was deleted.  False otherwise.

- delete\_bank\_account

  Deletes a bank account

  Requires:

  entity\_id bank\_account\_id

  Returns true if a record was deleted, false otherwise.

- get\_history

  Retrieves customer/vendor purchase.

  Search Criteria name:  search string for company name contact\_info:  Search string for contact info, can match phone, fax, or email. salesperson:  Search string for employee name in the salesperson field notes: Notes search.  Not currently implemented meta\_number:  Exact match for customer/vendor number address\_line:  Search string for first or second line of address. city:  Search string for city name state:  Case insensitive, otherwise exact match for state or province zip:  leading match for zip/mail code country\_id:  integer for country id.  Exact match tartdate\_from:  Earliest date for startdate of entity credit account startdate\_to:  Lates date for entity credit accounts' start date type:  either 'i' for invoice, 'o' for orders, 'q' for quotations from\_date:  Earliest date for the invoice/order to\_date:  Latest date for the invoice/order

  Unless otherwise noted, partial matches are sufficient.

  Control variables: inc\_open:  Include open invoices/orders.  If not true, no open invoices are\
              displayed inc\_closed: Include closed invoices/orders.  If not true, no closed invoices are\
               displayed report\_type:  Either summary or detail

  returns a list of rows of the summary report and sets these to  @{$self-\>{history\_rows}}

- save\_credit

  This method saves the credit account for the company.

  Expected inputs: credit\_id (int): (Optional) Id for the account entity\_class (int):  Class of the account, required (1 = vendor, 2 = customer) entity\_id (int):  ID of entity to attach to.  description (text):  Description of account discount (numeric):  Early payment discount  taxincluded (bool):  Whether prices include tax.  creditlimit (numeric):  Credit limit discount\_terms (int):  How many days can elapse before the discount lapses too. terms (int):  How many days can lapse before the invoice is overdue.  meta\_number (varchar):  Account string identifier for the account. business\_id (int):  ID for business type. language (varchar): Language code for invoices. pricegroup\_id (int): Price group curr (char):  Currency  identifier, three characters long. startdate (date):  Date of the start of the relationship.  enddate (date):  Date of the end of the relationship. threshold (NUMERIC):  How much must be owed before the invoices can be paid. ar\_ap\_account\_id (int):  ID of ar/ap account.  REQUIRED cash\_account\_id (int):  ID of cash account (Optional) pay\_to\_name (text):  Name to pay to or receive from. taxform\_id (int);  ID of tax form

- save\_location

  This method saves an address for a company.

  Requires the following variables on the object: credit\_id location\_id  location\_class (1 = billing, 2 = shipping, 3 = sales) line\_one line\_two city state (can hold province info)   mail\_code (zip or postal code)  country\_code (ID of country)

- get\_credit\_id

  This method returns the current credit id from the screen.

  Requires entity\_id, meta\_number, and entity\_class be set.

- *get\_metadata()*

  This retrieves various information vor building the user interface.  Among other things, it sets the following properties: `$self`-\>{ar\_ap\_acc\_list} = qw(list of ar or ap accounts) `$self`-\>{cash\_acc\_list} = qw(list of cash accounts) `$self`-\>{entity\_classes} = qw(list of entity classes) `$self`-\>{all\_taxes}  =qw(list of taxes)

- save\_contact

  Saves a contact.  Requires credit\_id, contact\_class, description, and contact to  be set.

  Requires the following be set: credit\_id or entity\_id contact\_class description contact old\_contact old\_contact\_class

- save\_bank\_account

  Saves a bank account.  Requires the following be set: entity\_id  bic (bank id) iban (account number) remark (remark for the account, optional) bank\_account\_id (id for record, optional)

- save\_notes

  Saves notes. The following must be set: credit\_id:  credit account to annotate.  Must be set to annotate credit account entity\_id:  entitity to annotate. note:  Note contents subject:  Note subject

- search

  Searches for matching company records.  Populates `$self`-\>{search\_results} with  records found.

  Search criteria and inputs: account\_class:  required (1 for vendor, 2 for customer, etc) contact contact\_info meta\_number address city state mail\_code country date\_from date\_to business\_id legal\_name control\_code

  Account class may not be undef.  meta\_number is an exact match, as is  control\_code.  All others specify ranges or partial matches.

- get\_billing\_info

  Requires that the id field is set.  Sets the following:

  legal\_name meta\_number control\_code tax\_id street1 street2 street3 city state mail\_code country

- accounts

  Returns all accounts, and sets these to `$self`-\>{accounts}.

  id and entity\_class must be set.

- address($id)

  Returns the location if it is specified by the `$id` argument.

- get

  Retrieves a company record and all info.

  taxform\_list is set to a list of tax forms for the entity's country credit\_list is set to a list of credit accounts locations is set to a list of locations contacts to a list of contacts notes to a list of notes bank\_account to a list of bank accounts

- get\_pricematrix

  This routine gets the price matrix for the customer or vendor.  The pricematrix info is stored in the pricematrix hash entry.  If a customer (account\_class=1),  it also populates a pricematrix\_pricegroup entry.

- delete\_pricematrix($entry\_id)

  This deletes a pricematrix line identified by `$entry_id`

- save\_pricematrix

  Updates or inserts the price matrix.

## COPYRIGHT

Copyright (c) 2009, the LedgerSMB Core Team.  This is licensed under the GNU  General Public License, version 2, or at your option any later version.  Please  see the accompanying License.txt for more information.
