Пример #1
0
 /**
  * Initializes invoice data.
  * This method is equivalent to the old getInvoice()
  */
 protected function _initData()
 {
     $invoices = new SimpleInvoices_Db_Table_Invoices();
     $invoiceItems = new SimpleInvoices_Db_Table_InvoiceItems();
     $payments = new SimpleInvoices_Db_Table_Payment();
     $this->_data = $invoices->getInvoice($this->_id);
     if (!is_array($this->_data)) {
         require_once 'SimpleInvoices/Exception.php';
         throw new SimpleInvoices_Exception('Invalid invoice identifier.');
     }
     // I unset the ID as I don't want it to be present in inserts or updates.
     unset($this->_data['id']);
     $this->_outData = array();
     $this->_outData['calc_date'] = date('Y-m-d', strtotime($this->_data['date']));
     $this->_outData['date'] = siLocal::date($this->_data['date']);
     $this->_outData['total'] = $invoiceItems->getInvoiceTotal($this->_id);
     $this->_outData['gross'] = $invoiceItems->getGrossForInvoice($this->_id);
     $this->_outData['paid'] = $payments->getPaidAmountForInvoice($this->_id);
     $this->_outData['owing'] = $this->_outData['total'] - $this->_outData['paid'];
     if (isset($this->_data['inv_status'])) {
         // This seems to be a thing of the past.
         // I think we could delete the whole "if".
         $this->_outData['status'] = $this->_data['inv_status'];
     } else {
         $this->_outData['status'] = '';
     }
     #invoice total tax
     $result = $invoiceItems->getTotals($this->_id);
     //$invoice['total'] = number_format($result['total'],2);
     $this->_outData['total_tax'] = $result['total_tax'];
     $this->_outData['tax_grouped'] = taxesGroupedForInvoice($id);
 }
Пример #2
0
//stop the direct browsing to this file - let index.php handle which files get displayed
checkLogin();

$SI_INVOICE_ITEMS = new SimpleInvoices_Db_Table_InvoiceItems();

# Deal with op and add some basic sanity checking

#insert - process payment
#op=pay_selected_invoice means the user came from the print_view or manage_invoces
#op=pay_invoice means the user came from the process_paymen page

global $auth_session;
if ( isset($_POST['process_payment']) ) {
    
    $SI_PAYMENTS = new SimpleInvoices_Db_Table_Payment();
    
    $payment_data = array(
        'ac_inv_id'         => $_POST['invoice_id'],
        'ac_amount'         => $_POST['ac_amount'],
        'ac_notes'          => $_POST['ac_notes'],
        'ac_date'           => $_POST['ac_date'],
        'ac_payment_type'   => $_POST['ac_payment_type'],
        'online_payment_id' => NULL
    );
    
	//works out any funds that are in excess of invoice total:
	$invoicetotal = $SI_INVOICE_ITEMS->getInvoiceTotal($payment_data['ac_inv_id']);
    $orig_amt = $payment_data['ac_amount'];
    $extrapayment = $payment_data['ac_amount']; - $invoicetotal;
Пример #3
0
	$check_payment = new payment();
	$check_payment->filter='online_payment_id';
	$check_payment->online_payment_id = $p->ipn_data['txn_id'];
	$check_payment->domain_id = $domain_id;
    $number_of_payments = $check_payment->count();
	$logger->log('Paypal - number of times this payment is in the db: '.$number_of_payments, Zend_Log::INFO);
	
	if($number_of_payments > 0)
	{
		$xml_message .= 'Online payment '.$p->ipn_data['tnx_id'].' has already been entered into Simple Invoices - exiting for domain_id='.$domain_id;
		$logger->log($xml_message, Zend_Log::INFO);
	}

	if($number_of_payments == '0')
	{
        $SI_PAYMENTS = new SimpleInvoices_Db_Table_Payment();
        $SI_PAYMENT_TYPES = new SimpleInvoices_Db_Table_PaymentTypes();
        
        $payment_data = array(
            'ac_inv_id'         => $p->ipn_data['invoice'],
            'ac_amount'         => $p->ipn_data['mc_gross'],
            'ac_notes'          => $paypal_data,
            'ac_date'           => date( 'Y-m-d', strtotime($p->ipn_data['payment_date'])),
            'online_payment_id' => $p->ipn_data['txn_id']
        );

			$payment_type = new payment_type();
			$payment_type->type = "Paypal";
			$payment_type->domain_id = $domain_id;
            
        $payment_type_data = array(