Beispiel #1
0
 public function action_vendorpaymentsearch()
 {
     $search_terms = $this->request->post('search_terms');
     $search_vendor_id = $this->request->post('search_vendor_id');
     $count = $this->request->post('count');
     $page = $this->request->post('page');
     if (!$count) {
         $count = 5;
     }
     if (!$page) {
         $page = 0;
     }
     $search_parameters = (object) array('page' => $page, 'page_size' => $count, 'sort_by' => 'newest', 'vendor_id' => $search_vendor_id, 'keywords' => '', 'search_and' => FALSE);
     foreach (explode(' ', $search_terms) as $search_term) {
         $term = trim($search_term);
         if ($term and is_numeric($search_term)) {
             $search_parameters->check_number = $term;
         } else {
             if ($term and date('Y-m-d', strtotime($term)) == $term) {
                 $search_parameters->date = $term;
             }
         }
         $search_parameters->keywords .= $term . ' ';
     }
     $account_transaction_search = new Beans_Account_Transaction_Search_Vendor($this->_beans_data_auth($search_parameters));
     $account_transaction_search_result = $account_transaction_search->execute();
     if (!$account_transaction_search_result->success) {
         return $this->_return_error($this->_beans_result_get_error($account_transaction_search_result));
     }
     $this->_return_object->data = $account_transaction_search_result->data;
     // $this->_return_object->data->checks = array();
     foreach ($account_transaction_search_result->data->transactions as $index => $transaction) {
         if (isset($transaction->form) and $transaction->form and isset($transaction->form->id) and $transaction->form->type == "expense") {
             $vendor_expense_lookup = new Beans_Vendor_Expense_Lookup($this->_beans_data_auth((object) array('id' => $transaction->form->id)));
             $vendor_expense_lookup_result = $vendor_expense_lookup->execute();
             if (!$vendor_expense_lookup_result->success) {
                 return $this->_return_error($this->_beans_result_get_error($vendor_expense_lookup_result));
             }
             $vendor_checks_check = new View_Partials_Vendors_Checks_Check();
             $vendor_checks_check->noprintchecks = TRUE;
             $vendor_checks_check->expense = $vendor_expense_lookup_result->data->expense;
             $this->_return_object->data->transactions[$index]->html = $vendor_checks_check->render();
         } else {
             if ($transaction->payment and $transaction->payment == "vendor") {
                 $vendor_payment_lookup = new Beans_Vendor_Payment_Lookup($this->_beans_data_auth((object) array('id' => $transaction->id)));
                 $vendor_payment_lookup_result = $vendor_payment_lookup->execute();
                 if (!$vendor_payment_lookup_result->success) {
                     return $this->_return_error($this->_beans_result_get_error($vendor_payment_lookup_result));
                 }
                 $vendor_checks_check = new View_Partials_Vendors_Checks_Check();
                 $vendor_checks_check->noprintchecks = TRUE;
                 $vendor_checks_check->payment = $vendor_payment_lookup_result->data->payment;
                 $this->_return_object->data->transactions[$index]->html = $vendor_checks_check->render();
             } else {
                 if ($transaction->tax_payment and isset($transaction->tax_payment->id)) {
                     $tax_payment_lookup = new Beans_Tax_Payment_Lookup($this->_beans_data_auth((object) array('id' => $transaction->tax_payment->id)));
                     $tax_payment_lookup_result = $tax_payment_lookup->execute();
                     if (!$tax_payment_lookup_result->success) {
                         return $this->_return_error($this->_beans_result_get_error($tax_payment_lookup_result));
                     }
                     $vendor_checks_check = new View_Partials_Vendors_Checks_Check();
                     $vendor_checks_check->noprintchecks = TRUE;
                     $vendor_checks_check->taxpayment = $tax_payment_lookup_result->data->payment;
                     $this->_return_object->data->transactions[$index]->html = $vendor_checks_check->render();
                 } else {
                     $vendor_checks_check = new View_Partials_Vendors_Checks_Check();
                     $vendor_checks_check->noprintchecks = TRUE;
                     $vendor_checks_check->transaction = $transaction;
                     $this->_return_object->data->transactions[$index]->html = $vendor_checks_check->render();
                 }
             }
         }
     }
 }
Beispiel #2
0
 public function action_renderprintchecks()
 {
     $expense_ids = array();
     $payment_ids = array();
     $taxpayment_ids = array();
     foreach ($this->request->post() as $key => $value) {
         if ($value == "print-check") {
             $key_array = explode('-', $key);
             ${$key_array[0] . '_ids'}[] = $key_array[1];
         }
     }
     $print_vendor_checks = new View_Vendors_Print_Checks();
     $print_vendor_checks->expenses = array();
     $print_vendor_checks->payments = array();
     $print_vendor_checks->taxpayments = array();
     if (count($expense_ids) or count($payment_ids) or count($taxpayment_ids)) {
         foreach ($expense_ids as $expense_id) {
             $expense_lookup = new Beans_Vendor_Expense_Lookup($this->_beans_data_auth((object) array('id' => $expense_id)));
             $expense_lookup_result = $expense_lookup->execute();
             if (!$expense_lookup_result->success) {
                 throw new Exception($this->_beans_result_get_error($expense_lookup_result));
             }
             $print_vendor_checks->expenses[] = $expense_lookup_result->data->expense;
         }
         foreach ($payment_ids as $payment_id) {
             $payment_lookup = new Beans_Vendor_Payment_Lookup($this->_beans_data_auth((object) array('id' => $payment_id)));
             $payment_lookup_result = $payment_lookup->execute();
             if (!$payment_lookup_result->success) {
                 throw new Exception($this->_beans_result_get_error($payment_lookup_result));
             }
             $print_vendor_checks->payments[] = $payment_lookup_result->data->payment;
         }
         foreach ($taxpayment_ids as $taxpayment_id) {
             $tax_payment_lookup = new Beans_Tax_Payment_Lookup($this->_beans_data_auth((object) array('id' => $taxpayment_id)));
             $tax_payment_lookup_result = $tax_payment_lookup->execute();
             if (!$tax_payment_lookup_result->success) {
                 throw new Exception($this->_beans_result_get_error($tax_payment_lookup_result));
             }
             $print_vendor_checks->taxpayments[] = $tax_payment_lookup_result->data->payment;
         }
     } else {
         throw new Exception("Please include at least one check to print.");
     }
     die($print_vendor_checks->render());
 }
