Ejemplo n.º 1
0
 function __construct($tablename = 'pltransactions')
 {
     // Register non-persistent attributes
     // Contruct the object
     parent::__construct($tablename);
     // Set specific characteristics
     // Define relationships
     $this->belongsTo('PLSupplier', 'plmaster_id', 'supplier');
     // Define field formats
     // Define system defaults
     // Define enumerated types
     $this->setEnum('transaction_type', array('I' => 'Invoice', 'C' => 'Credit Note', 'J' => 'Journal', 'P' => 'Payment', 'RP' => 'Refund Payment', 'SD' => 'Settlement Discount'));
 }
Ejemplo n.º 2
0
 function __construct($tablename = 'sltransactions')
 {
     // Register non-persistent attributes
     // Contruct the object
     parent::__construct($tablename);
     // Set specific characteristics
     // Define relationships
     $this->belongsTo('SLCustomer', 'slmaster_id', 'customer');
     $this->belongsTo('Person', 'person_id', 'person', null, "surname || ', ' || firstname");
     // Define field formats
     // set formatters, more set in load() function
     // Define enumerated types
     $this->setEnum('transaction_type', array('I' => 'Invoice', 'C' => 'Credit Note', 'J' => 'Journal', 'R' => 'Reciept', 'RR' => 'Refund Reciept', 'SD' => 'Settlement Discount'));
     // Do not allow links to the following
 }
Ejemplo n.º 3
0
 function __construct($tablename = 'eltransactions')
 {
     // Register non-persistent attributes
     // Contruct the object
     parent::__construct($tablename);
     // Set specific characteristics
     $this->idField = 'id';
     $this->orderby = 'transaction_date';
     $this->orderdir = 'DESC';
     // Define relationships
     $this->belongsTo('Employee', 'employee_id', 'supplier');
     $this->belongsTo('Currency', 'currency_id', 'currency');
     $this->belongsTo('Currency', 'twin_currency_id', 'twin');
     // Define field formats
     // set formatters, more set in load() function
     // Define enumerated types
     $this->setEnum('transaction_type', array('E' => 'Expense', 'C' => 'Expense Credit', 'J' => 'Journal', 'P' => 'Payment'));
     $this->setEnum('status', array('N' => 'New', 'O' => 'Open', 'Q' => 'Query', 'P' => 'Paid'));
     // Define default values
     // Define field formatting
     // Define link rules for related items
 }
Ejemplo n.º 4
0
 public static function savePayment(&$data, &$errors)
 {
     $account = DataObjectFactory::Factory('CBAccount');
     if (isset($data['cb_account_id']) && !empty($data['cb_account_id'])) {
         $account = $account->load($data['cb_account_id']);
         $data['control_glaccount_id'] = $account->glaccount_id;
         $data['control_glcentre_id'] = $account->glcentre_id;
     } else {
         $errors[] = 'No bank account supplied';
         return false;
     }
     $glparams = DataObjectFactory::Factory('GLParams');
     $base_currency_id = $glparams->base_currency();
     // The type of conversion depends on whether the input currency or the account currency equals the base currency
     // - input currency equals base, then multiple value by rate
     // - account currency equals base, then divide value by rate
     // Save the original input values
     $data['transaction_net_value'] = $data['net_value'];
     if (empty($data['tax_value'])) {
         $data['tax_value'] = 0.0;
     }
     $data['transaction_tax_value'] = $data['tax_value'];
     $data['transaction_currency_id'] = $data['currency_id'];
     if ($account->currency_id != $data['currency_id']) {
         if ($data['currency_id'] == $base_currency_id) {
             self::convertValues($data, 'M');
         } else {
             self::convertValues($data, 'D');
         }
     }
     $data['currency_id'] = $account->currency_id;
     if ($account->currency_id == $base_currency_id) {
         $data['rate'] = '';
     }
     if (!empty($data['tax_rate_id']) && empty($data['tax_percentage'])) {
         $taxrate = DataObjectFactory::Factory('TaxRate');
         $taxrate->load($data['tax_rate_id']);
         if ($taxrate->isLoaded()) {
             $data['tax_percentage'] = $taxrate->percentage;
         }
     }
     LedgerTransaction::setCurrency($data);
     return self::saveTransaction($data, $errors);
 }