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>
void CSPDHProcessor
::RecalcTotals( TOTALS
* ptgTotals
)
{
LOG_ENTER_FUNCTION
(LOGGER_NAME
, "CSPDHProcessor::RecalcTotals");
//***************************************************************************
int signacher
= 1;
BATCHRECORD br
;
int ret
= 0;
memset( ptgTotals
, 0, sizeof(TOTALS
) );
//***************************************************************************
// Batch upload of all not sent to host transaction
//***************************************************************************
if ( !m_ptrPosDb
->getDBBatch
().
OpenBatchScrollCursorTotals(m_sTid
, m_iIdHost
)) 
{
LOG_PRINTF
("RecalcTotals: OpenBatchScrollCursor, %s", m_ptrPosDb
->getDBBatch
().
GetLastErrorMessage());
LOG_ERROR
(LOGGER_NAME
);
return;
}
while ((ret
=m_ptrPosDb
->getDBBatch
().
FetchRowByScrollCursor(&br
)) == 0)
{
// TODO: tole je itak del queryja
if ( br.
CurrentTransaction.
InvoiceNumber == 0 )
continue;
// TODO: tole je del queryja
if ( br.
tgFlags.
fFlags.
IsNotCompleted )
continue;
if(br.
TransactionStatus != TransactionApproved
&& br.
TransactionStatus != TransactionOfflineApproved
)
continue;
signacher
= 1;
if ( br.
tgFlags.
fFlags.
IsReversal )
signacher
= -1;
TRANSACTION_TT_DATA
* pCurrentTransaction
= GetTransactionSpec
( br.
CurrentTransaction.
TransactionType, br.
CurrentTransaction.
TransactionSubType );
if ( NULL
!= pCurrentTransaction
)
{
switch(pCurrentTransaction
->TotalsType
)
{
case TOTALS_DEBIT
:
{
ptgTotals
->db_amount
+=br.
Amount1*signacher
;
ptgTotals
->db_count
+=signacher
;
break;
}
case TOTALS_CREDIT
:
{
ptgTotals
->cr_amount
+=br.
Amount1*signacher
;
ptgTotals
->cr_count
+=signacher
;
break;
}
case TOTALS_ADJ_DEBIT
:
{
ptgTotals
->db_amount
+=br.
Amount3*signacher
;
ptgTotals
->db_count
+=signacher
;
ptgTotals
->ad_amount
+= br.
Amount1*signacher
;
ptgTotals
->ad_count
+=signacher
;
break;
}
case TOTALS_ADJ_CREDIT
:
{
ptgTotals
->cr_amount
+=br.
Amount3*signacher
;
ptgTotals
->cr_count
+=signacher
;
ptgTotals
->ad_amount
-= br.
Amount1*signacher
;
ptgTotals
->ad_count
+=signacher
;
break;
}
default:
LOG_PRINTF
("Unknown totals type, %d", pCurrentTransaction
->TotalsType
);
LOG_ERROR
(LOGGER_NAME
);
break;
}
}
}
if (ret
==-1)
{
LOG_PRINTF
("RecalcTotals: Fetch, %s", m_ptrPosDb
->getDBBatch
().
GetLastErrorMessage());
LOG_ERROR
(LOGGER_NAME
);
}
m_ptrPosDb
->getDBBatch
().
CloseBatchScrollCursor();
}
Children
#176 Fork: recalc