Exemplo n.º 1
0
/* DENqa39707*/
EXPORT int insert_abp_serv_inst_product_by_date(ABP_DBHANDLE dbhandle, 
				 ABP_SERV_INST_PRODUCT serv_inst_product,
                                 ABP_LOCSTR *a_effective_date)
{
  int 	retval,rowcount=0;
  PRODUCT_VIEW_DATA *pvd;
  PRODUCT_KEY_DATA *pkd;
  CUSTOMER_ID_EQUIP_MAP_DATA *cid;
  CUSTOMER_ID_ACCT_MAP_DATA *cida, *cid_bill_rc;
  short status_new = STATUS_NEW, xid_type = 0,disconnect_reason=0;
  char external_id[CUSTOMER_ID_EQUIP_MAP_external_id_SZ];
  ABP_LOCSTR a_external_id;
  int account_no, bill_rc_account_no = 0, tracking_id;
  Arb_connection *connection;
  Arb_date product_start;
  ACCOUNT_BALANCE acct_bal;
  char err_msg[512], szeffective_date[DEF_STR_LEN];
  Arb_numeric arbneg;
/*added for DENqa13565*/
  BAL_MAP_TO_VALUES bmtv;
  Arb_date si_end, effective_date;
/*added for DENqa44281*/
  unsigned char auto_activation;


  if (NotCustDbhandle(dbhandle))
    return ABP_ARGERR;
  connection = dbhandle->cust_connection;

  ((ABP_ERR_DATA *)connection->user_data)->is_set = FALSE;

  if (WRONG_OBJ_TYPE(serv_inst_product, SERV_INST_PRODUCT))
    return ABP_ARGERR;

  pvd = serv_inst_product->product_view_data;
  pkd = serv_inst_product->product_key_data;
  cid = serv_inst_product->customer_id_equip_map_data;
  
  api_convert_input_string(szeffective_date, a_effective_date, DEF_STR_LEN);
  if ((a_effective_date != NULL) && (*szeffective_date != '\0'))
        api_string_to_Arbdate(szeffective_date, &effective_date, 0); 

/* DENqa00595: Prepay: 
 *                     1. Add another CUSTOMER_ID_ACCT_MAP table into serv_inst_product object
 *                     2. Expose open_item_id_map
 */
  cida = serv_inst_product->customer_id_acct_map_data[0];
  cid_bill_rc = serv_inst_product->customer_id_acct_map_data[1];

  /* always set has_product_keys,has_overrides to 0 when insert, this field is managed by DB trigger */
  set_product_view_has_product_keys(pvd,0);
  set_product_view_has_overrides(pvd, 0);

  /* Error if the user tries to set component_id.  This function only inserts
   * a la carte products.  We want to insert PRODUCT_VIEW.component_id = NULL,
   * so just leave it unset and let the db default.
   */
  if (IsSet (product_view_component_id, pvd))
  {
      abp_put_misc_message (connection, ABP_RANGE_ERR, "component_id");
      return ABP_MISC_ERR;
  }

  if (IsSet (product_view_connect_reason, pvd))
  {
      abp_put_misc_message (connection, ABP_RANGE_ERR, "connect_reason");
      return ABP_MISC_ERR;
  }

  if (IsSet (product_view_prev_product_inactive_dt, pvd))
  {
      abp_put_misc_message (connection, ABP_RANGE_ERR, "prev_end_dt");
      return ABP_MISC_ERR;
  }

  if (!IsSet(product_view_element_id, pvd))
   {
      abp_put_misc_message (connection, ABP_NO_VALUE_ERR,"element_id");
       return ABP_MISC_ERR;
   }

  if (get_abp_serv_inst_product_external_id_type(serv_inst_product, &xid_type) 
      != ABP_SET) {
    abp_put_misc_message(connection, ABP_NO_VALUE_ERR, "external_id_type");
    return ABP_MISC_ERR;
  }
  if (get_abp_serv_inst_product_external_id(serv_inst_product, &a_external_id) 
      != ABP_SET) {
    abp_put_misc_message(connection, ABP_NO_VALUE_ERR, "external_id");
    return ABP_MISC_ERR;
  }

  api_convert_input_string(external_id, &a_external_id, CUSTOMER_ID_EQUIP_MAP_external_id_SZ);
  /* DENqa39707*/
  if ((retval = find_subscr_no(connection, external_id, xid_type,
			       &(pvd->parent_subscr_no),
			       &(pvd->parent_subscr_no_resets),
                               (a_effective_date != NULL) && (*szeffective_date != '\0') ? &effective_date : NULL)) == ABP_STATUS_OK) {
    Set(product_view_parent_subscr_no, pvd);
    Set(product_view_parent_subscr_no_resets, pvd);
  }
  else 
    return retval;

  /* DENqa39707 find account no from emf is enough*/
    if ((retval = find_account_no_from_emf(connection, 
					   pvd->parent_subscr_no, 
					   pvd->parent_subscr_no_resets,
					   &account_no))
	!= ABP_STATUS_OK)
      return retval;

  set_product_view_parent_account_no(pvd, account_no);

  if (!IsSet(product_view_product_active_dt, pvd)) { /* get server date */
  	arb_setup_results(&proc_get_server_date, ARB_TYPE_DATESMALL, &product_start);
	arb_setup_proc_exec(connection, &proc_get_server_date, SQL_DEFER_EXECUTE, NO_MORE_ARGS);
	while (arb_next_row(connection) == ARB_MORE_DATA)
		;
  	if (arb_query_status(connection) == FAILURE)
		return ABP_DBERR;
  	set_product_view_product_active_dt(pvd, &product_start);
  } 
  truncate_Arbdate(&(pvd->product_active_dt));
  
 /*DENqa40378. Check to see if the if the SI has an end_date. If it has an end_date
    then update the product stop date with the SI end_date  */

  zero_Arbdate(&si_end); 
  arb_dbcmd (connection, "SELECT service_inactive_dt from SERVICE "); 
  arb_dbfcmd(connection, "WHERE subscr_no = %d ", pvd->parent_subscr_no);
  arb_dbfcmd(connection, "AND subscr_no_resets = %d ", pvd->parent_subscr_no_resets);
  arb_exec_string(connection,"",SQL_DEFER_EXECUTE);
  arb_dbbind(connection, 1, ARB_TYPE_DATESMALL, 0, &si_end);

  for(rowcount = 0; arb_next_row(connection) == ARB_MORE_DATA; rowcount++)
    ;
  if (arb_query_status(connection)==FAILURE)
    return ABP_DBERR;
 
  if( ! Arbdate_is_null(&si_end))
  {
     if ( !IsSet(product_view_product_inactive_dt, pvd)  
          || (IsSet(product_view_product_inactive_dt, pvd) && (Arbdate_compare(&pvd->product_inactive_dt,&si_end)> 0) ) )
     {
	 set_product_view_product_inactive_dt (pvd, &si_end);
     }
  }
	
  if (IsSet(product_view_product_inactive_dt, pvd))
    truncate_Arbdate(&(pvd->product_inactive_dt));

  /* BIP never picks up the product if date_rc_begin is NULL.
   * (CAMqa44989)
   */
  if (!IsSet(product_view_billing_active_dt, pvd))
  {
    if (Arbdate_copy(&pvd->billing_active_dt, &pvd->product_active_dt) != SUCCESS)
    {
	abp_put_misc_message(connection, ABP_BAD_DATE_STRING, "billing_active_dt");
	return ABP_MISC_ERR;
    }
    Set(product_view_billing_active_dt, pvd);
  }

  if (IsSet(customer_id_acct_map_external_id, cid_bill_rc)) {
     retval = get_abp_serv_inst_product_external_account_no_bill_rc_type(serv_inst_product, &xid_type);
     if (retval == ABP_DB_NULL) {
             abp_put_misc_message(connection,ABP_NO_VALUE_ERR, "external_account_no_bill_rc_type");
             return ABP_MISC_ERR;
       }
     if (retval == ABP_NOT_SET) {
            retval = find_default_external_id_type( connection, &xid_type);
            if (retval != ABP_STATUS_OK)
                return retval;
            set_customer_id_acct_map_external_id_type(cid_bill_rc, xid_type);
       }
     /* DENqa39707*/
     if ((retval = find_account_no(connection, 
                                   cid_bill_rc->external_id,
                                   cid_bill_rc->external_id_type,
                                   &bill_rc_account_no,
                                   (a_effective_date != NULL) && (*szeffective_date != '\0') ? &effective_date : NULL)) != ABP_STATUS_OK)
         return retval;
     set_product_view_billing_account_no (pvd, bill_rc_account_no);

    }

  if (!IsSet(product_view_billing_account_no, pvd) || !IsSet(product_view_open_item_id, pvd)) { /* we should find them from OPEN_ITEM_ID_MAP table */

/*EXPORT int get_account_balance( Arb_connection *dbp,
*                                int account_no,
*                                int subscr_no,
*                                int subscr_no_resets,
*                                int c_e_type,
*                                int c_e_value,
*                                Arb_date *effective_dt,
*                                ACCOUNT_BALANCE *account_balance)
*/

  bmtv.account_no = pvd->parent_account_no;
  bmtv.subscr_no = pvd->parent_subscr_no;
  bmtv.subscr_no_resets = pvd->parent_subscr_no_resets;
  bmtv.c_e_type = CHARGE_RC_TYPE;
  bmtv.c_e_value = pvd->element_id;
  if (Arbdate_copy(&(bmtv.effective_dt), &pvd->billing_active_dt) != SUCCESS)
  {
      abp_put_misc_message(connection, ABP_BAD_DATE_STRING, "effective_dt");
      return ABP_MISC_ERR;
  }
  bmtv.rate_period = 0;
  retval = get_account_balance(connection, &bmtv, &acct_bal);

     if (retval == FAILURE){
         strcpy(err_msg , get_balance_error_msg());
         abp_put_misc_message(connection, ABP_ACCT_BALANCE_LIB_ERROR, err_msg);
         return ABP_MISC_ERR;
     }

     if (!IsSet(product_view_billing_account_no, pvd))
             set_product_view_billing_account_no(pvd, acct_bal.balance_account_no);
     if (!IsSet(product_view_open_item_id, pvd))
             set_product_view_open_item_id(pvd, acct_bal.open_item_id);
     
   } 
         
  truncate_Arbdate(&(pvd->billing_active_dt));

  /* DENqa44281 - for auto_activation != 0 products, billing_active_dt should be NULL */
  arb_dbcmd(connection, "SELECT auto_activation from PRODUCT_ELEMENTS ");
  arb_dbfcmd(connection, "WHERE element_id = %d", pvd->element_id);
  arb_exec_string(connection, "", SQL_DEFER_EXECUTE);
  arb_dbbind(connection, 1, ARB_TYPE_INT8, 0, &auto_activation);
  rowcount = 0;
  while(arb_next_row(connection) == ARB_MORE_DATA)
    rowcount++;
  if (arb_query_status(connection) == FAILURE)
    return ABP_DBERR;
  if (rowcount == 0) {
    abp_put_misc_message(connection, ABP_ROW_NOT_FOUND, "PRODUCT_ELEMENTS");
    return ABP_MISC_ERR;
  }
  if (auto_activation != 0)
    SetToNull(product_view_billing_active_dt, pvd);
  /* DENqa44281 */

  arb_numeric_from_int(&arbneg,-1);

  /* Increment SEQ_NUM outside the transaction */
  if ((tracking_id = incr_seqnum(connection, "PRODUCT")) < 0) {
	if (arb_query_status(connection) != SUCCESS)
      		return ABP_DBERR;
	else {
		abp_put_misc_message(connection, ABP_ROW_NOT_FOUND, "SEQ_NUM (PRODUCT)");
		return ABP_MISC_ERR;
	}
  }

  
  if ((retval = abp_begin_transaction_inner(dbhandle,
				      "abp_insert_serv_inst_product")) 
      != ABP_STATUS_OK)
    return retval;

  arb_setup_proc_exec(connection, &proc_api_pp_insert_alacarte_product,SQL_EXECUTE_NOW,
        "account_no",account_no, ARG_NOT_NULL,
        "element_id",pvd->element_id, ARG_NOT_NULL,
        "start_date",&(pvd->product_active_dt), ARG_NOT_NULL ,
        "rc_date",&(pvd->billing_active_dt), IsSet(product_view_billing_active_dt,pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
        "override_rate", &arbneg, ARG_NOT_NULL, /* -1 signifies no override */
        "account_no_bill_rc",pvd->billing_account_no, ARG_NOT_NULL,
        "subscr_no",pvd->parent_subscr_no, ARG_NOT_NULL,
        "subscr_no_resets",pvd->parent_subscr_no_resets,ARG_NOT_NULL,
        "auto_activation", pvd->auto_activation, IsSet(product_view_auto_activation, pvd)?ARG_NOT_NULL: ARG_IS_NULL,
        "in_arrears_override",pvd->in_arrears_override,ARG_NOT_NULL,
        "order_number",pvd->order_number, IsSet(product_view_order_number,pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
        "serial_number",pvd->serial_number, IsSet(product_view_serial_number,pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
        "bill_period",pvd->bill_period, IsSet(product_view_bill_period,pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
        "stop_date",&(pvd->product_inactive_dt), IsSet(product_view_product_inactive_dt,pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
        "chg_order",IsSet(product_view_charge_order, pvd) ? pvd->charge_order : 0, ARG_NOT_NULL,
        "converted",IsSet(product_key_converted,pkd) ? pkd->converted : 0, ARG_NOT_NULL,
        "api_caller",tracking_id,ARG_NOT_NULL,
        "tracking_id_serv",dbhandle->cust_server_id , ARG_NOT_NULL,
        "sales_channel_id", pvd->sales_channel_id, IsSet(product_view_sales_channel_id, pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
        "open_item_id", pvd->open_item_id,  ARG_NOT_NULL,
	"rc_date_end", &(pvd->billing_inactive_dt), IsSet(product_view_billing_inactive_dt, pvd) ? ARG_NOT_NULL : ARG_IS_NULL, 
        "no_bill", IsSet(product_view_no_bill, pvd) ? pvd->no_bill : 0, ARG_NOT_NULL, NO_MORE_ARGS);

  if (arb_query_status(connection) != SUCCESS) {
        abp_roll_back_transaction_inner(dbhandle,"abp_insert_serv_inst_product");
        return ABP_DBERR;
  }
  else {
        set_product_key_tracking_id(pkd,tracking_id);
	set_product_view_tracking_id(pvd, tracking_id);
        set_product_key_tracking_id_serv(pkd,dbhandle->cust_server_id);
        set_product_view_tracking_id_serv(pvd, dbhandle->cust_server_id);
        return abp_commit_transaction_inner(dbhandle,"abp_insert_serv_inst_product");
  }
}
Exemplo n.º 2
0
EXPORT int insert_abp_acct_product_by_date(ABP_DBHANDLE dbhandle, ABP_ACCT_PRODUCT acct_product, ABP_LOCSTR *a_effective_date)
{
  int retval, account_no, bill_rc_account_no = 0, tracking_id;
  Arb_connection *connection;
  PRODUCT_VIEW_DATA *pvd;
  PRODUCT_KEY_DATA *pkd;
  CUSTOMER_ID_ACCT_MAP_DATA *cid, *cid_bill_rc;
  short xid_type = 0,default_xid_type = 0;
  Arb_numeric arbneg;
  ACCOUNT_BALANCE acct_bal;
  char err_msg[512];
/*added for DENqa13565*/
  BAL_MAP_TO_VALUES bmtv;
  char szeffective_date[DEF_STR_LEN];
  Arb_date effective_date;

  api_convert_input_string(szeffective_date, a_effective_date, DEF_STR_LEN);
  if ((a_effective_date != NULL) && (*szeffective_date != '\0'))
    api_string_to_Arbdate(szeffective_date, &effective_date, 0);

  if (WRONG_OBJ_TYPE(acct_product, ACCT_PRODUCT))
    return ABP_ARGERR;
  if (NotCustDbhandle(dbhandle))
    return ABP_ARGERR;
  connection = dbhandle->cust_connection;
  ((ABP_ERR_DATA *)connection->user_data)->is_set = FALSE;
  pvd = acct_product->product_view_data;
  pkd = acct_product->product_key_data;
  cid = acct_product->customer_id_acct_map_data[0];
  cid_bill_rc = acct_product->customer_id_acct_map_data[1];

  /* always set has_product_keys, has_overrides to 0 when insert, this field is managed by DB trigger */
  set_product_view_has_product_keys(pvd, 0);
  set_product_view_has_overrides(pvd, 0);

  if (IsSet(product_view_connect_reason, pvd)) {
      abp_put_misc_message (connection, ABP_RANGE_ERR, "connect_reason");
      return ABP_MISC_ERR;
  }

  if (IsSet(product_view_prev_product_inactive_dt, pvd)) {
      abp_put_misc_message (connection, ABP_RANGE_ERR, "prev_end_dt");
      return ABP_MISC_ERR;
  }
  
  /* Error if the user tries to set component_id.  This function only inserts
   * a la carte products.
   */
  if (IsSet (product_view_component_id, pvd))
  {
      abp_put_misc_message (connection, ABP_RANGE_ERR, "component_id");
      return ABP_MISC_ERR;
  }

  if (!IsSet(product_view_element_id, pvd)) 
   {
      abp_put_misc_message (connection, ABP_NO_VALUE_ERR,"element_id");
       return ABP_MISC_ERR;
   }

  if (IsSet(customer_id_acct_map_external_id, cid)) {
 	retval = get_abp_acct_product_external_id_type(acct_product, &xid_type);
	if (retval == ABP_DB_NULL) {
		abp_put_misc_message(connection,ABP_NO_VALUE_ERR, "external_id_type");
		return ABP_MISC_ERR;
	}
	if (retval == ABP_NOT_SET) {
		retval = find_default_external_id_type( connection, &default_xid_type);
		if (retval != ABP_STATUS_OK)
			return retval;
		set_customer_id_acct_map_external_id_type(cid, default_xid_type);
	}
        retval = find_account_no(connection, cid->external_id,cid->external_id_type, &account_no, (a_effective_date != NULL) && (*szeffective_date != '\0') ? &effective_date : NULL);
	if (retval != ABP_STATUS_OK)
		return retval;
        set_product_view_parent_account_no(pvd, account_no);
  }
  else {
	abp_put_misc_message(connection, ABP_NO_VALUE_ERR, "external_id");
	return ABP_MISC_ERR;
  }
  
  if (!IsSet(product_view_product_active_dt, pvd)) {
        arb_setup_results(&proc_get_server_date, ARB_TYPE_DATELONG, &(pvd->product_active_dt));
        arb_setup_proc_exec(connection, &proc_get_server_date, SQL_DEFER_EXECUTE, NO_MORE_ARGS);
        while (arb_next_row(connection) == ARB_MORE_DATA)
                ;
        if (arb_query_status(connection) != SUCCESS)
                return ABP_DBERR;
        else
                Set(product_view_product_active_dt, pvd);
  }
  truncate_Arbdate(&(pvd->product_active_dt));

  /* BIP never picks up the product if billing_active_dt is NULL.
   * (CAMqa44989)
   */
  if (!IsSet(product_view_billing_active_dt, pvd))
  {
    if (Arbdate_copy(&pvd->billing_active_dt, &pvd->product_active_dt) != SUCCESS)
    {
        abp_put_misc_message(connection, ABP_BAD_DATE_STRING, "date_rc_begin");
        return ABP_MISC_ERR;
    }
    Set(product_view_billing_active_dt, pvd);
  }

  if (IsSet(customer_id_acct_map_external_id, cid_bill_rc)) {
	xid_type = 0; 
	retval = get_abp_acct_product_external_account_no_bill_rc_type(acct_product, &xid_type);
	if (retval == ABP_DB_NULL) {
		abp_put_misc_message(connection,ABP_NO_VALUE_ERR, "external_account_no_bill_rc_type");
		return ABP_MISC_ERR;
	}
	if (retval == ABP_NOT_SET) { 
		if (default_xid_type == 0) { /*only find the default type if it has not yet been found */
			retval = find_default_external_id_type( connection, &xid_type);
			if (retval != ABP_STATUS_OK)
				return retval;
		}
		set_customer_id_acct_map_external_id_type(cid_bill_rc, default_xid_type);
	}
        retval = find_account_no(connection, cid_bill_rc->external_id,cid_bill_rc->external_id_type, &bill_rc_account_no, (a_effective_date != NULL) && (*szeffective_date != '\0') ? &effective_date : NULL);
	if (retval != ABP_STATUS_OK)
		return retval;
        set_product_view_billing_account_no(pvd, bill_rc_account_no);
  }

   if (!IsSet(product_view_billing_account_no,pvd) || !IsSet(product_view_open_item_id, pvd)) { 
  	
   /* DENqa00595 - API work needed by iCmodules for Prepay solution. 			
      account_no_bill_rc and open_item_id can be found from OPEN_ITEM_ID_MAP table
   */   
  /* Don't load global account balances here, this will now be done in bal_map_lib */   

/*EXPORT int get_account_balance( Arb_connection *dbp,
*                                int account_no,
*                                int subscr_no,
*                                int subscr_no_resets,
*                                int c_e_type,
*                                int c_e_value,
*                                Arb_date *effective_dt,
*                                ACCOUNT_BALANCE *account_balance)
*/

  bmtv.account_no = pvd->parent_account_no;
  bmtv.subscr_no = 0;
  bmtv.subscr_no_resets = 0;
  bmtv.c_e_type = CHARGE_RC_TYPE;
  bmtv.c_e_value = pvd->element_id;
  if (Arbdate_copy(&(bmtv.effective_dt), &pvd->billing_active_dt) != SUCCESS)
  {
      abp_put_misc_message(connection, ABP_BAD_DATE_STRING, "effective_dt");
      return ABP_MISC_ERR;
  }
  bmtv.rate_period = 0;
  retval = get_account_balance(connection, &bmtv, &acct_bal);

   if (retval == FAILURE){
      strcpy(err_msg , get_balance_error_msg());
      abp_put_misc_message(connection, ABP_ACCT_BALANCE_LIB_ERROR, err_msg);
      return ABP_MISC_ERR;
   }
    
   if (!IsSet(product_view_billing_account_no,pvd))
       set_product_view_billing_account_no(pvd, acct_bal.balance_account_no);
   if (!IsSet(product_view_open_item_id, pvd)) 
       set_product_view_open_item_id(pvd, acct_bal.open_item_id);    
   
  }

  truncate_Arbdate(&(pvd->billing_active_dt));

  arb_numeric_from_int(&arbneg,-1); 	
  tracking_id = incr_seqnum(connection, "PRODUCT");
  if (tracking_id == -1) {
	if (arb_query_status(connection) != SUCCESS)
		return ABP_DBERR;
	else {
		abp_put_misc_message(connection, ABP_ROW_NOT_FOUND, "SEQ_NUM (PRODUCT)");
		return ABP_MISC_ERR;
	}
  }
  if ((retval = abp_begin_transaction_inner(dbhandle, "abp_insert_acct_product")) != ABP_STATUS_OK)
	return retval;

  arb_setup_proc_exec(connection, &proc_api_pp_insert_alacarte_product,SQL_EXECUTE_NOW,
	"account_no",account_no, ARG_NOT_NULL,
	"element_id",pvd->element_id, ARG_NOT_NULL,
	"start_date",&(pvd->product_active_dt), ARG_NOT_NULL ,
	"rc_date",&(pvd->billing_active_dt), IsSet(product_view_billing_active_dt,pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
	"override_rate", &arbneg, ARG_NOT_NULL, /* -1 signifies no override */
	"account_no_bill_rc",pvd->billing_account_no, ARG_NOT_NULL,
	"subscr_no",0, ARG_IS_NULL,
	"subscr_no_resets",0,ARG_IS_NULL,
	"in_arrears_override",pvd->in_arrears_override,ARG_NOT_NULL,
	"order_number",pvd->order_number, IsSet(product_view_order_number,pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
	"serial_number",pvd->serial_number, IsSet(product_view_serial_number,pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
  	"bill_period",pvd->bill_period, IsSet(product_view_bill_period,pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
	"stop_date",&(pvd->product_inactive_dt), IsSet(product_view_product_inactive_dt,pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
	"chg_order",IsSet(product_view_charge_order, pvd) ? pvd->charge_order : 0, ARG_NOT_NULL,
	"converted",IsSet(product_key_converted,pkd) ? pkd->converted : 0, ARG_NOT_NULL,
	"api_caller",tracking_id,ARG_NOT_NULL,
	"tracking_id_serv",dbhandle->cust_server_id , ARG_NOT_NULL, 
	"sales_channel_id", pvd->sales_channel_id, IsSet(product_view_sales_channel_id, pvd) ? ARG_NOT_NULL : ARG_IS_NULL,
        "open_item_id", pvd->open_item_id,  ARG_NOT_NULL, 
        "no_bill", IsSet(product_view_no_bill, pvd) ? pvd->no_bill : 0, ARG_NOT_NULL, NO_MORE_ARGS);
  if (arb_query_status(connection) != SUCCESS) {
	abp_roll_back_transaction_inner(dbhandle,"abp_insert_acct_product");
	return ABP_DBERR;
  }
  else {
        set_product_key_tracking_id(pkd,tracking_id);	
	set_product_view_tracking_id(pvd, tracking_id);
        set_product_key_tracking_id_serv(pkd,dbhandle->cust_server_id);	
        set_product_view_tracking_id_serv(pvd,dbhandle->cust_server_id);    
	return abp_commit_transaction_inner(dbhandle,"abp_insert_acct_product");
  }

}
Exemplo n.º 3
0
// This program allows a teller to enter in account details and the program will calculate account information for the teller
int main() {
  float account_balance;
  char account_type;
  char exit_program_flag;
  int total_number_of_accounts = 0;
  float total_amount_in_accounts = 0;
  int minimum_balance_fee = 35;
  int total_minimum_balance_fees = 0;
  int total_accounts_with_minimum_balance_fees = 0;
  int minimum_balance_fee_charged_flag = 0;
  float account_balances[MAX_NUMBER_OF_ACCOUNTS];
  int current_account_number = 0;
  char account_holder[MAX_ACCOUNT_HOLDER_SIZE]; 
  char valid_account_type_flag = VALID_ACCOUNT_TYPE;
  char buf[255];
  
  do  {
    current_account_number++;
    minimum_balance_fee_charged_flag = MINIMUM_BALANCE_FEE_NOT_CHARGED;
    valid_account_type_flag = VALID_ACCOUNT_TYPE;
    go:
    get_account_holder(account_holder);
    FILE *fp;
    fp = fopen("stop_list.dat","r");
    int counter=0;
    while (fgets(buf,255,fp)!=NULL)
    {
      
      //printf("%d\n",counter);
      //printf("%s",buf);
      if(strcmp(buf,account_holder)==0)
      {
        goto stop;
      }
      //counter++;
    }
    account_balance = get_account_balance();
    account_type = get_account_type();
    
    if ((account_type == 's') && (account_balance < SAVINGS_ACCOUNT_MINIMUM_BALANCE)) {
      minimum_balance_fee_charged_flag = MINIMUM_BALANCE_FEE_CHARGED;
    } else if ((account_type == 'c') && (account_balance < CHECKING_ACCOUNT_MINIMUM_BALANCE)) {
      minimum_balance_fee_charged_flag = MINIMUM_BALANCE_FEE_CHARGED;
    } else {
      if ((account_type != 's') && (account_type != 'c')) {
        printf ("The account type was invalid\n");
        valid_account_type_flag = INVALID_ACCOUNT_TYPE;
      } else {
        printf ("A minimum balance fee does not need to be charged to this account\n");
      }
    }      
    
    if (valid_account_type_flag == VALID_ACCOUNT_TYPE) {
      // Display account summary information
      printf ("=== Account Information for %s's Account ===\n", account_holder);
      if (minimum_balance_fee_charged_flag) {
        total_accounts_with_minimum_balance_fees++;
        total_minimum_balance_fees += minimum_balance_fee;
        printf ("Minimum Balance Fee to Account Balance Percentage: %.1f%%\n", minimum_balance_fee / account_balance * PERCENT_CONVERSION_FACTOR);
        printf ("The new account balance is $%.2f\n", net_balance(account_balance, minimum_balance_fee));
      } else {
        printf ("Minimum Balance Fee to Account Balance Percentage: %.1f%%\n", NO_MINIMUM_BALANCE / account_balance);
        printf ("The new account balance is $%.2f\n", net_balance(account_balance, NO_MINIMUM_BALANCE));
      }
      
      update_account_summary_information(&total_number_of_accounts, &total_amount_in_accounts, account_balance);
      account_balances[current_account_number+ARRAY_OFFSET] = account_balance;
    }
    
    exit_program_flag = ask_to_exit();
  } while (exit_program_flag == CONTINUE_PROGRAM);
  
  output_account_summary_to_file(total_number_of_accounts, total_amount_in_accounts, total_minimum_balance_fees, total_accounts_with_minimum_balance_fees);
  output_list_of_account_balances(account_balances, total_number_of_accounts);
  
  return 0;
  stop:
  printf("this person is on the stop list\n");
  goto go;
}
// This program allows a teller to enter in account details and the program will calculate account information for the teller
int main() {
  float account_balance;
  char account_type;
  char exit_program_flag = CONTINUE_PROGRAM;
  int total_number_of_accounts = 0;
  float total_amount_in_accounts = 0;
  int minimum_balance_fee = 35;
  int total_minimum_balance_fees = 0;
  int total_accounts_with_minimum_balance_fees = 0;
  int minimum_balance_fee_charged_flag = 0;
  // declare array
  float account_balances[MAX_NUMBER_OF_ACCOUNTS];
  int minimum_balance_fees[MAX_NUMBER_OF_ACCOUNTS];
  
  while (exit_program_flag == CONTINUE_PROGRAM) {
    account_balance = get_account_balance();
    account_type = get_account_type();

    if (account_type == 's') {
      minimum_balance_fee_charged_flag = is_account_below_minimum_balance(account_balance, SAVINGS_ACCOUNT_MINIMUM_BALANCE);
    } else {
      minimum_balance_fee_charged_flag = is_account_below_minimum_balance(account_balance, CHECKING_ACCOUNT_MINIMUM_BALANCE);
    }  
    
    // Display account summary information
    if (minimum_balance_fee_charged_flag) {
      total_accounts_with_minimum_balance_fees++;
      total_minimum_balance_fees += minimum_balance_fee;
      minimum_balance_fees[total_number_of_accounts] = minimum_balance_fee;
      printf ("Minimum Balance Fee to Account Balance Percentage: %.1f%%\n", minimum_balance_fee / account_balance * PERCENT_CONVERSION_FACTOR);
      printf ("The new account balance is $%.2f\n", net_balance(account_balance, minimum_balance_fee));
    } else {
      minimum_balance_fees[total_number_of_accounts] = NO_MINIMUM_BALANCE;
      printf ("Minimum Balance Fee to Account Balance Percentage: %.1f%%\n", NO_MINIMUM_BALANCE / account_balance);
      printf ("The new account balance is $%.2f\n", net_balance(account_balance, NO_MINIMUM_BALANCE));
    }
    
    // Display accounts summary information
    account_balances[total_number_of_accounts] = account_balance;
    
    // add account balance to list of account balances
    update_account_summary_information(&total_number_of_accounts, &total_amount_in_accounts, account_balance);
    
    // Display accounts summary information: 2nd option
    //printf("total_number_of_accounts: %d\n", total_number_of_accounts);
    //account_balances[total_number_of_accounts-1] = account_balance;
    
    exit_program_flag = ask_to_exit();
  }

  printf ("==== Accounts Summary ====\n");
  printf ("The total number of accounts: %d\n", total_number_of_accounts);
  printf ("The total amount in all accounts: $%.2f\n", total_amount_in_accounts);
  printf ("The percentage of the total minimum balance fees with respect to the total account balances: %.1f%%\n", total_minimum_balance_fees / total_amount_in_accounts * PERCENT_CONVERSION_FACTOR);
  printf ("The percentage of accounts that were charged a minimum balance fee: %.1f%%\n", PERCENT_CONVERSION_FACTOR * total_accounts_with_minimum_balance_fees / total_number_of_accounts);
  
  // printout list account balances entered by the teller
  print_account_balances(
    total_number_of_accounts,
    account_balances,
    minimum_balance_fees
  );
  return 0;
}
Exemplo n.º 5
0
// This program allows a teller to enter in account details and the program will calculate account information for the teller
int main() {
  float account_balance;
  char account_type;
  char exit_program_flag = CONTINUE_PROGRAM;
  int total_number_of_accounts = 0;
  float total_amount_in_accounts = 0;
  int minimum_balance_fee = 35;
  int total_minimum_balance_fees = 0;
  int total_accounts_with_minimum_balance_fees = 0;
  int minimum_balance_fee_charged_flag = 0;
  float account_balances[MAX_NUMBER_OF_ACCOUNTS];
  int current_account_number = 0;
  char account_holder[MAX_ACCOUNT_HOLDER_SIZE]; 
  
  while (exit_program_flag == CONTINUE_PROGRAM) {
    current_account_number++;
    
    // get account holder information
    printf ("Please enter the account holder:\n");
    scanf ("%s", account_holder);
    
    account_balance = get_account_balance();
    account_type = get_account_type();
    
    if (account_type == 's') {
      minimum_balance_fee_charged_flag = is_account_below_minimum_balance(account_balance, SAVINGS_ACCOUNT_MINIMUM_BALANCE);
    } else {
      minimum_balance_fee_charged_flag = is_account_below_minimum_balance(account_balance, CHECKING_ACCOUNT_MINIMUM_BALANCE);
    }  
    
    // Display account summary information
    printf ("=== Account Information for %s's Account ===\n", account_holder);
    if (minimum_balance_fee_charged_flag) {
      total_accounts_with_minimum_balance_fees++;
      total_minimum_balance_fees += minimum_balance_fee;
      printf ("Minimum Balance Fee to Account Balance Percentage: %.1f%%\n", minimum_balance_fee / account_balance * PERCENT_CONVERSION_FACTOR);
      printf ("The new account balance is %.2f\n", net_balance(account_balance, minimum_balance_fee));
    } else {
      printf ("Minimum Balance Fee to Account Balance Percentage: %.1f%%\n", NO_MINIMUM_BALANCE / account_balance);
      printf ("The new account balance is $%.2f\n", net_balance(account_balance, NO_MINIMUM_BALANCE));
    }
    
    update_account_summary_information(&total_number_of_accounts, &total_amount_in_accounts, account_balance);
    account_balances[current_account_number+ARRAY_OFFSET] = account_balance;
    
    exit_program_flag = ask_to_exit();
  }
  
  FILE *fp,*fp2;
  
  fp = fopen("meow.output","w");
  fp = fopen("meow2.output","w");
  
  // Display accounts summary information
  fprintf (fp,"==== Accounts Summary ====\n");
  fprintf (fp,"The total number of accounts: %d\n", total_number_of_accounts);
  fprintf (fp,"The total amount in all accounts: $%.2f\n", total_amount_in_accounts);
  fprintf (fp,"The percentage of the total minimum balance fees with respect to the total account balances: %.1f%%\n", total_minimum_balance_fees / total_amount_in_accounts * PERCENT_CONVERSION_FACTOR);
  fprintf (fp,"The percentage of accounts that were charged a minimum balance fee: %.1f%%\n", PERCENT_CONVERSION_FACTOR * total_accounts_with_minimum_balance_fees / total_number_of_accounts);
  int balances_display_counter = 1;
  fprintf (fp,"==== List of Account Balances ====\n");
  while (balances_display_counter <= current_account_number) {
    fprintf (fp2,"%3d: $%8.2f\n", balances_display_counter, account_balances[balances_display_counter+ARRAY_OFFSET]);
    balances_display_counter++;
  }
  
  return 0;
}