FIX_API Shipping address not availble means take billing Address : ps

This commit is contained in:
VE10-Sanjeev 2024-07-04 08:12:01 +00:00
parent 7faaac70a8
commit c37ba573b1
3 changed files with 41 additions and 24 deletions

View File

@ -775,6 +775,12 @@ class ApiIntegration extends ResourceController
$result_shipping_addr = $this->save_invoice_address_in_customer_address($shipping_array,2,(int)$local_customer_id); $result_shipping_addr = $this->save_invoice_address_in_customer_address($shipping_array,2,(int)$local_customer_id);
$shipping_addr_id = $result_shipping_addr['addr_id']; $shipping_addr_id = $result_shipping_addr['addr_id'];
$shipping_addr = $result_shipping_addr['addr']; $shipping_addr = $result_shipping_addr['addr'];
}else{
if(count($billing_array) > 0){
$result_shipping_addr = $this->save_invoice_address_in_customer_address($billing_array,2,(int)$local_customer_id);
$shipping_addr_id = $result_shipping_addr['addr_id'];
$shipping_addr = $result_shipping_addr['addr'];
}
} }
if (count($records['line_items']) > 0) { if (count($records['line_items']) > 0) {
@ -954,30 +960,36 @@ class ApiIntegration extends ResourceController
$fromDate = NULL; $fromDate = NULL;
$toDate = NULL; $toDate = NULL;
$duration = 0; $duration = 0;
for ($x = 0; $x < count($result_book_category); $x++) { if($invoice_id){
$duration = isset($result_book_category[$x]['duration']) && $result_book_category[$x]['duration'] != '' && (int)$result_book_category[$x]['duration'] > 0 ? $result_book_category[$x]['duration'] * 12 : 1 * 12; $this->logger->info("Api SaveSalesDetails : Subscription Data not Inserted because I don't have => Local invoice ID = ".$invoice_id);
$this->logger->info("Api SaveSalesDetails : Duration - Given : " .$result_book_category[$x]['duration']." Final : ".$duration); for ($x = 0; $x < count($result_book_category); $x++) {
$fromDateTimestamp = strtotime($records['date_created']); $duration = isset($result_book_category[$x]['duration']) && $result_book_category[$x]['duration'] != '' && (int)$result_book_category[$x]['duration'] > 0 ? $result_book_category[$x]['duration'] * 12 : 1 * 12;
$toDateTimestamp = strtotime("+$duration months", $fromDateTimestamp); $this->logger->info("Api SaveSalesDetails : Duration - Given : " .$result_book_category[$x]['duration']." Final : ".$duration);
$fromDate = date("Y-m-d", strtotime($records['date_created'])); $fromDateTimestamp = strtotime($records['date_created']);
$toDate = date("Y-m-d", $toDateTimestamp); $toDateTimestamp = strtotime("+$duration months", $fromDateTimestamp);
// $scheme_id = $result_book_category[$x]['category_id']; b4 $fromDate = date("Y-m-d", strtotime($records['date_created']));
$scheme_id = $result_book_category[$x]['book_id']; $toDate = date("Y-m-d", $toDateTimestamp);
$dataToCheck = ['scheme_id'=>$scheme_id,'customer_id' => $local_customer_id,'invoice_id' => $invoice_id ]; // $scheme_id = $result_book_category[$x]['category_id']; b4
$existing_subscription = $api_model->getData('subscription', $dataToCheck); $scheme_id = $result_book_category[$x]['book_id'];
$dataToCheck = ['scheme_id'=>$scheme_id,'customer_id' => $local_customer_id,'invoice_id' => $invoice_id ];
$existing_subscription = $api_model->getData('subscription', $dataToCheck);
if (count($existing_subscription) > 0) { if (count($existing_subscription) > 0) {
$this->logger->info("Api SaveSalesDetails : Subscription ".count($existing_subscription)." data already exists = ".json_encode($dataToCheck)); $this->logger->info("Api SaveSalesDetails : Subscription ".count($existing_subscription)." data already exists = ".json_encode($dataToCheck));
} else { } else {
$subscription_data[$x]['scheme_id'] = $result_book_category[$x]['category_id']; $subscription_data[$x]['scheme_id'] = $scheme_id;
$subscription_data[$x]['customer_id'] = $local_customer_id; $subscription_data[$x]['customer_id'] = $local_customer_id;
$subscription_data[$x]['invoice_id'] = $invoice_id; $subscription_data[$x]['invoice_id'] = $invoice_id;
$subscription_data[$x]['from_subscription'] = $fromDate; $subscription_data[$x]['from_subscription'] = $fromDate;
$subscription_data[$x]['to_subscription'] = $toDate; $subscription_data[$x]['to_subscription'] = $toDate;
$subscription_data[$x]['mode'] = $result_book_category[$x]['category_name']; $subscription_data[$x]['mode'] = $result_book_category[$x]['category_name'];
$subscription_data[$x]['business_id']=$this->global_variable_business_id; $subscription_data[$x]['business_id']=$this->global_variable_business_id;
$this->logger->info("Api SaveSalesDetails : Subscription Data inx = $x Request data = ".json_encode($subscription_data)); $this->logger->info("Api SaveSalesDetails : Subscription Data inx = $x Request data = ".json_encode($subscription_data));
}
} }
}else{
$this->logger->info("Api SaveSalesDetails : Subscription Data not Inserted because I don't have => Local invoice ID = ".$invoice_id);
} }
// echo $fromDate; // echo $fromDate;
// echo $toDate; // echo $toDate;

View File

@ -806,7 +806,8 @@ class Invoice extends BaseController
$status = $data[0]->status; $status = $data[0]->status;
// Load view with data // Load view with data
$html = view('invoice_print_preview_template', ['data' => $data, 'invoiceItems' => $invoiceItems,'business'=>$business, 'invoice_type' => $invoice_type, 'invoiceTerms' => $data, 'status' => $status]); // $html = view('invoice_print_preview_template', ['data' => $data, 'invoiceItems' => $invoiceItems,'business'=>$business, 'invoice_type' => $invoice_type, 'invoiceTerms' => $data, 'status' => $status]);
$html = view('invoice_pdf_template', ['data' => $data, 'invoiceItems' => $invoiceItems,'business'=>$business, 'invoice_type' => $invoice_type, 'invoiceTerms' => $data, 'status' => $status]);
// Return HTML content // Return HTML content
echo $html; echo $html;

View File

@ -88,6 +88,7 @@ public function getCustomerAddressesBySchemeName($schemeName)
} }
public function getAllCustomerDetailsBySchemeName($schemeName) public function getAllCustomerDetailsBySchemeName($schemeName)
{ {
// echo "addresses - Customer";
$currentDate = date('Y-m-d'); $currentDate = date('Y-m-d');
$builder = $this->db->table('subscription'); $builder = $this->db->table('subscription');
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name,customer_addresses.mobile_no, customer_addresses.address_1,customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code,business.title as business_name,business.address as business_address,business.city as business_city,business.state as business_state,business.postal_code as business_postal_code,books.title,from_subscription,to_subscription,business.title as business_name,business.mobile_no as business_mobile_no,states.state_name'); $builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name,customer_addresses.mobile_no, customer_addresses.address_1,customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code,business.title as business_name,business.address as business_address,business.city as business_city,business.state as business_state,business.postal_code as business_postal_code,books.title,from_subscription,to_subscription,business.title as business_name,business.mobile_no as business_mobile_no,states.state_name');
@ -103,6 +104,9 @@ public function getAllCustomerDetailsBySchemeName($schemeName)
// Fetch the query result // Fetch the query result
$query = $builder->get(); $query = $builder->get();
// $lastQuery = $this->db->getLastQuery();
// $finalQueryString = $lastQuery->getQuery();
// echo $finalQueryString;
$customerDetails = []; $customerDetails = [];