Beispiel #3
0
 public function action_taxes()
 {
     $tax_id = FALSE;
     $tax_payment_id = FALSE;
     if ($this->request->post('tax_id')) {
         $tax_id = $this->request->post('tax_id');
     }
     if ($this->request->post('tax_payment_id')) {
         $tax_payment_id = $this->request->post('tax_payment_id');
     }
     if ($tax_id) {
         $tax_payment_search_data = new stdClass();
         $tax_payment_search_data->sort_by = 'newest';
         $tax_payment_search_data->page_size = 24;
         $tax_payment_search_data->search_tax_id = $tax_id;
         $tax_payment_search = new Beans_Tax_Payment_Search($this->_beans_data_auth($tax_payment_search_data));
         $tax_payment_search_result = $tax_payment_search->execute();
         if ($this->_beans_result_check($tax_payment_search_result)) {
             $this->_view->tax_payments = $tax_payment_search_result->data->payments;
         }
     }
     if ($tax_id && $tax_payment_id) {
         if ($tax_payment_id == "prep") {
             $date_start = date("Y-m-d");
             $date_end = date("Y-m-d");
             $tax_prep = new Beans_Tax_Prep($this->_beans_data_auth((object) array('id' => $tax_id, 'date_start' => $date_start, 'date_end' => $date_end)));
             $tax_prep_result = $tax_prep->execute();
             if ($this->_beans_result_check($tax_prep_result)) {
                 $this->_view->payment = (object) array('id' => NULL, 'prep' => TRUE, 'tax' => $tax_prep_result->data->tax, 'amount' => NULL, 'writeoff_amount' => NULL, 'date' => NULL, 'date_start' => $tax_prep_result->data->date_start, 'date_end' => $tax_prep_result->data->date_end, 'check_number' => NULL, 'invoiced_line_amount' => $tax_prep_result->data->taxes->due->invoiced->form_line_amount, 'invoiced_line_taxable_amount' => $tax_prep_result->data->taxes->due->invoiced->form_line_taxable_amount, 'invoiced_amount' => $tax_prep_result->data->taxes->due->invoiced->amount, 'refunded_line_amount' => $tax_prep_result->data->taxes->due->refunded->form_line_amount, 'refunded_line_taxable_amount' => $tax_prep_result->data->taxes->due->refunded->form_line_taxable_amount, 'refunded_amount' => $tax_prep_result->data->taxes->due->refunded->amount, 'net_line_amount' => $tax_prep_result->data->taxes->due->net->form_line_amount, 'net_line_taxable_amount' => $tax_prep_result->data->taxes->due->net->form_line_taxable_amount, 'net_amount' => $tax_prep_result->data->taxes->due->net->amount, 'liabilities' => array_merge($tax_prep_result->data->taxes->due->invoiced->liabilities, $tax_prep_result->data->taxes->due->refunded->liabilities), 'amount' => NULL, 'writeoff_amount' => NULL);
             }
         } else {
             $tax_payment_lookup = new Beans_Tax_Payment_Lookup($this->_beans_data_auth((object) array('id' => $tax_payment_id)));
             $tax_payment_lookup_result = $tax_payment_lookup->execute();
             if ($this->_beans_result_check($tax_payment_lookup_result)) {
                 $this->_view->payment = $tax_payment_lookup_result->data->payment;
             }
         }
     }
     $this->_action_tab_name = "Sales Tax";
     $this->_action_tab_uri = '/' . $this->request->uri();
 }
Beispiel #4
0
 public function action_taxpayment()
 {
     $taxpayment_id = $this->request->param('id');
     $tax_payment_lookup = new Beans_Tax_Payment_Lookup($this->_beans_data_auth((object) array('id' => $taxpayment_id)));
     $tax_payment_lookup_result = $tax_payment_lookup->execute();
     if (!$tax_payment_lookup_result->success) {
         // V2Item - Clean up and output nicely.
         die("An error occurred: " . $tax_payment_lookup_result->auth_error . $tax_payment_lookup_result->error);
     }
     $vendors_print_taxpayment = new View_Vendors_Print_Taxpayment();
     $vendors_print_taxpayment->setup_company_list_result = $this->_setup_company_list_result;
     $vendors_print_taxpayment->payment = $tax_payment_lookup_result->data->payment;
     die($vendors_print_taxpayment->render());
 }