Code Tidy - Pastebin

New     Fork     Embed     View raw     Report
recalc - c

Embed

You can embed this paste into a blog or website with this code:

<iframe class="codetidy" type="text/html" width="100%" src="http://codetidy.com/paste/embed/175" frameborder="0"></iframe>

Add comment

Captcha
  1. void CSPDHProcessor::RecalcTotals( TOTALS* ptgTotals )?
  2. {?
  3.     LOG_ENTER_FUNCTION(LOGGER_NAME, "CSPDHProcessor::RecalcTotals");?
  4.     //***************************************************************************?
  5.     int signacher = 1;?
  6.     BATCHRECORD br;?
  7.     int ret = 0;?
  8.     memset( ptgTotals, 0, sizeof(TOTALS) );?
  9.     ?
  10.     //***************************************************************************?
  11.     // Batch upload of all not sent to host transaction?
  12.     //***************************************************************************?
  13.     ?
  14.     if ( !m_ptrPosDb->getDBBatch().OpenBatchScrollCursorTotals(m_sTid, m_iIdHost)) ?
  15.     {?
  16.         LOG_PRINTF("RecalcTotals: OpenBatchScrollCursor, %s", m_ptrPosDb->getDBBatch().GetLastErrorMessage());?
  17.         LOG_ERROR(LOGGER_NAME);?
  18.         return;?
  19.     }?
  20.     ?
  21.     while ((ret=m_ptrPosDb->getDBBatch().FetchRowByScrollCursor(&br)) == 0)?
  22.     {?
  23.         // TODO: tole je itak del queryja?
  24.         if ( br.CurrentTransaction.InvoiceNumber == 0 )?
  25.             continue;?
  26.         // TODO: tole je del queryja?
  27.         if ( br.tgFlags.fFlags.IsNotCompleted )?
  28.             continue;?
  29.         ?
  30.         if(br.TransactionStatus != TransactionApproved && br.TransactionStatus != TransactionOfflineApproved)?
  31.             continue;?
  32.  ?
  33.         signacher = 1;?
  34.         if ( br.tgFlags.fFlags.IsReversal )?
  35.             signacher = -1;?
  36.         ?
  37.         TRANSACTION_TT_DATA* pCurrentTransaction = GetTransactionSpec( br.CurrentTransaction.TransactionType, br.CurrentTransaction.TransactionSubType );?
  38.         if ( NULL != pCurrentTransaction )?
  39.         {?
  40.             switch(pCurrentTransaction->TotalsType)?
  41.             {?
  42.             case TOTALS_DEBIT:?
  43.                 {?
  44.                     ptgTotals->db_amount+=br.Amount1*signacher;?
  45.                     ptgTotals->db_count+=signacher;?
  46.                     break;?
  47.                 }?
  48.             case TOTALS_CREDIT:?
  49.                 {?
  50.                     ptgTotals->cr_amount+=br.Amount1*signacher;?
  51.                     ptgTotals->cr_count+=signacher;?
  52.                     break;?
  53.                 }?
  54.             case TOTALS_ADJ_DEBIT:?
  55.                 {?
  56.                     ptgTotals->db_amount+=br.Amount3*signacher;?
  57.                     ptgTotals->db_count+=signacher;?
  58.                     ptgTotals->ad_amount += br.Amount1*signacher;?
  59.                     ptgTotals->ad_count+=signacher;?
  60.                     break;?
  61.                 }?
  62.             case TOTALS_ADJ_CREDIT:?
  63.                 {?
  64.                     ptgTotals->cr_amount+=br.Amount3*signacher;?
  65.                     ptgTotals->cr_count+=signacher;?
  66.                     ptgTotals->ad_amount -= br.Amount1*signacher;?
  67.                     ptgTotals->ad_count+=signacher;?
  68.                     break;?
  69.                 }?
  70.             default:?
  71.                 LOG_PRINTF("Unknown totals type, %d", pCurrentTransaction->TotalsType);?
  72.                 LOG_ERROR(LOGGER_NAME);?
  73.                 break;?
  74.             }?
  75.         }?
  76.     }?
  77.     if (ret==-1)?
  78.     {?
  79.         LOG_PRINTF("RecalcTotals: Fetch, %s", m_ptrPosDb->getDBBatch().GetLastErrorMessage());?
  80.         LOG_ERROR(LOGGER_NAME);?
  81.     }?
  82.     ?
  83.     m_ptrPosDb->getDBBatch().CloseBatchScrollCursor();?
  84. }?

Children

#176 Fork: recalc
© 2011 Code Tidy  Terms and conditions