· 8 years ago · Mar 08, 2018, 11:12 AM
1Exportfile for AOT version 1.0 or later
2Formatversion: 1
3
4***Element: CLS
5
6; Microsoft Dynamics AX Class: RetailStatementPost unloaded
7; --------------------------------------------------------------------------------
8 CLSVERSION 1
9
10 CLASS #RetailStatementPost
11 PROPERTIES
12 Name #RetailStatementPost
13 Extends #RunBaseBatch
14 RunOn #Server
15 Origin #{2D102E6B-0000-1000-D18F-676CAD609643}
16 LegacyId #11883
17 ENDPROPERTIES
18
19 METHODS
20 SOURCE #accountPeriodicDisc
21 #/// <summary>
22 #/// Finds the ledger account for periodic discount for the periodic discount type, discount amount, item and customer account passed as parameter.
23 #/// </summary>
24 #/// <param name="_offerId">
25 #/// The current value for the <c>RetailPeriodicOfferId</c>.
26 #/// </param>
27 #/// <param name="_periodicDiscAmount">
28 #/// The current value for the periodic discount amount.
29 #/// </param>
30 #/// <param name="_itemId">
31 #/// The current value of item ID.
32 #/// </param>
33 #/// <param name="_itemGroupId">
34 #/// The current value of Item group ID.
35 #/// </param>
36 #/// <param name="_custAccount">
37 #/// The current value of customer account.
38 #/// </param>
39 #/// <returns>
40 #/// The ledger account to which periodic discount is posted.
41 #/// </returns>
42 #/// <remarks>
43 #/// The ledger account returned is based on whether it is discount offer, mix and match or multibuy.
44 #/// </remarks>
45 #LedgerDimensionDefaultAccount accountPeriodicDisc(RetailDiscountOfferId _offerId, DiscAmount _periodicDiscAmount, ItemId _itemId, RetailItemGroupId _itemGroupId, CustAccount _custAccount)
46 #{
47 # LedgerDimensionDefaultAccount ret;
48 # RetailPeriodicDiscount periodicDiscount;
49 # RetailParameters retailParameters;
50 #
51 # retailParameters = RetailParameters::find();
52 # switch (retailParameters.LedgerAccountType)
53 # {
54 # case RetailBookingLedgerAccountTypeBase::Periodic :
55 # periodicDiscount = RetailPeriodicDiscount::findByOfferId(_offerId);
56 # if (periodicDiscount.DiscountLedgerDimension)
57 # {
58 # ret = periodicDiscount.DiscountLedgerDimension;
59 # }
60 # else
61 # {
62 # switch (periodicDiscount.PeriodicDiscountType)
63 # {
64 # case RetailDiscountOfferTypeBase::DiscountOffer:
65 # ret = retailParameters.OfferLedgerDimension;
66 # break;
67 # case RetailDiscountOfferTypeBase::MixAndMatch:
68 # ret = retailParameters.MixMatchLedgerDimension;
69 # break;
70 # case RetailDiscountOfferTypeBase::Multibuy:
71 # ret = retailParameters.MultiBuyLedgerDimension;
72 # break;
73 # case RetailDiscountOfferTypeBase::Threshold:
74 # ret = retailParameters.ThresholdLedgerDimension;
75 # break;
76 # }
77 # }
78 # break;
79 # case RetailBookingLedgerAccountTypeBase::Standard :
80 # ret = this.accountSalesDisc(_itemId, _itemGroupId, _custAccount);
81 # break;
82 # }
83 #
84 # return ret;
85 #}
86 ENDSOURCE
87 SOURCE #accountSales
88 #/// <summary>
89 #/// Finds the ledger account for sales revenue for the item and customer account passed as parameter.
90 #/// </summary>
91 #/// <param name="_itemId">
92 #/// The current value of item ID.
93 #/// </param>
94 #/// <param name="_itemGroupId">
95 #/// The current value of Item group ID.
96 #/// </param>
97 #/// <param name="_custAccount">
98 #/// The current value of customer account.
99 #/// </param>
100 #/// <returns>
101 #/// The ledger account to which sales revenue is posted.
102 #/// </returns>
103 #/// <remarks>
104 #/// Calls the method <c>accountItemLedgerDimension</c> to find the ledger account.
105 #/// </remarks>
106 #LedgerDimensionDefaultAccount accountSales(ItemId _itemId, RetailItemGroupId _itemGroupId, CustAccount _custAccount)
107 #{
108 # return InventPosting::accountItemLedgerDimension(InventAccountType::SalesRevenue,
109 # _itemId,
110 # _itemGroupId,
111 # 0,
112 # _custAccount,
113 # CustTable::find(_custAccount).CustGroup,
114 # CustTable::find(_custAccount).TaxGroup);
115 #}
116 ENDSOURCE
117 SOURCE #accountSalesDisc
118 #/// <summary>
119 #/// Finds the ledger account for sales discount for the item and customer account passed as parameter.
120 #/// </summary>
121 #/// <param name="_itemId">
122 #/// The current value of item ID.
123 #/// </param>
124 #/// <param name="_itemGroupId">
125 #/// The current value of Item group ID.
126 #/// </param>
127 #/// <param name="_custAccount">
128 #/// The current value of customer account.
129 #/// </param>
130 #/// <returns>
131 #/// The ledger account to which sales discount is posted.
132 #/// </returns>
133 #/// <remarks>
134 #/// Calls the method <c>accountItemLedgerDimension</c> to find the ledger account.
135 #/// </remarks>
136 #LedgerDimensionDefaultAccount accountSalesDisc(ItemId _itemId, RetailItemGroupId _itemGroupId, CustAccount _custAccount)
137 #{
138 # return InventPosting::accountItemLedgerDimension(InventAccountType::SalesDisc,
139 # _itemId,
140 # _itemGroupId,
141 # 0,
142 # _custAccount,
143 # CustTable::find(_custAccount).CustGroup,
144 # CustTable::find(_custAccount).TaxGroup);
145 #}
146 #
147 ENDSOURCE
148 SOURCE #accountTotalDisc
149 #/// <summary>
150 #/// Finds the ledger account for total discount for the discount amount passed as parameter.
151 #/// </summary>
152 #/// <param name="_custAccount">
153 #/// The current value of customer account.
154 #/// </param>
155 #/// <param name="_totalDiscAmount">
156 #/// The current value of the total discount amount.
157 #/// </param>
158 #/// <returns>
159 #/// The ledger account to which total discount is posted.
160 #/// </returns>
161 #/// <remarks>
162 #/// If the ledger account is not found the posting will be cancelled.
163 #/// </remarks>
164 #/// <exception cref="Exception::Error">
165 #/// End the operation if the ledger account to which the total discount is to be posted is not found.
166 #/// </exception>
167 #LedgerDimensionDefaultAccount accountTotalDisc(CustAccount _custAccount, DiscAmount _totalDiscAmount)
168 #{
169 # LedgerDimensionDefaultAccount ret;
170 # str transType;
171 #;
172 # if (_custAccount)
173 # {
174 # transType = "@SYS21195";
175 #
176 # ret = LedgerSystemAccounts::find(LedgerPostingType::CustInvoiceDisc).LedgerDimension;
177 # }
178 # else
179 # {
180 # transType = "@SYS6465";
181 #
182 # if (RetailParameters::find().TotalDiscountLedgerDimension)
183 # {
184 # ret = RetailParameters::find().TotalDiscountLedgerDimension;
185 # }
186 # }
187 #
188 # if (!ret && _totalDiscAmount)
189 # {
190 # checkFailed(strfmt("@SYS24816",transType));
191 # error("@SYS21533");
192 # error("@SYS93289");
193 # throw error("@SYS78886");
194 # }
195 #
196 # return ret;
197 #}
198 ENDSOURCE
199 SOURCE #addSentFiscalDocumentsToBeInquired_BR
200 #protected void addSentFiscalDocumentsToBeInquired_BR(RetailStatementTable _statementTable)
201 #{
202 # #FiscalDocumentModels_BR
203 #
204 # RetailFiscalDocument_BR retailFiscalDocument;
205 # RetailTransactionTable transactionTable;
206 # RetailEFDocumentToBeInquired_BR efDocumentToBeInquired, existingEfDocumentToBeInquired;
207 #
208 # while select RecId from retailFiscalDocument
209 # where retailFiscalDocument.Status == FiscalDocumentStatus_BR::Created
210 # && retailFiscalDocument.MessageStatus == EFDocMessageStatus_BR::Sent
211 # && retailFiscalDocument.Model == #FiscalDocModel_65
212 # && retailFiscalDocument.store == _statementTable.storeId
213 # exists join transactionTable
214 # where transactionTable.Transactionid == retailFiscalDocument.Transactionid
215 # && transactionTable.terminal == retailFiscalDocument.terminal
216 # && transactionTable.store == retailFiscalDocument.store
217 # // check if transactionTable record is inside range defined in _statementTable
218 # && (((! _statementTable.transFromDate || transactionTable.transDate > _statementTable.transFromDate
219 # || (transactionTable.transDate == _statementTable.transFromDate && (! _statementTable.transFromTime || transactionTable.transTime >= _statementTable.transFromTime)))
220 # &&
221 # (! _statementTable.transToDate || transactionTable.transDate < _statementTable.transToDate
222 # || (transactionTable.transDate == _statementTable.transToDate && (! _statementTable.transToTime || transactionTable.transTime <= _statementTable.transToTime)))))
223 # notExists join existingEfDocumentToBeInquired
224 # where existingEfDocumentToBeInquired.RetailFiscalDocument_BR == retailFiscalDocument.RecId
225 # {
226 # efDocumentToBeInquired.Status = RetailEFDocumentToBeInquiredStatus_BR::Unknown;
227 # efDocumentToBeInquired.RetailFiscalDocument_BR = retailFiscalDocument.RecId;
228 # efDocumentToBeInquired.insert();
229 # }
230 #}
231 ENDSOURCE
232 SOURCE #addTaxAdjustment
233 #/// <summary>
234 #/// Inserts the record in the <c>TaxWorkRegulation</c> table for the tax amount of the statement.
235 #/// </summary>
236 #/// <param name="salesHeader">
237 #/// The current instance of <c>SalesTable</c> table.
238 #/// </param>
239 #/// <param name="taxCode">
240 #/// The current value of tax code.
241 #/// </param>
242 #/// <param name="taxAmount">
243 #/// The current value of tax amount.
244 #/// </param>
245 #void addTaxAdjustment(SalesTable salesHeader, TaxCode taxCode, TaxAmount taxAmount)
246 #{
247 # TaxWorkRegulation taxWorkRegulation;
248 # ;
249 # taxWorkRegulation.HeadingTableId = salesHeader.TableId;
250 # taxWorkRegulation.HeadingRecId = salesHeader.RecId;
251 # taxWorkRegulation.TaxDirection = TaxDirection::OutgoingTax;
252 # taxWorkRegulation.ManualInsertedTax = NoYes::No;
253 #
254 # taxWorkRegulation.TaxCode = taxCode;
255 # taxWorkRegulation.TaxRegulationAmountCur = taxAmount;
256 #
257 # taxWorkRegulation.insert();
258 #
259 #}
260 ENDSOURCE
261 SOURCE #checkStatement
262 #[SysObsoleteAttribute('checkStatement method is no longer public.', true)]
263 #boolean checkStatement()
264 #{
265 # return true;
266 #}
267 #
268 ENDSOURCE
269 SOURCE #classDeclaration
270 #/// <summary>
271 #/// Post the Retail statement.
272 #/// </summary>
273 #/// <remarks>
274 #/// Post the statement amount and related tax amounts, discounts and payment transactions accordingly.
275 #/// </remarks>
276 #class RetailStatementPost extends RunBaseBatch
277 #{
278 # RetailStatementTable statementTable;
279 # RetailStoreTable storeTable;
280 # RetailParameters parameters;
281 #
282 # CustTable custTable;
283 #
284 # FormDataSource formDS;
285 # Object callerObject;
286 #
287 # LedgerVoucher ledgerVoucher;
288 # LedgerVoucherObject ledgerVoucherObject;
289 # LedgerVoucherTransObject ledgerVoucherTransObject;
290 #
291 # Map voucherList;
292 #
293 # NumberSeq numberSeq ;
294 #
295 # SysOperationProgress operationProgress;
296 #
297 # RetailStatementId statementId;
298 #
299 # // <GEERU>
300 # boolean countryRegion_W;
301 # boolean countryRegion_RU;
302 # // </GEERU>
303 #
304 # // <GBR>
305 # RetailFiscalReceiptProcessor_BR fiscalReceiptProcessor;
306 # // </GBR>
307 #
308 # #define.CurrentVersion(1)
309 #
310 # #localmacro.CurrentList
311 # statementId
312 # #endmacro
313 #
314 # #define.LessThan('..')
315 # #define.SalesVoucher(0)
316 # #define.PaymentVoucher(1)
317 # #define.MaxTaxDifference(0.005)
318 #}
319 #
320 ENDSOURCE
321 SOURCE #concatTransTxt
322 #/// <summary>
323 #/// Concatenate both the texts passed as the parameter.
324 #/// </summary>
325 #/// <param name="_firstTxt">
326 #/// The first text to which it should concatenated.
327 #/// </param>
328 #/// <param name="_secondTxt">
329 #/// The second text to which it should be concatenated.
330 #/// </param>
331 #/// <returns>
332 #/// The concatenated text.
333 #/// </returns>
334 #private TransTxt concatTransTxt(TransTxt _firstTxt, TransTxt _secondTxt)
335 #{
336 # TransTxt concatTxt = (_firstTxt == '') ? '' : ' - ';
337 #
338 # return _firstTxt + concatTxt + _secondTxt;
339 #}
340 ENDSOURCE
341 SOURCE #concludePost_BR
342 #// <GBR>
343 #protected void concludePost_BR(RetailStatementTable _statementTable)
344 #{
345 # RetailFiscalReceipt_BR fiscalReceipt;
346 # RetailTransactionTable transactionTable;
347 #
348 # this.postDeniedConsumerFiscalDocuments_BR(_statementTable);
349 # this.addSentFiscalDocumentsToBeInquired_BR(_statementTable);
350 #
351 # // Voided fiscal receipts are not processed in the statement
352 # update_recordSet fiscalReceipt
353 # setting IsStatementPosted = NoYes::Yes,
354 # Voucher = ''
355 # where fiscalReceipt.StoreId == _statementTable.storeId
356 # && fiscalReceipt.Status == FiscalDocumentStatus_BR::Cancelled
357 # && fiscalReceipt.IsStatementPosted == NoYes::No
358 # join transactionTable
359 # where transactionTable.Transactionid == fiscalReceipt.Transactionid
360 # && transactionTable.terminal == fiscalReceipt.TerminalId
361 # && transactionTable.store == fiscalReceipt.StoreId
362 # && transactionTable.statementId == "";
363 #}
364 #// </GBR>
365 ENDSOURCE
366 SOURCE #createPaymentLedgerTrans
367 #private void createPaymentLedgerTrans(RetailAccountType _accountType,
368 # LedgerPostingType _ledgerPostingType,
369 # LedgerDimensionDefaultAccount _ledgerAccount,
370 # CurrencyCode _currencyCode,
371 # AmountCur _amountCur,
372 # TableId _tableId,
373 # RecId _recId,
374 # TransDate _transDate,
375 # str _transTxt,
376 # str _documentNumber,
377 # int _voucherType = #PaymentVoucher
378 # )
379 #{
380 # BankAccountTable bankAccountTable;
381 # LedgerTransTxt transTxtType = LedgerTransTxt::LedgerClosing;
382 # BankAccountID bankAccountID;
383 # BankVoucher bankVoucher;
384 # ;
385 #
386 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepStart(0, 'createPaymentLedgerTrans');
387 #
388 # if (_amountCur)
389 # {
390 # this.initVoucher(_transDate, _voucherType);
391 # bankAccountID = DimensionStorage::ledgerDimension2AccountNum(_ledgerAccount);
392 #
393 # switch (_accountType)
394 # {
395 # case RetailLedgerBank::Ledger:
396 # ledgerVoucherTransObject = LedgerVoucherTransObject::newTransactionAmountDefault(ledgerVoucherObject,
397 # _ledgerPostingType,
398 # DimensionDefaultingService::serviceCreateLedgerDimension(_ledgerAccount, statementTable.DefaultDimension),
399 # _currencyCode,
400 # _amountCur,
401 # CurrencyExchangeHelper::newExchangeDate(Ledger::primaryLedger(CompanyInfo::findDataArea(curext()).RecId), ledgerVoucherObject.parmAccountingDate()));
402 # ledgerVoucherTransObject.parmSourceTableId(_tableId);
403 # ledgerVoucherTransObject.parmSourceRecId(_recId);
404 #
405 # if (_ledgerPostingType == LedgerPostingType::SalesCash)
406 # {
407 # transTxtType = LedgerTransTxt::CustCashPayment;
408 # }
409 # else if (_ledgerPostingType == LedgerPostingType::MSTDiff)
410 # {
411 # transTxtType = LedgerTransTxt::LedgerMSTDiff;
412 # }
413 # this.setLVTOTransTxt(ledgerVoucherTransObject, transTxtType, _transTxt);
414 # ledgerVoucher.addTrans(ledgerVoucherTransObject);
415 #
416 # break;
417 # case RetailLedgerBank::Bank:
418 # bankAccountTable = BankAccountTable::find(bankAccountID);
419 # bankVoucher = BankVoucher::construct(_amountCur,
420 # _currencyCode,
421 # bankAccountID,
422 # "",
423 # "",
424 # "",
425 # _transTxt,
426 # LedgerPostingType::Bank,
427 # statementTable.DefaultDimension,
428 # bankAccountTable.LedgerDimension,
429 # "",
430 # Currency::exchRate(_currencyCode, _transDate));
431 # bankVoucher.parmSourceTableId(_tableId);
432 # bankVoucher.parmSourceRecId(_recId);
433 #
434 # bankVoucher.post(ledgerVoucher);
435 #
436 # break;
437 # }
438 # }
439 #
440 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepEnd(0, 'createPaymentLedgerTrans');
441 #}
442 #
443 #
444 ENDSOURCE
445 SOURCE #deleteStatement
446 #/// <summary>
447 #/// Deletes the statement from the <c>RetailStatementTable</c>, <c>RetailStatementLine</c> and <c>RetailCashDecalaration</c>.
448 #/// </summary>
449 #/// <param name="_statementTable">
450 #/// The record os the statement to be deleted
451 #/// </param>
452 #void deleteStatement(RetailStatementTable _statementTable)
453 #{
454 # RetailStatementLine statementLine;
455 # RetailCashDeclaration cashDeclaration;
456 # ;
457 #
458 # _statementTable.reread();
459 #
460 # delete_from statementLine
461 # where statementLine.StatementId == _statementTable.StatementId;
462 #
463 # delete_from cashDeclaration
464 # where cashDeclaration.StatementId == _statementTable.StatementId;
465 #
466 # _statementTable.doDelete();
467 #}
468 #
469 ENDSOURCE
470 SOURCE #getExchRate
471 #/// <summary>
472 #/// Gets the exchange rate for the given currency or for the given store.
473 #/// </summary>
474 #/// <param name="_date">
475 #/// The date for which the exchage rate is claculated
476 #/// </param>
477 #/// <param name="_currency">
478 #/// The currency for which the exchange rate is calculated
479 #/// </param>
480 #/// <param name="_store">
481 #/// The store for which the exchange rate is calculated.
482 #/// </param>
483 #/// <returns>
484 #/// Exchange rateof the currency.
485 #/// </returns>
486 #exchRate getExchRate(date _date, CurrencyCode _currency, RetailStoreId _store)
487 #{
488 # ExchRate exchRate = 0;
489 # ExchangeRate exchRates;
490 # ExchangeRateCurrencyPair currencyPair;
491 # RefRecId exchangeRateType;
492 # RetailSharedParameters retailSharedParameters;
493 # CurrencyCode currencyCode = !_currency ? RetailStoreTable::find(_store).Currency : _currency;
494 # ;
495 #
496 # exchRate = ExchangeRateHelper::getExchangeRate1_Static(
497 # Ledger::primaryLedger(CompanyInfo::findDataArea(curext()).RecId),
498 # currencyCode,
499 # _date);
500 #
501 # retailSharedParameters = retailSharedParameters::find(false);
502 #
503 # exchangeRateType = retailSharedParameters.ExchangeRateType;
504 #
505 # select validtimestate(_date) exchRates
506 # join RecId, FromCurrencyCode, ToCurrencyCode, ExchangeRateType from currencyPair
507 # where exchRates.ExchangeRateCurrencyPair == currencyPair.RecId
508 # && currencyPair.FromCurrencyCode == currencyCode && currencyPair.ToCurrencyCode == _currency
509 # && currencyPair.ExchangeRateType == exchangeRateType;
510 #
511 # if(exchRates != null)
512 # {
513 # exchRate = exchRates.ExchangeRate;
514 # }
515 #
516 # return exchRate;
517 #}
518 #
519 ENDSOURCE
520 SOURCE #getFDocCancelRetailTransaction_BR
521 #/// <summary>
522 #/// Gets the retail transaction that cancels a fiscal document in the same statement
523 #/// </summary>
524 #/// <param name="_statementId">
525 #/// The statement id where the fiscal document is being posted
526 #/// </param>
527 #/// <param name="_accessKey">
528 #/// The access key of the fiscal document to be canceled
529 #/// </param>
530 #/// <returns>
531 #/// The retail transaction record
532 #/// </returns>
533 #private RetailTransactionTable getFDocCancelRetailTransaction_BR(RetailStatementId _statementId, EFDocAccessKey_BR _accessKey)
534 #{
535 # RetailTransactionTable retailTransactionTable;
536 # RetailFiscalDocumentCancel_BR retailFiscalDocumentCancel;
537 #
538 # select retailTransactionTable
539 # exists join retailFiscalDocumentCancel
540 # where retailTransactionTable.transactionId == retailFiscalDocumentCancel.transactionId
541 # && retailTransactionTable.store == retailFiscalDocumentCancel.store
542 # && retailTransactionTable.terminal == retailFiscalDocumentCancel.terminal
543 # && retailTransactionTable.statementId == _statementId
544 # && retailFiscalDocumentCancel.AccessKey == _accessKey;
545 #
546 # return retailTransactionTable;
547 #}
548 ENDSOURCE
549 SOURCE #getFiscalDocPostWithoutCustInvJour_BR
550 #/// <summary>
551 #/// Constructs a class to post a fiscal document without a <c>CustInvoiceJour</c>.
552 #/// </summary>
553 #/// <returns>
554 #/// An instance of <c>RetailFiscalDocumentPost_BR</c>.
555 #/// </returns>
556 #/// <remarks>
557 #/// Passes the <c>CustInvoiceJour</c> buffer as null because we don't want to use any ledger vouchers.
558 #/// </remarks>
559 #// <GBR>
560 #protected RetailFiscalDocumentPost_BR getFiscalDocPostWithoutCustInvJour_BR()
561 #{
562 # return new RetailFiscalDocumentPost_BR(null);
563 #}
564 #// </GBR>
565 ENDSOURCE
566 SOURCE #getFiscalDocumentPost_BR
567 #/// <summary>
568 #/// Constructs a class to post Fiscal documents based on a Fiscal document model 2 record.
569 #/// </summary>
570 #/// <param name="_fiscalDocumentModel2">
571 #/// A record of <c>RetailFiscalDocumentModel2_BR</c>.
572 #/// </param>
573 #/// <param name="_ledgerVoucher">
574 #/// A <c>Voucher</c> that the Fiscal document will be linked to.
575 #/// </param>
576 #/// <returns>
577 #/// An instance of <c>FiscalDocumentPost_BR</c>.
578 #/// </returns>
579 #// <GBR>
580 #public FiscalDocumentPost_BR getFiscalDocumentPost_BR(RetailFiscalDocumentModel2_BR _fiscalDocumentModel2,
581 # Voucher _ledgerVoucher)
582 #{
583 # return new FiscalDocumentPost_BR(
584 # FiscalDocumentParmDataCreator_BR::fromFiscalDocumentModel2(
585 # _fiscalDocumentModel2,
586 # _ledgerVoucher));
587 #}
588 #// </GBR>
589 ENDSOURCE
590 SOURCE #getFiscalReceiptProcessor_BR
591 #/// <summary>
592 #/// Constructs a class to process a fiscal receipt (model 2D) record.
593 #/// </summary>
594 #/// <returns>
595 #/// An instance of <c>RetailFiscalReceiptProcessor_BR</c>.
596 #/// </returns>
597 #// <GBR>
598 #protected RetailFiscalReceiptProcessor_BR getFiscalReceiptProcessor_BR()
599 #{
600 # return fiscalReceiptProcessor;
601 #}
602 #// </GBR>
603 ENDSOURCE
604 SOURCE #getLedgerPostingController_BR
605 #/// <summary>
606 #/// Constructs a ledger posting controller to be used at the Z report posting.
607 #/// </summary>
608 #/// <returns>
609 #/// An instance of <c>LedgerPostingController</c>.
610 #/// </returns>
611 #public LedgerPostingController getLedgerPostingController_BR()
612 #{
613 # return LedgerPostingController::newForLedgerPostingJournal(ledgerVoucher);
614 #}
615 ENDSOURCE
616 SOURCE #getOriginalFDocRetailTransaction_BR
617 #/// <summary>
618 #/// Gets the retail transaction that returns a fiscal document in the same statement
619 #/// </summary>
620 #/// <param name="_statementId">
621 #/// The statement id where the fiscal document is being posted
622 #/// </param>
623 #/// <param name="_accessKey">
624 #/// The access key of the fiscal document to be returned
625 #/// </param>
626 #/// <returns>
627 #/// The retail transaction record
628 #/// </returns>
629 #private RetailTransactionTable getOriginalFDocRetailTransaction_BR(RetailStatementId _statementId, EFDocAccessKey_BR _accessKey)
630 #{
631 # RetailTransactionTable retailTransactionTable;
632 # RetailFiscalDocument_BR retailFiscalDocument;
633 #
634 # select retailTransactionTable
635 # exists join retailFiscalDocument
636 # where retailTransactionTable.transactionId == retailFiscalDocument.transactionId
637 # && retailTransactionTable.store == retailFiscalDocument.store
638 # && retailTransactionTable.terminal == retailFiscalDocument.terminal
639 # && retailTransactionTable.statementId == _statementId
640 # && retailFiscalDocument.AccessKey == _accessKey;
641 #
642 # return retailTransactionTable;
643 #}
644 ENDSOURCE
645 SOURCE #getRetailFiscalDocumentPost_BR
646 #/// <summary>
647 #/// Constructs a class to post a fiscal document based on a consumer retail fiscal document (model 65) record.
648 #/// </summary>
649 #/// <param name="_custInvoiceJour">
650 #/// The <c>CustInvoiceJour</c> record generated by the Retail statement.
651 #/// </param>
652 #/// <returns>
653 #/// An instance of <c>RetailFiscalDocumentPost_BR</c>.
654 #/// </returns>
655 #// <GBR>
656 #protected RetailFiscalDocumentPost_BR getRetailFiscalDocumentPost_BR(CustInvoiceJour _custInvoiceJour)
657 #{
658 # return new RetailFiscalDocumentPost_BR(_custInvoiceJour);
659 #}
660 #// </GBR>
661 ENDSOURCE
662 SOURCE #getRetailZReportValidation_BR
663 #/// <summary>
664 #/// Constructs a class to validate a Z report.
665 #/// </summary>
666 #/// <param name="_retailZReport">
667 #/// A record of <c>RetailZReport_BR</c>.
668 #/// </param>
669 #/// <returns>
670 #/// An instance of <c>RetailZReportValidation_BR</c>.
671 #/// </returns>
672 #// <GBR>
673 #protected RetailZReportValidation_BR getRetailZReportValidation_BR(RetailZReport_BR _retailZReport)
674 #{
675 # return new RetailZReportValidation_BR(_retailZReport);
676 #}
677 #// </GBR>
678 ENDSOURCE
679 SOURCE #getTaxRetailZReport_BR
680 #/// <summary>
681 #/// Constructs a tax class to handle the ledger post of a Z report.
682 #/// </summary>
683 #/// <param name="_retailZReport">
684 #/// A record of <c>RetailZReport_BR</c>.
685 #/// </param>
686 #/// <returns>
687 #/// An instance of <c>TaxRetailZReport_BR</c>.
688 #/// </returns>
689 #// <GBR>
690 #protected TaxRetailZReport_BR getTaxRetailZReport_BR(RetailZReport_BR _retailZReport)
691 #{
692 # return new TaxRetailZReport_BR(_retailZReport);
693 #}
694 #// </GBR>
695 ENDSOURCE
696 SOURCE #getTransactionText_BR
697 #/// <summary>
698 #/// Retrieves the transaction text to be used at the Z report posting.
699 #/// </summary>
700 #/// <param name="_retailZReport">
701 #/// The given Z report.
702 #/// </param>
703 #/// <returns>
704 #/// The transaction text.
705 #/// </returns>
706 #protected TransTxt getTransactionText_BR(RetailZReport_BR _retailZReport)
707 #{
708 # return strFmt("@SYP4930014",
709 # _retailZReport.ZReportNumber,
710 # _retailZReport.FiscalPrinterSerialNumber,
711 # _retailZReport.StoreId);
712 #}
713 ENDSOURCE
714 SOURCE #initFromArgs
715 #/// <summary>
716 #/// Initialize <c>RetailStatementTable</c> with the caller record.
717 #/// </summary>
718 #/// <param name="_args">
719 #/// Details of the caller datasource.
720 #/// </param>
721 #/// <remarks>
722 #/// Calls the <c>StatementTable</c> method to initialize the table.
723 #/// </remarks>
724 #/// <exception cref="Exception::Error">
725 #/// The caller dataset is not <c>RetailStatementTable</c> table.
726 #/// </exception>
727 #/// <exception cref="Exception::Error">
728 #/// Must be called with parameter.
729 #/// </exception>
730 #void initFromArgs(Args _args)
731 #{
732 # TableId argsDataset;
733 #
734 # if (_args)
735 # {
736 # argsDataset = _args.dataset();
737 # if (argsDataset != 0)
738 # {
739 # switch (argsDataset)
740 # {
741 # case tablenum(RetailStatementTable) : statementTable = _args.record();
742 # formDS = statementTable.dataSource();
743 # callerObject = _args.caller();
744 # break;
745 # default : throw error("@RET4156");
746 # }
747 # }
748 # }
749 # else
750 # {
751 # throw error("@RET4156");
752 # }
753 #}
754 ENDSOURCE
755 SOURCE #initVoucher
756 #/// <summary>
757 #/// Generate the voucher from the voucher series based on the last voucher.
758 #/// </summary>
759 #/// <param name="_transDate">
760 #/// The posting date of the statement.
761 #/// </param>
762 #/// <param name="_ledgerVoucherTag">
763 #/// The current value of voucher.
764 #/// </param>
765 #/// <exception cref="Exception::Error">
766 #/// Statement voucher number sequence is not specified.
767 #/// </exception>
768 #void initVoucher(TransDate _transDate = statementTable.postingDate, int _ledgerVoucherTag = #SalesVoucher)
769 #{
770 # NumberSequenceTable numberSequence;
771 # Voucher voucher;
772 # RefRecId voucherNumSeqId;
773 #
774 # if (voucherList.exists([_transDate, _ledgerVoucherTag]))
775 # {
776 # voucher = voucherList.lookup([_transDate, _ledgerVoucherTag]);
777 # }
778 #
779 # if (!ledgerVoucher || (voucher != ledgerVoucher.lastVoucher()))
780 # {
781 # storeTable = RetailStoreTable::find(statementTable.StoreId);
782 # voucherNumSeqId = RetailStatementVoucher::numberSequenceId(statementTable.storeId);
783 #
784 # if (voucherNumSeqId == 0)
785 # {
786 # throw error(strfmt("@RET4157", storeTable.StoreNumber));
787 # }
788 #
789 # numberSequence = NumberSequenceTable::find(voucherNumSeqId);
790 # if (!ledgerVoucher)
791 # {
792 # ledgerVoucher = LedgerVoucher::newLedgerPost(RetailParameters::find().DetailSummary, SysModule::Retail, numberSequence.NumberSequence);
793 # }
794 #
795 # if (!voucher)
796 # {
797 # voucher = NumberSeq::newGetNumFromId(voucherNumSeqId).num();
798 #
799 # ledgerVoucherObject = LedgerVoucherObject::newVoucher(voucher, _transDate, SysModule::Retail, LedgerTransType::Sales, NoYes::No);
800 # ledgerVoucher.addVoucher(ledgerVoucherObject);
801 #
802 # voucherList.insert([_transDate, _ledgerVoucherTag], voucher);
803 # }
804 #
805 # ledgerVoucherObject = ledgerVoucher.findLedgerVoucherObject(voucher, _transDate);
806 #
807 # ledgerVoucher.lastTransDate(ledgerVoucherObject.parmTransDate());
808 # ledgerVoucher.lastVoucher(ledgerVoucherObject.parmVoucher());
809 # }
810 #}
811 #
812 ENDSOURCE
813 SOURCE #insertStatementJour
814 #/// <summary>
815 #/// Inserts the record in the <c>RetailStatementJour</c> and <c>RetailStatementTrans</c> after the posting of statement.
816 #/// </summary>
817 #/// <param name="_statementTable">
818 #/// The current instance of Statement table.
819 #/// </param>
820 #/// <remarks>
821 #/// Finds the voucher value after posting and inserts to the <c>RetailStatementVoucher</c> table.
822 #/// </remarks>
823 #void insertStatementJour(RetailStatementTable _statementTable)
824 #{
825 # RetailStatementJour statementJour;
826 # RetailStatementTrans statementTrans;
827 #
828 # MapIterator voucherIterator;
829 # TransDate transDate;
830 # int ledgerVoucherTag;
831 # Voucher voucher;
832 # RetailStatementVoucher statementVoucher;
833 #
834 # RetailStatementLine statementLine;
835 # LedgerVoucherObject lvObj;
836 # ;
837 #
838 # statementJour = RetailStatementJour::find(_statementTable.StatementId, true);
839 #
840 # statementJour.initFromStatementTable(_statementTable);
841 #
842 # statementJour.NumberOfItemsBarcodesNotOnFile = _statementTable.itemsOrBarcodeNotOnFile();
843 # statementJour.NumberOfWrongShiftTransactions = _statementTable.transactionOnWrongShift();
844 # statementJour.SalesAmount = _statementTable.salesAmount();
845 # statementJour.TaxAmount = _statementTable.taxAmount();
846 # statementJour.TotalDiscAmount = _statementTable.totalDiscount();
847 # statementJour.LineDiscAmount = _statementTable.lineDiscount();
848 # statementJour.IncomeAmount = _statementTable.income();
849 # statementJour.ExpensesAmount = _statementTable.expenses();
850 # statementJour.NumberOfBlockedItems = _statementTable.numberOfBlockedItems();
851 # statementJour.NumberOfBlockedCustomers = _statementTable.numberOfBlockedCustomers();
852 # statementJour.NumberOfSalesPaymentDifferenceTrans = _statementTable.transactionsWithSaleOrPaymentDifference();
853 # statementJour.DefaultDimension = _statementTable.DefaultDimension;
854 # statementJour.PostedDate = systemdateget();
855 # statementJour.PostedTime = timenow();
856 #
857 # // <GEERU>
858 # if (countryRegion_RU)
859 # {
860 # statementJour.LoyaltyDiscAmount_RU = _statementTable.loyaltyDiscount_RU();
861 # }
862 # // </GEERU>
863 #
864 # if (statementJour)
865 # {
866 # statementJour.update();
867 # }
868 # else
869 # {
870 # statementJour.insert();
871 # }
872 #
873 # RetailTracer::Info('Posting', 'RetailStatementPost::insertStatementJour()',
874 # 'Displaying field values of statement header. Statement Id = %1, StatementDate = %2, StoreId = %3, ClosingMethod = %4, NumberOfItemsBarcodesNotOnFile = %5, NumberOfWrongShiftTransactions = %6, SalesAmount = %7, TaxAmount = %8,TotalDiscAmount = %9',
875 # statementJour.statementId, statementJour.statementDate, statementJour.storeId, statementJour.closingMethod, statementJour.numberOfItemsBarcodesNotOnFile, statementJour.numberOfWrongShiftTransactions, statementJour.salesAmount, statementJour.taxAmount, statementJour.totalDiscAmount);
876 # RetailTracer::Info('Posting', 'RetailStatementPost::insertStatementJour()',
877 # '--> Part 2: LineDiscAmount = %1, IncomeAmount = %2,ExpensesAmount = %3,NumberOfBlockedItems = %4, NumberOfSalesPaymentDifferenceTrans= %5, DefaultDimension= %6',
878 # statementJour.lineDiscAmount, statementJour.incomeAmount, statementJour.expensesAmount, statementJour.numberOfBlockedItems, statementJour.numberOfSalesPaymentDifferenceTrans, statementJour.DefaultDimension);
879 #
880 # while select statementLine
881 # where statementLine.StatementId == _statementTable.StatementId
882 # {
883 # statementTrans = RetailStatementTrans::find(statementLine.StatementId, statementLine.LineNum, true);
884 # statementTrans.initFromStatementLine(statementLine);
885 #
886 # statementTrans.insert();
887 # }
888 #
889 # RetailTracer::Info('Posting', 'RetailStatementPost::insertStatementJour()',
890 # 'Displaying field values of statement trans. Statement Id = %1, LineNum = %2, StatementCode = %3, StaffId = %4, TerminalId = %5, CardTypeId = %6, Currency = %7, CountedAmount = %8, CountedAmountMST = %9, TenderTypeId = %10',
891 # statementTrans.statementId, statementTrans.lineNum, statementTrans.statementCode, statementTrans.staffId, statementTrans.terminalId, statementTrans.cardTypeId, statementTrans.currency, statementTrans.countedAmountMST, statementTrans.tenderTypeId);
892 # RetailTracer::Info('Posting', 'RetailStatementPost::insertStatementJour()',
893 # ' ---> PART 2: TransAmount = %11, DifferenceAmount = %13,DifferenceAmountMST = %14, OrderInvoiceAmount= %15, TransAmountStore = %16, BankedAmountStore = %17, CountedAmountStore = %18, DifferenceAmountStore=%19, SafeAmount= %20',
894 # statementTrans.transAmount, statementTrans.differenceAmount, statementTrans.differenceAmountMST, statementTrans.orderInvoiceAmount, statementTrans.transAmountStore, statementTrans.bankedAmountStore, statementTrans.countedAmountStore, statementTrans.differenceAmountStore, statementTrans.safeAmount);
895 # RetailTracer::Info('Posting', 'RetailStatementPost::insertStatementJour()',
896 # '---> PART 3: CardFeeAmount = %21',
897 # statementTrans.cardFeeAmount);
898 #
899 # voucherIterator = new MapIterator(voucherList);
900 #
901 # while (voucherIterator.more())
902 # {
903 # [transDate, ledgerVoucherTag] = voucherIterator.key();
904 # voucher = voucherIterator.value();
905 #
906 # lvObj = ledgerVoucher.findLedgerVoucherObject(voucher);
907 # if (lvObj && lvObj.transElements())
908 # {
909 # statementVoucher.statementId = _statementTable.statementId;
910 # statementVoucher.voucher = voucher;
911 # statementVoucher.voucherDate = transDate;
912 #
913 # statementVoucher.insert();
914 # }
915 #
916 # voucherIterator.next();
917 # }
918 #
919 # RetailTracer::Info('Posting', 'RetailStatementPost::insertStatementJour()',
920 # 'Displaying field values of statement voucher. Statement Id = %1, Voucher = %2, VoucherDate = %3',
921 # statementVoucher.statementId, statementVoucher.voucher, statementVoucher.voucherDate);
922 #}
923 ENDSOURCE
924 SOURCE #linkSalesOrderVouchersToStatement
925 #/// <summary>
926 #/// Inserts the record in the <c>RetailStatementVoucher</c> for the posted sales order with the statment ID passed.
927 #/// </summary>
928 #/// <remarks>
929 #/// Links the tables <c>RetailStatementVoucher</c> table and <c>CustInvoiceJour</c> table through Statement ID.
930 #/// </remarks>
931 #void linkSalesOrderVouchersToStatement()
932 #{
933 # RetailStatementVoucher statementVoucher;
934 # CustInvoiceJour custInvoiceJour;
935 # RetailTransactionTable rboHeaders;
936 # RetailStatementId currentStatementId;
937 # RetailCustInvoiceJourTable retailCustInvoiceJour;
938 # ;
939 #
940 # currentStatementId = statementTable.statementId;
941 #
942 # insert_recordset statementVoucher(statementId, voucher, voucherDate)
943 # select currentStatementId, ledgerVoucher, invoiceDate
944 # from custInvoiceJour
945 # exists join rboHeaders
946 # where custInvoiceJour.InvoiceId == rboHeaders.invoiceId
947 # && rboHeaders.statementId == currentStatementId
948 # && rboHeaders.invoiceId
949 # exists join retailCustInvoiceJour
950 # where custInvoiceJour.RecId == retailCustInvoiceJour.CustInvoiceJour
951 # && retailCustInvoiceJour.RetailStatementId == currentStatementId;
952 #}
953 ENDSOURCE
954 SOURCE #markTransactions
955 #/// <summary>
956 #/// Updates the status as 'Posted' in all the posting tables after the Retail statement posting.
957 #/// </summary>
958 #/// <param name="_statementTable">
959 #/// The current instance of <c>RetailStatementTable</c> table.
960 #/// </param>
961 #void markTransactions(RetailStatementTable _statementTable)
962 #{
963 # RetailTransactionTable transactionTable;
964 # RetailTransactionSalesTrans transactionSalesTrans;
965 # RetailTransactionPaymentTrans transactionPaymentTrans;
966 # RetailTransactionIncomeExpenseTrans transactionIncomeExpenseTrans;
967 #
968 # RetailTransactionBankedTenderTrans transactionBankedTenderTrans;
969 #
970 # RetailTransactionSafeTenderTrans transactionSafeTenderTrans;
971 #
972 # int numberOfTransactions;
973 # int numberOfSalesTrans;
974 # int numberOfPaymentTrans;
975 # int numberOfSafeTenderTrans;
976 #
977 # int numberOfBankedTenderTrans;
978 # RetailTransactionOrderInvoiceTrans transactionOrderInvoiceTrans;
979 #
980 # ;
981 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepStart(0, 'markTransactions');
982 #
983 # /*
984 # * Update sales transactions.
985 # */
986 # update_recordset transactionSalesTrans
987 # setting
988 # InventStatusSales = RetailInventStatusSales::Posted,
989 # TransactionStatus = RetailEntryStatus::Posted
990 # join transactionTable
991 # where
992 # transactionSalesTrans.statementId == _statementTable.statementId &&
993 # transactionTable.statementId == _statementTable.statementId &&
994 # transactionTable.type != RetailTransactionType::PhysicalInventory &&
995 # transactionTable.Store == transactionSalesTrans.Store &&
996 # transactionTable.Terminal == transactionSalesTrans.TerminalId &&
997 # transactionTable.TransactionId == transactionSalesTrans.TransactionId &&
998 # transactionSalesTrans.TransactionStatus == RetailEntryStatus::None;
999 #
1000 # numberOfSalesTrans = any2int(transactionSalesTrans.rowCount());
1001 #
1002 # /*
1003 # * Update payment transactions table.
1004 # */
1005 # update_recordset transactionPaymentTrans
1006 # setting
1007 # TransactionStatus = RetailEntryStatus::Posted
1008 # join transactionTable
1009 # where
1010 # transactionTable.statementId == _statementTable.statementId &&
1011 # transactionTable.type != RetailTransactionType::PhysicalInventory &&
1012 # transactionTable.Store == transactionPaymentTrans.Store &&
1013 # transactionTable.Terminal == transactionPaymentTrans.terminal &&
1014 # transactionTable.TransactionId == transactionPaymentTrans.TransactionId &&
1015 # transactionPaymentTrans.TransactionStatus == RetailEntryStatus::None;
1016 #
1017 # numberOfPaymentTrans = any2int(transactionPaymentTrans.rowCount());
1018 #
1019 # /*
1020 # * Update banked tender transactions.
1021 # */
1022 # update_recordset transactionBankedTenderTrans
1023 # setting
1024 # TransactionStatus = RetailEntryStatus::Posted
1025 # join transactionTable
1026 # where
1027 # transactionTable.statementId == _statementTable.statementId &&
1028 # transactionTable.type != RetailTransactionType::PhysicalInventory &&
1029 # transactionTable.Store == transactionBankedTenderTrans.Store &&
1030 # transactionTable.Terminal == transactionBankedTenderTrans.Terminal &&
1031 # transactionTable.TransactionId == transactionBankedTenderTrans.TransactionId &&
1032 # transactionBankedTenderTrans.TransactionStatus == RetailEntryStatus::None;
1033 #
1034 # numberOfBankedTenderTrans = any2int(transactionBankedTenderTrans.rowCount());
1035 #
1036 # /*
1037 # * Update safe tender transactions.
1038 # */
1039 # update_recordset transactionSafeTenderTrans
1040 # setting
1041 # TransactionStatus = RetailEntryStatus::Posted
1042 # join transactionTable
1043 # where
1044 # transactionTable.statementId == _statementTable.statementId &&
1045 # transactionTable.type != RetailTransactionType::PhysicalInventory &&
1046 # transactionTable.Store == transactionSafeTenderTrans.Store &&
1047 # transactionTable.Terminal == transactionSafeTenderTrans.Terminal &&
1048 # transactionTable.TransactionId == transactionSafeTenderTrans.TransactionId &&
1049 # transactionSafeTenderTrans.TransactionStatus == RetailEntryStatus::None;
1050 #
1051 # numberOfSafeTenderTrans = any2int(transactionSafeTenderTrans.rowCount());
1052 #
1053 # /*
1054 # * Update income expense transactions.
1055 # */
1056 # update_recordset transactionIncomeExpenseTrans
1057 # setting
1058 # TransactionStatus = RetailEntryStatus::Posted
1059 # join transactionTable
1060 # where
1061 # transactionTable.statementId == _statementTable.statementId &&
1062 # transactionTable.type != RetailTransactionType::PhysicalInventory &&
1063 # transactionTable.Store == transactionIncomeExpenseTrans.Store &&
1064 # transactionTable.Terminal == transactionIncomeExpenseTrans.terminal &&
1065 # transactionTable.TransactionId == transactionIncomeExpenseTrans.TransactionId &&
1066 # transactionIncomeExpenseTrans.TransactionStatus == RetailEntryStatus::None;
1067 #
1068 # /*
1069 # * Update transaction order invoice table.
1070 # */
1071 # update_recordset transactionOrderInvoiceTrans
1072 # setting
1073 # TransactionStatus = RetailEntryStatus::Posted
1074 # join transactionTable
1075 # where
1076 # transactionTable.statementId == _statementTable.statementId &&
1077 # transactionTable.type != RetailTransactionType::PhysicalInventory &&
1078 # transactionTable.Store == transactionOrderInvoiceTrans.storeId &&
1079 # transactionTable.Terminal == transactionOrderInvoiceTrans.TerminalId &&
1080 # transactionTable.TransactionId == transactionOrderInvoiceTrans.TransactionId &&
1081 # transactionOrderInvoiceTrans.TransactionStatus == RetailEntryStatus::None;
1082 #
1083 # /*
1084 # * Lastly, update the transaction table.
1085 # */
1086 # update_recordset transactionTable
1087 # setting
1088 # EntryStatus = RetailEntryStatus::Posted
1089 # where
1090 # transactionTable.StatementId == _statementTable.StatementId
1091 # && transactionTable.Type != RetailTransactionType::PhysicalInventory;
1092 #
1093 # numberOfTransactions = any2int(transactionTable.rowCount());
1094 #
1095 # /*
1096 # * Cycle through manually entered RetailTransactionBankedTenderTrans.
1097 # * These transactions do not have a transaction header and are deleted if the statement is cleared.
1098 # */
1099 # update_recordSet transactionBankedTenderTrans
1100 # setting
1101 # TransactionStatus = RetailEntryStatus::Posted
1102 # where
1103 # transactionBankedTenderTrans.StatementId == statementTable.StatementId &&
1104 # transactionBankedTenderTrans.TransactionStatus == RetailEntryStatus::None &&
1105 # transactionBankedTenderTrans.StatusType == RetailBankedStatusTypeBase::Manual;
1106 # numberOfBankedTenderTrans = any2int(transactionBankedTenderTrans.rowCount());
1107 #
1108 #
1109 # /*
1110 # * Cycle through manually entered RetailTransactionSafeTenderTrans.
1111 # * These transactions do not have a transaction header and are deleted if the statement is cleared.
1112 # */
1113 # update_recordSet transactionSafeTenderTrans
1114 # setting
1115 # TransactionStatus = RetailEntryStatus::Posted
1116 # where
1117 # transactionSafeTenderTrans.StatementId == statementTable.StatementId &&
1118 # transactionSafeTenderTrans.TransactionStatus == RetailEntryStatus::None &&
1119 # transactionSafeTenderTrans.StatusType == RetailSafeStatusTypeBase::Manual;
1120 # numberOfSafeTenderTrans = any2int(transactionSafeTenderTrans.rowCount());
1121 #
1122 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepEnd(0, 'markTransactions');
1123 #}
1124 #
1125 ENDSOURCE
1126 SOURCE #new
1127 #void new()
1128 #{
1129 # super();
1130 #
1131 # // <GEERU>
1132 # #EECountryRegionCodes
1133 # #ISOCountryRegionCodes
1134 #
1135 # countryRegion_W = SysCountryRegionCode::isLegalEntityInCountryRegion(#easternEuropeAllandRU);
1136 # countryRegion_RU = SysCountryRegionCode::isLegalEntityInCountryRegion([#isoRU]);
1137 # // <GEERU>
1138 #
1139 # // <GBR>
1140 # if (BrazilParameters::isEnabled())
1141 # {
1142 # fiscalReceiptProcessor = new RetailFiscalReceiptProcessor_BR();
1143 # }
1144 # // </GBR>
1145 #
1146 # voucherList = new Map(Types::Container,Types::String);
1147 #}
1148 ENDSOURCE
1149 SOURCE #pack
1150 #public container pack()
1151 #{
1152 # return [#CurrentVersion, #CurrentList];
1153 #}
1154 ENDSOURCE
1155 SOURCE #parmStatementId
1156 #public RetailStatementId parmStatementId(RetailStatementId _statementId = statementId)
1157 #{
1158 # ;
1159 #
1160 # statementId = _statementId;
1161 #
1162 # return statementId;
1163 #}
1164 ENDSOURCE
1165 SOURCE #postAggregatedDiscounts
1166 #/// <summary>
1167 #/// Post aggregated discounts.
1168 #/// </summary>
1169 #/// <remarks>
1170 #/// calls the method <c>PostDiscounts</c> to post the discounted amount for each record of <c>RetailTransactionSalesTrans</c> table.
1171 #/// </remarks>
1172 #void postAggregatedDiscounts()
1173 #{
1174 # void postAggregatedDiscountsPriv(boolean _forSales)
1175 # {
1176 #
1177 # QueryRun aggregateQueryRun;
1178 # Query aggregateQuery;
1179 # RetailTransactionSalesTrans transactionSalesTrans;
1180 # RetailTransactionDiscountTrans transactionDiscountTrans;
1181 # str documentNumber;
1182 #
1183 # aggregateQueryRun = new QueryRun(querystr(RetailAggregatedSalesForDiscounts));
1184 # aggregateQuery = aggregateQueryRun.query();
1185 #
1186 # // Filter for current statement
1187 # aggregateQuery.dataSourceTable(tablenum(RetailTransactionSalesTrans)).addRange(fieldnum(RetailTransactionSalesTrans, StatementId)).value(statementTable.StatementId);
1188 #
1189 # // Filter for periodic discount
1190 # aggregateQuery.dataSourceTable(tableNum(RetailTransactionDiscountTrans)).addRange(fieldNum(RetailTransactionDiscountTrans, DiscountOriginType)).value(queryValue(RetailDiscountOriginType::Periodic));
1191 # if ( _forSales)
1192 # {
1193 # aggregateQuery.dataSourceTable(tablenum(RetailTransactionSalesTrans)).addRange(fieldnum(RetailTransactionSalesTrans, qty)).value(#LessThan + queryValue(0));
1194 # }
1195 # else
1196 # {
1197 # aggregateQuery.dataSourceTable(tablenum(RetailTransactionSalesTrans)).addRange(fieldnum(RetailTransactionSalesTrans, qty)).value(queryValue(0) + #LessThan);
1198 # }
1199 #
1200 # // Run through the aggregated sales posting vouchers.
1201 # while (aggregateQueryRun.next())
1202 # {
1203 # transactionSalesTrans = aggregateQueryRun.get(tablenum(RetailTransactionSalesTrans));
1204 # transactionDiscountTrans = aggregateQueryRun.get(tablenum(RetailTransactionDiscountTrans));
1205 # documentNumber = statementTable.StatementId;
1206 #
1207 # RetailTracer::Info('Posting', 'RetailStatementPost::postAggregatedDiscounts()',
1208 # 'Displaying field values of RetailTransactionSalesTrans. ItemId = %1, Store = %2, Terminal = %3, taxGroup = %4, TaxItemGroup = %5, DefaultDimension = %6, TransactionId = %7',
1209 # transactionSalesTrans.itemId, transactionSalesTrans.store, transactionSalesTrans.terminalId, transactionSalesTrans.taxGroup, transactionSalesTrans.TaxItemGroup, transactionSalesTrans.DefaultDimension, transactionSalesTrans.transactionId);
1210 #
1211 # RetailTracer::Info('Posting', 'RetailStatementPost::postAggregatedDiscounts()',
1212 # 'Displaying field values of RetailTransactionDiscountTrans. PeriodicDiscountOfferId = %1, DiscountCost = %2, TransactionId = %3',
1213 # transactionDiscountTrans.PeriodicDiscountOfferId, transactionDiscountTrans.DiscountCost, transactionDiscountTrans.TransactionId);
1214 #
1215 # this.postDiscounts(documentNumber, transactionSalesTrans, transactionDiscountTrans, transactionSalesTrans.Currency, transactionSalesTrans.CustAccount);
1216 # }
1217 # }
1218 #
1219 # ;
1220 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepStart(0, 'postAggregatedDiscounts');
1221 #
1222 # postAggregatedDiscountsPriv(true);
1223 # postAggregatedDiscountsPriv(false);
1224 #
1225 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepEnd(0, 'postAggregatedDiscounts');
1226 #}
1227 ENDSOURCE
1228 SOURCE #postBankDropLine_RU
1229 #// <GEERU>
1230 #private void postBankDropLine_RU(RetailTransactionTable _transactionTable,
1231 # RetailStatementPaymentJournal _statementJournal)
1232 #{
1233 # RetailTransactionBankedTenderTrans transactionBankedTenderTrans;
1234 # RetailStoreTenderTypeTable storeTenderTypeTable;
1235 # LedgerDimensionAccount ledgerAccount, offsetLedgerAccount;
1236 # DimensionDefault defaultDimension;
1237 #
1238 # while select sum(AmountCur), Currency, businessDate, TenderType from transactionBankedTenderTrans
1239 # group by TenderType, Currency, businessDate
1240 # where transactionBankedTenderTrans.Store == _transactionTable.store
1241 # && transactionBankedTenderTrans.Terminal == _transactionTable.terminal
1242 # && transactionBankedTenderTrans.TransactionId == _transactionTable.transactionId
1243 # && transactionBankedTenderTrans.TransactionStatus == RetailEntryStatus::None
1244 # {
1245 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(storeTable.StoreNumber).RecId, transactionBankedTenderTrans.TenderType);
1246 # defaultDimension = DimensionDefaultingService::serviceMergeDefaultDimensions(statementTable.DefaultDimension, storeTenderTypeTable.DefaultDimension);
1247 #
1248 # ledgerAccount = storeTenderTypeTable.LedgerDimension;
1249 # offsetLedgerAccount = storeTenderTypeTable.BankBagLedgerDimension;
1250 #
1251 # if (ledgerAccount == offsetLedgerAccount || !storeTenderTypeTable.ActiveAccount)
1252 # continue;
1253 #
1254 # if (storeTenderTypeTable.accountType == RetailLedgerBank::Ledger)
1255 # {
1256 # ledgerAccount = DimensionDefaultingService::serviceCreateLedgerDimension(ledgerAccount, defaultDimension);
1257 # }
1258 #
1259 # if (storeTenderTypeTable.BankBagAccountType == RetailLedgerBank::Ledger)
1260 # {
1261 # offsetLedgerAccount = DimensionDefaultingService::serviceCreateLedgerDimension(storeTenderTypeTable.BankBagLedgerDimension, defaultDimension);
1262 # }
1263 #
1264 # _statementJournal.createPaymentLedgerTrans(
1265 # storeTenderTypeTable.accountType,
1266 # ledgerAccount,
1267 # storeTenderTypeTable.BankBagAccountType,
1268 # offsetLedgerAccount,
1269 # transactionBankedTenderTrans.Currency ? transactionBankedTenderTrans.Currency : storeTable.Currency,
1270 # transactionBankedTenderTrans.AmountCur,
1271 # transactionBankedTenderTrans.businessDate,
1272 # "@RET3607" + " - " + "@RET4514" + storeTenderTypeTable.tenderTypeId,
1273 # statementTable.StatementId,
1274 # transactionBankedTenderTrans.TenderType,
1275 # defaultDimension);
1276 # }
1277 #}
1278 #// </GEERU>
1279 ENDSOURCE
1280 SOURCE #postBrazilSpecific_BR
1281 #/// <summary>
1282 #/// Posts all Brazilian specific data
1283 #/// </summary>
1284 #/// <param name="_transactionTable">
1285 #/// The <c>RetailTransactionTable</c> currently being posted.
1286 #/// </param>
1287 #/// <remarks>
1288 #/// Each retail transaction may have multiple Retail Brazilian records associated to.
1289 #/// </remarks>
1290 #/// <exception cref="Exception::Error">
1291 #/// Thrown if no Brazilan records are found associated to the Retail transaction.
1292 #/// </exception>
1293 #// <GBR>
1294 #protected void postBrazilSpecific_BR(RetailTransactionTable _transactionTable)
1295 #{
1296 # if (_transactionTable.type == RetailTransactionType::Sales)
1297 # {
1298 # switch (_transactionTable.SubType)
1299 # {
1300 # case RetailTransactionSubType::None:
1301 # this.postTransactionBackCompatibility(_transactionTable);
1302 # break;
1303 #
1304 # case RetailTransactionSubType::FiscalDocumentModel2:
1305 # this.postFiscalDocumentModel2_BR(_transactionTable);
1306 # break;
1307 #
1308 # case RetailTransactionSubType::FiscalReceipt:
1309 # this.postFiscalReceipt_BR(_transactionTable);
1310 # break;
1311 #
1312 # case RetailTransactionSubType::FiscalReceiptCancelling:
1313 # this.postFiscalReceiptVoided_BR(_transactionTable);
1314 # break;
1315 #
1316 # case RetailTransactionSubType::EFDocument:
1317 # Error('NF-e posting not implemented.');
1318 # break;
1319 #
1320 # case RetailTransactionSubType::EFDocumentCancelling:
1321 # Error('NF-e cancelling not implemented.');
1322 # break;
1323 #
1324 # case RetailTransactionSubType::ReturnEFDocument:
1325 # this.postRetailReturnFiscalDocument_BR(_transactionTable);
1326 # break;
1327 #
1328 # case RetailTransactionSubType::ConsumerEFDocument:
1329 # case RetailTransactionSubType::ElectronicFiscalReceipt:
1330 # this.postRetailFiscalDocument_BR(_transactionTable);
1331 # break;
1332 #
1333 # case RetailTransactionSubType::ElectronicFiscalReceiptCancelling:
1334 # case RetailTransactionSubType::ConsumerEFDocumentCancelling:
1335 # this.postRetailFiscalDocumentCanceled_BR(_transactionTable);
1336 # break;
1337 # }
1338 # }
1339 # else if (_transactionTable.type == RetailTransactionType::PrintZ)
1340 # {
1341 # this.postZReport_BR(_transactionTable);
1342 # }
1343 # else if (_transactionTable.type == RetailTransactionType::NoSalesFiscalDocument)
1344 # {
1345 # if (_transactionTable.saleIsReturnSale == NoYes::Yes)
1346 # {
1347 # this.postLinkedFiscalDocumentCanceled_BR(_transactionTable);
1348 # }
1349 # else
1350 # {
1351 # this.postLinkedFiscalDocument_BR(_transactionTable);
1352 # }
1353 # }
1354 #}
1355 #// </GBR>
1356 ENDSOURCE
1357 SOURCE #postCrossCompanyGiftcard
1358 #private void postCrossCompanyGiftcard()
1359 #{
1360 # RetailTransactionSalesTrans giftcardSalesTrans;
1361 # RetailTransactionPaymentTrans giftcardPaymentTrans;
1362 # LedgerJournalName journalName;
1363 # NumberSeq journalNumSeq;
1364 # AxLedgerJournalTable ledgerJournal;
1365 # LedgerJournalTrans ledgerJournalTrans;
1366 # RetailStoreTenderTypeTable storeTenderTypeTable;
1367 # DataAreaId giftcardCompany;
1368 #
1369 # void createPaymentLedgerTrans(
1370 # LedgerDimensionAccount _accountNum,
1371 # LedgerDimensionAccount _offsetAccountNum,
1372 # CurrencyCode _currency,
1373 # AmountCur _Amount,
1374 # TransDate _date)
1375 # {
1376 # AxLedgerJournalTrans ledgerJournalLine;
1377 #
1378 # if (!_Amount)
1379 # {
1380 # return;
1381 # }
1382 #
1383 # if (!_accountNum || !_offsetAccountNum)
1384 # {
1385 # // Account number or offset account number is not correctly set up, intercompany gift card posting can't proceed.
1386 # throw error("@REX4040024");
1387 # }
1388 #
1389 # ttsBegin;
1390 #
1391 # ledgerJournalLine = new AxLedgerJournalTrans();
1392 #
1393 # ledgerJournalLine.parmJournalNum(ledgerJournal.parmJournalNum());
1394 # ledgerJournalLine.parmAccountType(LedgerJournalACType::Ledger);
1395 # ledgerJournalLine.parmCompany(curext());
1396 # ledgerJournalLine.parmLedgerDimension(_accountNum);
1397 #
1398 # ledgerJournalLine.parmOffsetCompany(RetailGiftCardPostingParameters::getGiftCardCompany());
1399 # ledgerJournalLine.parmOffsetLedgerDimension(_offsetAccountNum);
1400 # ledgerJournalLine.parmOffsetAccountType(LedgerJournalACType::Ledger);
1401 #
1402 # ledgerJournalLine.parmCurrencyCode(_currency);
1403 # ledgerJournalLine.parmTransDate(_date);
1404 #
1405 # ledgerJournalLine.parmDocumentNum(statementTable.statementId);
1406 # ledgerJournalLine.parmTransactionType(LedgerTransType::Transfer);
1407 #
1408 # if (_Amount < 0)
1409 # {
1410 # ledgerJournalLine.parmAmountCurDebit(abs(_Amount));
1411 # }
1412 # else
1413 # {
1414 # ledgerJournalLine.parmAmountCurCredit(_Amount);
1415 # }
1416 #
1417 # ledgerJournalLine.save();
1418 #
1419 # ttsCommit;
1420 # }
1421 #
1422 # giftcardCompany = RetailGiftCardPostingParameters::getGiftCardCompany();
1423 # if (!giftcardCompany || giftcardCompany == curext())
1424 # {
1425 # // No intercompany giftcard posting is needed.
1426 # return;
1427 # }
1428 #
1429 # // <GEERU>
1430 # if (RetailParameters::find().ProcessGiftCardsAsPrepayments_RU)
1431 # {
1432 # // Standard intercompany giftcard posting should be skipped.
1433 # return;
1434 # }
1435 # // </GEERU>
1436 #
1437 # select journalName from journalName where journalName.JournalName == RetailGiftCardPostingParameters::getGiftCardLedgerJournalName();
1438 #
1439 # if (!journalName)
1440 # {
1441 # // Journal name is not correctly set up, intercompany gift card posting can't proceed.
1442 # throw error("@REX4040023");
1443 # }
1444 #
1445 # // Get the number sequence for slip journal document
1446 # journalNumSeq = NumberSeq::newGetNum(LedgerParameters::numRefJournalNum());
1447 #
1448 # // Create ledger journal
1449 # ttsBegin;
1450 # ledgerJournal = new AxLedgerJournalTable();
1451 # ledgerJournal.parmJournalName(journalName.JournalName);
1452 # ledgerJournal.parmJournalType(journalName.JournalType);
1453 # ledgerJournal.parmJournalNum(journalNumSeq.num());
1454 # ledgerJournal.parmNumberSequenceTable(journalName.NumberSequenceTable);
1455 # ledgerJournal.parmRetailStatementId(statementTable.statementId);
1456 # ledgerJournal.save();
1457 #
1458 # // Create ledger journal lines. All avaiable transactions with transactionstatus = none are marked as posted before.
1459 # while select statementId, businessDate, currency, ItemId, netAmount, transactionStatus from giftcardSalesTrans
1460 # where giftcardSalesTrans.statementId == statementTable.statementId &&
1461 # giftcardSalesTrans.itemId == RetailParameters::find().GiftcardItem
1462 # && giftcardSalesTrans.transactionStatus == RetailEntryStatus::Posted
1463 # {
1464 # if (giftcardSalesTrans.netAmount)
1465 # {
1466 # createPaymentLedgerTrans(
1467 # RetailGiftCardPostingParameters::getSalesOrderAccountNumber(curext(), statementTable.DefaultDimension),
1468 # RetailGiftCardPostingParameters::getSalesOrderAccountNumber(RetailGiftCardPostingParameters::getGiftCardCompany(), statementTable.DefaultDimension),
1469 # giftcardSalesTrans.currency,
1470 # // SalesLine table uses negative amounts while RetailTransactionSalesLines uses positive amounts.
1471 # // The amount on this voucher should be negative, so we are using original netAmount (negative)
1472 # giftcardSalesTrans.netAmount,
1473 # giftcardSalesTrans.businessDate);
1474 # }
1475 # }
1476 #
1477 # storeTenderTypeTable = RetailGiftCardPostingParameters::getStoreGiftcardTenderType(statementTable.storeId);
1478 #
1479 # while select statementId, businessDate, currency, tenderType, amountCur
1480 # from giftcardPaymentTrans
1481 # group by statementId, businessDate, currency
1482 # where giftcardPaymentTrans.statementId == statementTable.statementId &&
1483 # giftcardPaymentTrans.tenderType == storeTenderTypeTable.tenderTypeId
1484 # {
1485 # if (giftcardPaymentTrans.amountCur)
1486 # {
1487 # createPaymentLedgerTrans(
1488 # DimensionDefaultingService::serviceCreateLedgerDimension(RetailGiftCardPostingParameters::getGiftcardPaymentAccount(statementTable.storeId), statementTable.DefaultDimension),
1489 # RetailGiftCardPostingParameters::getSalesPostingAccount(RetailGiftCardPostingParameters::getGiftCardCompany(),
1490 # statementTable.storeId,
1491 # statementTable.DefaultDimension),
1492 # giftcardPaymentTrans.currency,
1493 # giftcardPaymentTrans.amountCur,
1494 # giftcardPaymentTrans.businessDate);
1495 # }
1496 # }
1497 #
1498 # ttsCommit;
1499 #
1500 # // Post the journal
1501 # select firstonly RecId from ledgerJournalTrans
1502 # where ledgerJournalTrans.JournalNum == ledgerJournal.parmJournalNum();
1503 # if (ledgerJournalTrans.RecId)
1504 # {
1505 # LedgerJournalPost::postJournal(ledgerJournal.ledgerJournalTable(), NoYes::No, false, true);
1506 # }
1507 # else
1508 # {
1509 # ledgerJournal.delete();
1510 # }
1511 #}
1512 ENDSOURCE
1513 SOURCE #postDeniedConsumerFiscalDocuments_BR
1514 #// <GBR>
1515 #protected void postDeniedConsumerFiscalDocuments_BR(RetailStatementTable _statementTable)
1516 #{
1517 # #FiscalDocumentModels_BR
1518 #
1519 # RetailFiscalDocument_BR retailFiscalDocument;
1520 # RetailFiscalDocumentPost_BR retailFiscalDocumentPost;
1521 # RetailTransactionTable transactionTable;
1522 # FiscalDocument_BR fiscalDocument;
1523 #
1524 # // post denied consumer fiscal documents
1525 # while select * from retailFiscalDocument
1526 # where retailFiscalDocument.Status == FiscalDocumentStatus_BR::Denied
1527 # && retailFiscalDocument.Model == #FiscalDocModel_65
1528 # && retailFiscalDocument.store == _statementTable.storeId
1529 #
1530 # exists join transactionTable
1531 # where transactionTable.Transactionid == retailFiscalDocument.Transactionid
1532 # && transactionTable.terminal == retailFiscalDocument.terminal
1533 # && transactionTable.store == retailFiscalDocument.store
1534 # // check if transactionTable record is inside range defined in _statementTable
1535 # && (((! _statementTable.transFromDate || transactionTable.transDate > _statementTable.transFromDate
1536 # || (transactionTable.transDate == _statementTable.transFromDate && (! _statementTable.transFromTime || transactionTable.transTime >= _statementTable.transFromTime)))
1537 # &&
1538 # (! _statementTable.transToDate || transactionTable.transDate < _statementTable.transToDate
1539 # || (transactionTable.transDate == _statementTable.transToDate && (! _statementTable.transToTime || transactionTable.transTime <= _statementTable.transToTime)))))
1540 #
1541 # notExists join fiscalDocument
1542 # where fiscalDocument.AccessKey == retailFiscalDocument.AccessKey
1543 # {
1544 # retailFiscalDocumentPost = this.getFiscalDocPostWithoutCustInvJour_BR();
1545 # retailFiscalDocumentPost.run(retailFiscalDocument);
1546 # }
1547 #}
1548 #//</GBR>
1549 ENDSOURCE
1550 SOURCE #postDiscounts
1551 #/// <summary>
1552 #/// Post the discounted amount.
1553 #/// </summary>
1554 #/// <param name="_documentNumber">
1555 #/// The statement ID of the <c>RetailTransactionSalesTrans</c> table.
1556 #/// </param>
1557 #/// <param name="_transactionSalesTrans">
1558 #/// The current instance of <c>RetailTransactionSalesTrans</c> table.
1559 #/// </param>
1560 #/// <param name="_transactionDiscountTrans">
1561 #/// The current instance of <c>RetailTransactionDiscountTrans</c> table.
1562 #/// </param>
1563 #/// <param name="_currencyCode">
1564 #/// The curreny code of the record <c>RetailTransactionSalesTrans</c> table.
1565 #/// </param>
1566 #/// <param name="_custAccount">
1567 #/// The customer account of the record <c>RetailTransactionSalesTrans</c> table.
1568 #/// </param>
1569 #void postDiscounts(
1570 # str _documentNumber,
1571 # RetailTransactionSalesTrans _transactionSalesTrans,
1572 # RetailTransactionDiscountTrans _transactionDiscountTrans,
1573 # CurrencyCode _currencyCode,
1574 # CustAccount _custAccount)
1575 #{
1576 # CurrencyCode currencyCode;
1577 # LedgerPostingType ledgerPostingType;
1578 # DiscAmount periodicDiscount;
1579 # LedgerDimensionDefaultAccount accountPeriodicDisc, accountDisc;
1580 # ExchRate exchRate;
1581 # DimensionDefault defaultDimensionMerged;
1582 #
1583 # ;
1584 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepStart(0, 'postDiscounts');
1585 #
1586 # RetailTracer::Info('Posting', 'RetailStatementPost::postDiscounts()', 'Post discount parameters: postPeriodicDisc=%1, ledgerAccountType=%2', parameters.postPeriodicDisc, parameters.ledgerAccountType);
1587 #
1588 # if (parameters.postPeriodicDisc && (parameters.ledgerAccountType == RetailBookingLedgerAccountTypeBase::Periodic)
1589 # && (_transactionDiscountTrans.DiscountOriginType == RetailDiscountOriginType::Periodic)
1590 # )
1591 # {
1592 # accountPeriodicDisc = this.accountPeriodicDisc(
1593 # _transactionDiscountTrans.PeriodicDiscountOfferId,
1594 # _transactionDiscountTrans.DiscountCost,
1595 # _transactionSalesTrans.ItemId,
1596 # '' /*_transactionSalesTrans.ItemGroupId*/,
1597 # _custAccount);
1598 # accountDisc = InventPosting::accountItemLedgerDimension(InventAccountType::SalesDisc,
1599 # _transactionSalesTrans.ItemId,
1600 # '', //_transactionSalesTrans.ItemGroupId was removed and they were different types anyway.
1601 # 0,
1602 # _custAccount,
1603 # _transactionSalesTrans.taxGroup,
1604 # _transactionSalesTrans.TaxItemGroup);
1605 #
1606 # RetailTracer::Info('Posting', 'RetailStatementPost::postDiscounts()',
1607 # 'Post discount accounts: PeriodicDiscountOfferId=%1, accountPeriodicDisc=%2',
1608 # _transactionDiscountTrans.PeriodicDiscountOfferId, accountPeriodicDisc);
1609 #
1610 # if (accountPeriodicDisc && accountDisc && (accountPeriodicDisc != accountDisc))
1611 # {
1612 #
1613 # this.initVoucher(_transactionSalesTrans.businessDate);
1614 #
1615 # currencyCode = _currencyCode;
1616 #
1617 # if (!currencyCode)
1618 # {
1619 # currencyCode = storeTable.Currency;
1620 # }
1621 #
1622 # ledgerPostingType = _custAccount ? LedgerPostingType::CustInvoiceDisc : LedgerPostingType::SalesDisc;
1623 #
1624 # exchRate = this.getExchRate(_transactionSalesTrans.businessDate, _currencyCode, _transactionSalesTrans.Store);
1625 #
1626 # periodicDiscount = accountPeriodicDisc && parameters.PostPeriodicDisc ? _transactionDiscountTrans.DiscountCost : 0;
1627 #
1628 # defaultDimensionMerged = DimensionDefaultingService::serviceMergeDefaultDimensions(_transactionSalesTrans.DefaultDimension,
1629 # InventTable::find(_transactionSalesTrans.itemId).DefaultDimension);
1630 #
1631 # if (accountDisc && periodicDiscount)
1632 # {
1633 # ledgerVoucherTransObject = LedgerVoucherTransObject::newTransactionAmountDefault(ledgerVoucherObject,
1634 # LedgerPostingType::SalesDisc,
1635 # DimensionDefaultingService::serviceCreateLedgerDimension(
1636 # accountDisc,
1637 # defaultDimensionMerged),
1638 # currencyCode,
1639 # -periodicDiscount,
1640 # CurrencyExchangeHelper::newExchangeDate(Ledger::primaryLedger(CompanyInfo::findDataArea(curext()).RecId), ledgerVoucherObject.parmAccountingDate()));
1641 #
1642 # ledgerVoucherTransObject.parmSourceTableId(_transactionDiscountTrans.TableId);
1643 # ledgerVoucherTransObject.parmSourceRecId(_transactionDiscountTrans.RecId);
1644 # this.setLVTOTransTxt(ledgerVoucherTransObject, LedgerTransTxt::SalesEndDisc,
1645 # "@RET4320" + " - " +
1646 # "@RET4443" + _transactionSalesTrans.TransactionId +
1647 # "@RET4444" + _transactionSalesTrans.Store +
1648 # "@RET4445" + _transactionSalesTrans.TerminalId);
1649 # ledgerVoucher.addTrans(ledgerVoucherTransObject);
1650 # }
1651 #
1652 # if (parameters.PostPeriodicDisc && _transactionDiscountTrans.DiscountCost && accountPeriodicDisc)
1653 # {
1654 # ledgerVoucherTransObject = LedgerVoucherTransObject::newTransactionAmountDefault(ledgerVoucherObject,
1655 # LedgerPostingType::SalesDisc,
1656 # DimensionDefaultingService::serviceCreateLedgerDimension(
1657 # accountPeriodicDisc,
1658 # defaultDimensionMerged),
1659 # currencyCode,
1660 # _transactionDiscountTrans.DiscountCost,
1661 # CurrencyExchangeHelper::newExchangeDate(Ledger::primaryLedger(CompanyInfo::findDataArea(curext()).RecId), ledgerVoucherObject.parmAccountingDate()));
1662 #
1663 # ledgerVoucherTransObject.parmSourceTableId(_transactionDiscountTrans.TableId);
1664 # ledgerVoucherTransObject.parmSourceRecId(_transactionDiscountTrans.RecId);
1665 # this.setLVTOTransTxt(ledgerVoucherTransObject, LedgerTransTxt::SalesEndDisc,
1666 # "@RET3071" + " - " + _transactionDiscountTrans.PeriodicDiscountOfferId);
1667 # ledgerVoucher.addTrans(ledgerVoucherTransObject);
1668 # }
1669 #
1670 # //Posting of the inventory transaction
1671 #
1672 # ledgerVoucherObject.lastTransTxt(
1673 # this.concatTransTxt(ledgerVoucherObject.lastTransTxt(),
1674 # "@RET4319" + " - " +
1675 # "@RET4443" + _transactionSalesTrans.TransactionId +
1676 # "@RET4444" + _transactionSalesTrans.Store +
1677 # "@RET4445" + _transactionSalesTrans.TerminalId));
1678 #
1679 # ledgerVoucherObject.parmDocument(_transactionSalesTrans.businessDate, _documentNumber);
1680 # }
1681 # else
1682 # {
1683 # warning("@RET260885");
1684 # RetailTracer::Warning('Posting', 'RetailStatementPost::postDiscounts()', "@RET260885");
1685 # }
1686 # }
1687 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepEnd(0, 'postDiscounts');
1688 #}
1689 #
1690 ENDSOURCE
1691 SOURCE #postFiscalDocumentModel2_BR
1692 #/// <summary>
1693 #/// Processes a Fiscal document model 02 created at the POS.
1694 #/// </summary>
1695 #/// <param name="_transactionTable">
1696 #/// The Retail sales transaction related to the Fiscal receipt.
1697 #/// </param>
1698 #/// <returns>
1699 #/// True if a Fiscal document model 02 was found related to the Sales transaction; otherwise, false.
1700 #/// </returns>
1701 #// <GBR>
1702 #protected boolean postFiscalDocumentModel2_BR(RetailTransactionTable _transactionTable)
1703 #{
1704 # boolean documentFound = false;
1705 # CustInvoiceJour custInvoiceJour;
1706 # FiscalDocumentPost_BR fiscalDocumentPost;
1707 # RetailFiscalDocumentModel2_BR fiscalDocumentModel2;
1708 #
1709 # // Retrieve the fiscal document model 2 associated to the retail transaction
1710 # fiscalDocumentModel2 = RetailFiscalDocumentModel2_BR::find(_transactionTable.transactionId,
1711 # _transactionTable.Store,
1712 # _transactionTable.terminal);
1713 #
1714 # if (fiscalDocumentModel2)
1715 # {
1716 # // Get the voucher
1717 # select ledgerVoucher from custInvoiceJour
1718 # where custInvoiceJour.InvoiceId == _transactionTable.invoiceId
1719 # && custInvoiceJour.InvoiceDate == _transactionTable.businessDate;
1720 #
1721 # // Post the fiscal document model 2
1722 # fiscalDocumentPost = this.getFiscalDocumentPost_BR(fiscalDocumentModel2, custInvoiceJour.ledgerVoucher);
1723 # fiscalDocumentPost.run();
1724 #
1725 # documentFound = true;
1726 # }
1727 #
1728 # return documentFound;
1729 #}
1730 #// </GBR>
1731 #
1732 ENDSOURCE
1733 SOURCE #postFiscalReceipt_BR
1734 #/// <summary>
1735 #/// Processes a Fiscal receipt originally created at the POS.
1736 #/// </summary>
1737 #/// <param name="_transactionTable">
1738 #/// The Retail sales transaction related to the Fiscal receipt.
1739 #/// </param>
1740 #/// <returns>
1741 #/// True if a Fiscal receipt was found related to the Sales transaction; otherwise, false.
1742 #/// </returns>
1743 #// <GBR>
1744 #protected boolean postFiscalReceipt_BR(RetailTransactionTable _transactionTable)
1745 #{
1746 # boolean documentFound;
1747 #
1748 # documentFound = fiscalReceiptProcessor.postFiscalReceipt(_transactionTable);
1749 #
1750 # if (documentFound)
1751 # {
1752 # // The fiscal receipt might have a fiscal document model 02 linked to it
1753 # this.postFiscalDocumentModel2_BR(_transactionTable);
1754 # }
1755 #
1756 # return documentFound;
1757 #}
1758 #// </GBR>
1759 ENDSOURCE
1760 SOURCE #postFiscalReceiptVoided_BR
1761 #/// <summary>
1762 #/// Cancels a Fiscal receipt if there is a related sales return.
1763 #/// </summary>
1764 #/// <param name="_transactionTable">
1765 #/// The Retail transaction that might be a sales return.
1766 #/// </param>
1767 #/// <returns>
1768 #/// True if it is a sales return and a related fiscal receipt was found; otherwise, false.
1769 #/// </returns>
1770 #/// <remarks>
1771 #/// This covers only fiscal receipts voided after they are concluded, which are handled as sales return.
1772 #/// The statement post will skip fiscal receipts voided before they are concluded, so they are handled at postConcludePost_BR.
1773 #/// </remarks>
1774 #// <GBR>
1775 #protected boolean postFiscalReceiptVoided_BR(RetailTransactionTable _transactionTable)
1776 #{
1777 # boolean documentFound = false;
1778 #
1779 # if (_transactionTable.saleIsReturnSale)
1780 # {
1781 # documentFound = fiscalReceiptProcessor.postFiscalReceipt(fiscalReceiptProcessor.getOriginalRetailTransaction(_transactionTable));
1782 # }
1783 #
1784 # return documentFound;
1785 #}
1786 #// </GBR>
1787 #
1788 ENDSOURCE
1789 SOURCE #postGiftCardForSalesTaxProvision
1790 #/// <summary>
1791 #/// Post Issue Gift Card and Add to Gift Card transactions for Sales Tax provision to holding account.
1792 #/// </summary>
1793 #private void postGiftCardForSalesTaxProvision()
1794 #{
1795 # RetailTransactionSalesTrans giftcardSalesTrans;
1796 # RetailTransactionPaymentTrans giftcardPaymentTrans;
1797 # RetailStoreTenderTypeTable storeTenderTypeTable;
1798 # NumberSequenceTable numberSequenceTable;
1799 # LedgerJournalTrans ledgerJournalTrans;
1800 # NumberSeq journalNumSeq;
1801 # NumberSeq voucherNumSeq;
1802 # AxLedgerJournalTable ledgerJournal;
1803 # LedgerJournalName gcJournalName;
1804 # RetailStatementVoucher statementVoucher;
1805 # TaxAmount taxAmount;
1806 # LedgerDimensionAccount payableAccount;
1807 # LedgerDimensionAccount holdingAccount;
1808 # TaxCode taxCode;
1809 # container payableAndHoldingAccountWithTax;
1810 # int containerLength;
1811 # int counter;
1812 # LineNum lineNum;
1813 # Voucher giftCardVoucher;
1814 #
1815 # #define.PayableAcount(1)
1816 # #define.HoldingAcount(2)
1817 # #define.TaxCode(3)
1818 # #define.TaxPercent(4)
1819 #
1820 # void createLedgerTrans(
1821 # LedgerDimensionAccount _accountNum,
1822 # CurrencyCode _currency,
1823 # TaxCode _taxCode,
1824 # AmountCur _Amount,
1825 # LineNum _lineNum,
1826 # TransDate _date)
1827 # {
1828 # AxLedgerJournalTrans ledgerJournalLine;
1829 #
1830 # if (!_Amount)
1831 # {
1832 # return;
1833 # }
1834 #
1835 # if (!_accountNum)
1836 # {
1837 # // Account number or offset account number is not correctly set up, gift card sales tax provision posting can't proceed.
1838 # throw error("@SYP4862814");
1839 # }
1840 #
1841 # ledgerJournalLine = new AxLedgerJournalTrans();
1842 #
1843 # ledgerJournalLine.parmJournalNum(ledgerJournal.parmJournalNum());
1844 # ledgerJournalLine.parmAccountType(LedgerJournalACType::Ledger);
1845 # ledgerJournalLine.parmCompany(curext());
1846 # ledgerJournalLine.parmLedgerDimension(_accountNum);
1847 #
1848 # ledgerJournalLine.parmDefaultDimension(ledgerJournal.parmDefaultDimension());
1849 # ledgerJournalLine.parmTaxCode(_taxCode);
1850 #
1851 # ledgerJournalLine.parmCurrencyCode(_currency);
1852 # ledgerJournalLine.parmTransDate(_date);
1853 #
1854 # ledgerJournalLine.parmDocumentNum(statementTable.statementId);
1855 # ledgerJournalLine.parmTransactionType(LedgerTransType::GeneralJournal);
1856 # ledgerJournalLine.parmApproved(NoYes::Yes);
1857 # ledgerJournalLine.parmLineNum(_lineNum);
1858 # ledgerJournalLine.parmVoucher(giftCardVoucher);
1859 #
1860 # if (_Amount < 0)
1861 # {
1862 # ledgerJournalLine.parmAmountCurDebit(abs(_Amount));
1863 # }
1864 # else
1865 # {
1866 # ledgerJournalLine.parmAmountCurCredit(_Amount);
1867 # }
1868 #
1869 # ledgerJournalLine.save();
1870 # }
1871 #
1872 # TaxAmount getTaxAmountForPricesInclusiveofTax(RetailNetAmount amountInclusiveTax, TaxValue taxRate, CurrencyCode currency)
1873 # {
1874 # TaxAmount tax;
1875 #
1876 # tax = amountInclusiveTax * (taxRate / (100 + taxRate));
1877 #
1878 # tax = CurrencyExchangeHelper::round(tax, currency);
1879 #
1880 # return tax;
1881 # }
1882 #
1883 # select journalName from gcJournalName where gcJournalName.JournalName == RetailGiftCardPostingParameters::getGiftCardLedgerJournalName();
1884 #
1885 # if (!gcJournalName)
1886 # {
1887 # // Journal name is not correctly set up, gift card Tax withholding secondary posting can't proceed.
1888 # throw error("@SYP4886752");
1889 # }
1890 #
1891 # journalNumSeq = NumberSeq::newGetNum(LedgerParameters::numRefJournalNum());
1892 #
1893 # // Create ledger journal
1894 # ledgerJournal = new AxLedgerJournalTable();
1895 #
1896 # ledgerJournal.parmJournalName(gcJournalName.JournalName);
1897 # ledgerJournal.parmJournalType(gcJournalName.JournalType);
1898 # ledgerJournal.parmJournalNum(journalNumSeq.num());
1899 # ledgerJournal.parmNumberSequenceTable(gcJournalName.NumberSequenceTable);
1900 # ledgerJournal.parmDefaultDimension(statementTable.DefaultDimension);
1901 # ledgerJournal.parmRetailStatementId(statementTable.statementId);
1902 # ledgerJournal.save();
1903 #
1904 # select firstOnly numberSequenceTable
1905 # where numberSequenceTable.RecId == gcJournalName.NumberSequenceTable;
1906 #
1907 # voucherNumSeq = NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence, NumberSeqScopeFactory::createDefaultScope(), false, true);
1908 # giftCardVoucher = voucherNumSeq.voucher();
1909 #
1910 # // Get container with payable account (TaxOutgoingLedgerDimension), holding account (TaxReportLedgerDimension) and Tax Percentage (TaxValue)
1911 # payableAndHoldingAccountWithTax = RetailGiftCardPostingParameters::getGCTaxWithPayableAndHoldingAccount(curext(), statementTable.storeId);
1912 # containerLength = conLen(payableAndHoldingAccountWithTax);
1913 #
1914 # lineNum = 0;
1915 # // For Issue Gift Card and Add To Gift Card Lines, hold tax on GiftCard Amount.
1916 # while select sum(netAmountInclTax), businessDate, currency from giftcardSalesTrans
1917 # group by statementId, businessDate, currency
1918 # where giftcardSalesTrans.statementId == statementTable.statementId &&
1919 # giftcardSalesTrans.itemId == RetailParameters::find().GiftcardItem
1920 # {
1921 # if (giftcardSalesTrans.netAmountInclTax)
1922 # {
1923 # // Create Journal line for Payable accounts from each Tax Code and Debit TaxAmount and Holding accont from each tax code and Credit TaxAmount.
1924 # for (counter = 1; counter <= containerLength; counter++)
1925 # {
1926 # taxCode = conPeek(conPeek(payableAndHoldingAccountWithTax, counter), #TaxCode);
1927 # taxAmount = getTaxAmountForPricesInclusiveofTax(abs(giftcardSalesTrans.netAmountInclTax), conPeek(conPeek(payableAndHoldingAccountWithTax, counter), #TaxPercent), giftcardSalesTrans.currency);
1928 # payableAccount = DimensionDefaultingService::serviceCreateLedgerDimension(conPeek(conPeek(payableAndHoldingAccountWithTax, counter), #PayableAcount), statementTable.DefaultDimension);
1929 # holdingAccount = DimensionDefaultingService::serviceCreateLedgerDimension(conPeek(conPeek(payableAndHoldingAccountWithTax, counter), #HoldingAcount), statementTable.DefaultDimension);
1930 #
1931 # lineNum = lineNum + 1;
1932 # // Create ledger journal lines for account payable.
1933 # createLedgerTrans(
1934 # payableAccount,
1935 # giftcardSalesTrans.currency,
1936 # taxCode,
1937 # taxAmount,
1938 # lineNum,
1939 # giftcardSalesTrans.businessDate);
1940 #
1941 # lineNum = lineNum + 1;
1942 # // Create ledger journal lines for holding account
1943 # createLedgerTrans(
1944 # holdingAccount,
1945 # giftcardSalesTrans.currency,
1946 # taxCode,
1947 # - taxAmount,
1948 # lineNum,
1949 # giftcardSalesTrans.businessDate);
1950 # }
1951 # }
1952 # }
1953 #
1954 # storeTenderTypeTable = RetailGiftCardPostingParameters::getStoreGiftcardTenderType(statementTable.storeId);
1955 #
1956 # while select sum(amountCur), businessDate, currency from giftcardPaymentTrans
1957 # group by statementId, businessDate, currency
1958 # where giftcardPaymentTrans.statementId == statementTable.statementId &&
1959 # giftcardPaymentTrans.tenderType == storeTenderTypeTable.tenderTypeId
1960 # {
1961 # if (giftcardPaymentTrans.amountCur)
1962 # {
1963 # // Create Journal line for Payable accounts from each Tax Code and credit TaxAmount
1964 # for (counter = 1; counter <= containerLength; counter++)
1965 # {
1966 # taxCode = conPeek(conPeek(payableAndHoldingAccountWithTax, counter), #TaxCode);
1967 # taxAmount = getTaxAmountForPricesInclusiveofTax(abs(giftcardPaymentTrans.amountCur), conPeek(conPeek(payableAndHoldingAccountWithTax, counter), #TaxPercent), giftcardPaymentTrans.currency);
1968 # payableAccount = DimensionDefaultingService::serviceCreateLedgerDimension(conPeek(conPeek(payableAndHoldingAccountWithTax, counter), #PayableAcount), statementTable.DefaultDimension);
1969 # holdingAccount = DimensionDefaultingService::serviceCreateLedgerDimension(conPeek(conPeek(payableAndHoldingAccountWithTax, counter), #HoldingAcount), statementTable.DefaultDimension);
1970 #
1971 # lineNum = lineNum + 1;
1972 # // Create ledger journal lines for account payable.
1973 # createLedgerTrans(
1974 # payableAccount,
1975 # giftcardPaymentTrans.currency,
1976 # taxCode,
1977 # - taxAmount,
1978 # lineNum,
1979 # giftcardPaymentTrans.businessDate);
1980 #
1981 # lineNum = lineNum + 1;
1982 # // Create ledger journal lines for account holding.
1983 # createLedgerTrans(
1984 # holdingAccount,
1985 # giftcardPaymentTrans.currency,
1986 # taxCode,
1987 # taxAmount,
1988 # lineNum,
1989 # giftcardPaymentTrans.businessDate);
1990 # }
1991 # }
1992 # }
1993 #
1994 # voucherNumSeq.used();
1995 #
1996 # // Post the journal
1997 # select firstonly RecId from ledgerJournalTrans
1998 # where ledgerJournalTrans.JournalNum == ledgerJournal.parmJournalNum();
1999 #
2000 # if (ledgerJournalTrans.RecId)
2001 # {
2002 # LedgerJournalPost::postJournal(ledgerJournal.ledgerJournalTable(), NoYes::No, false, true);
2003 #
2004 # // Link this journal to voucher.
2005 #
2006 # while select Voucher, TransDate
2007 # from ledgerJournalTrans
2008 # group by ledgerJournalTrans.Voucher, ledgerJournalTrans.TransDate
2009 # where ledgerJournalTrans.JournalNum == ledgerJournal.parmJournalNum()
2010 #
2011 # {
2012 # statementVoucher.statementId = statementTable.statementId;
2013 # statementVoucher.voucher = ledgerJournalTrans.Voucher;
2014 # statementVoucher.voucherDate = ledgerJournalTrans.TransDate;
2015 # statementVoucher.insert();
2016 # }
2017 # }
2018 # else
2019 # {
2020 # ledgerJournal.delete();
2021 # }
2022 #}
2023 #
2024 ENDSOURCE
2025 SOURCE #postIETax
2026 #/// <summary>
2027 #/// Post the tax amount based on the statement ID passed as parameter.
2028 #/// </summary>
2029 #/// <param name="_documentNumber">
2030 #/// The current value of Statement ID.
2031 #/// </param>
2032 #/// <param name="_transactionIncomeExpenseTrans">
2033 #/// The current instance of <c>RetailTransactionIncomeExpenseTrans</c> table.
2034 #/// </param>
2035 #/// <param name="_taxGroup">
2036 #/// The current value of tax group.
2037 #/// </param>
2038 #/// <param name="_taxItemGroup">
2039 #/// The current value of tax item group.
2040 #/// </param>
2041 #/// <param name="_amount">
2042 #/// The tax amount to be posted.
2043 #/// </param>
2044 #/// <param name="_currencyCode">
2045 #/// The current value of the Currncy code.
2046 #/// </param>
2047 #/// <remarks>
2048 #/// Based on the module type, tax will be initialized.
2049 #/// </remarks>
2050 #void postIETax(str _documentNumber,
2051 # RetailTransactionIncomeExpenseTrans _transactionIncomeExpenseTrans,
2052 # TaxGroup _taxGroup,
2053 # TaxItemGroup _taxItemGroup,
2054 # Amount _amount,
2055 # CurrencyCode _currencyCode)
2056 #{
2057 # Tax tax;
2058 # TaxAmountCur taxAmountCur;
2059 #;
2060 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepStart(0, 'postIETax');
2061 #
2062 # switch (_transactionIncomeExpenseTrans.taxModuleType())
2063 # {
2064 # case TaxModuleType::Sales :
2065 # tax = new RetailTaxSales(_transactionIncomeExpenseTrans.transactionTable(),
2066 # _taxGroup,
2067 # _taxItemGroup,
2068 # "",
2069 # _transactionIncomeExpenseTrans.incomeExpenseAccountTable().Name,
2070 # statementTable.DefaultDimension,
2071 # NoYes::Yes,
2072 # ledgerVoucher);
2073 # break;
2074 # case TaxModuleType::Purch :
2075 # tax = new RetailTaxPurch(_transactionIncomeExpenseTrans.transactionTable(),
2076 # _taxGroup,
2077 # _taxItemGroup,
2078 # "",
2079 # _transactionIncomeExpenseTrans.incomeExpenseAccountTable().Name,
2080 # statementTable.DefaultDimension,
2081 # true,
2082 # ledgerVoucher);
2083 # break;
2084 # }
2085 #
2086 # this.initVoucher(_transactionIncomeExpenseTrans.businessDate);
2087 #
2088 # taxAmountCur = tax.taxCalcWithoutSource(_taxGroup,
2089 # _taxItemGroup,
2090 # _transactionIncomeExpenseTrans.businessDate,
2091 # _currencyCode,
2092 # _amount,
2093 # _transactionIncomeExpenseTrans.taxModuleType());
2094 #
2095 # RetailTracer::Info('RetailStatementPost', 'postIETax',
2096 # 'Post Income/Expense tax: Module type= %1, amount=%2, currencyCode=%3',
2097 # _transactionIncomeExpenseTrans.taxModuleType(), _amount, _currencyCode);
2098 # tax.saveAndPost(LedgerPostingController::newForLedgerPostingJournal(ledgerVoucher));
2099 #
2100 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepEnd(0, 'postIETax');
2101 #}
2102 ENDSOURCE
2103 SOURCE #postIncomeExpenseLine
2104 #private void postIncomeExpenseLine(RetailTransactionTable _transactionTable
2105 # // <GEERU>
2106 # , RetailStatementPaymentJournal _expenseStatementPaymentJournal = null
2107 # // </GEERU>
2108 # )
2109 #{
2110 # RetailTransactionIncomeExpenseTrans transactionIncomeExpenseTrans;
2111 # RetailIncomeExpenseAccountTable incomeExpenseAccountTable;
2112 # RetailTransactionPaymentTrans payTransTable;
2113 # // <GEERU>
2114 # RetailStoreTenderTypeTable payStoreTenderTypeTable;
2115 # DimensionDefault defaultDimension;
2116 # // </GEERU>
2117 # MainAccountLegalEntity mainAccountLegalEntity;
2118 # Amount amount;
2119 # Amount amountUnrounded;
2120 #
2121 # TaxGroup taxGroup;
2122 # TaxItemGroup taxItemGroup;
2123 # CurrencyCode currencyCode;
2124 # boolean purchTaxOnOperation;
2125 #
2126 # LedgerDimensionAccount ledgerAccount;
2127 # LedgerJournalACType accountType;
2128 #
2129 # str documentNumber;
2130 # Amount roundingDiffAmount;
2131 #
2132 # #Retail
2133 #
2134 # container getLedgerOffsetAccount(
2135 # RetailStoreId _storeId,
2136 # RetailTenderTypeId _tenderTypeId,
2137 # RetailCardTypeId _cardTypeId,
2138 # DimensionDefault _paymentDimension)
2139 # {
2140 # LedgerJournalACType offsetAccountType;
2141 # DimensionDefault offsetAccountDefaultDimension;
2142 # LedgerDimensionDefaultAccount offsetAccountNum;
2143 #
2144 # RetailStoreTenderTypeTable storeTenderTypeTable;
2145 # RetailStoreTenderTypeCardTable storeTenderTypeCardTable;
2146 #
2147 # ;
2148 #
2149 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(_storeId).RecId, _tenderTypeId);
2150 #
2151 # switch (storeTenderTypeTable.function)
2152 # {
2153 # case RetailTenderFunction::Card:
2154 # if (_cardTypeId)
2155 # {
2156 # storeTenderTypeCardTable = RetailStoreTenderTypeCardTable::find(RetailStoreTable::find(_storeId).RecId, _tenderTypeId, _cardTypeId);
2157 # if (storeTenderTypeCardTable && storeTenderTypeCardTable.LedgerDimension)
2158 # {
2159 # offsetAccountType = (storeTenderTypeCardTable.accountType == RetailLedgerBank::Ledger) ? LedgerJournalACType::Ledger : LedgerJournalACType::Bank;
2160 # offsetAccountNum = storeTenderTypeCardTable.LedgerDimension;
2161 # break;
2162 # }
2163 # }
2164 # // this code must match that in the default clause below.
2165 # offsetAccountType = (storeTenderTypeTable.accountType == RetailLedgerBank::Ledger) ? LedgerJournalACType::Ledger : LedgerJournalACType::Bank;
2166 # offsetAccountNum = storeTenderTypeTable.LedgerDimension;
2167 # offsetAccountDefaultDimension = storeTenderTypeTable.DefaultDimension;
2168 # break;
2169 #
2170 # case RetailTenderFunction::Customer:
2171 # break;
2172 # default:
2173 # offsetAccountType = (storeTenderTypeTable.accountType == RetailLedgerBank::Ledger) ? LedgerJournalACType::Ledger : LedgerJournalACType::Bank;
2174 # offsetAccountNum = storeTenderTypeTable.LedgerDimension;
2175 # offsetAccountDefaultDimension = storeTenderTypeTable.DefaultDimension;
2176 # break;
2177 # }
2178 #
2179 # if (offsetAccountType == LedgerJournalACType::Ledger)
2180 # {
2181 #
2182 # offsetAccountNum = DimensionDefaultingService::serviceCreateLedgerDimension(
2183 # offsetAccountNum,
2184 # DimensionDefaultingService::serviceMergeDefaultDimensions(_paymentDimension, offsetAccountDefaultDimension));
2185 # }
2186 #
2187 # return [offsetAccountType, offsetAccountNum];
2188 # }
2189 # ;
2190 #
2191 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepStart(0, 'postIncomeExpenseLine');
2192 #
2193 # documentNumber = #T + strrem(_transactionTable.TransactionId, ",.");
2194 #
2195 # currencyCode = _transactionTable.currency;
2196 #
2197 # if (!currencyCode)
2198 # {
2199 # currencyCode = storeTable.Currency;
2200 # }
2201 # // <GEERU>
2202 # if (!_expenseStatementPaymentJournal)
2203 # {
2204 # // </GEERU>
2205 # while select transactionIncomeExpenseTrans
2206 # index transactionLineIdx
2207 # where transactionIncomeExpenseTrans.TransactionId == _transactionTable.TransactionId
2208 # && transactionIncomeExpenseTrans.store == _transactionTable.store
2209 # && transactionIncomeExpenseTrans.terminal == _transactionTable.terminal
2210 # && transactionIncomeExpenseTrans.TransactionStatus == RetailEntryStatus::None
2211 # {
2212 # incomeExpenseAccountTable = RetailIncomeExpenseAccountTable::find(transactionIncomeExpenseTrans.store, transactionIncomeExpenseTrans.IncomeExepenseAccount);
2213 #
2214 # mainAccountLegalEntity = MainAccountLegalEntity::findByMainAccountLegalEntity(DimensionStorage::getMainAccountFromLedgerDimension(incomeExpenseAccountTable.LedgerDimension).RecId, CompanyInfo::find().RecId);
2215 #
2216 # taxGroup = mainAccountLegalEntity.TaxGroup;
2217 # taxItemGroup = mainAccountLegalEntity.TaxItemGroup;
2218 # purchTaxOnOperation = TaxParameters::find().PurchTaxOnOperations;
2219 #
2220 # // TaxParameters::find().PurchTaxOnOperations - Use The US Tax System. (Income Expense does not support US tax calculations)
2221 # if (purchTaxOnOperation)
2222 # {
2223 # amount = transactionIncomeExpenseTrans.Amount;
2224 # }
2225 # else
2226 # {
2227 # amount = Tax::baseAmountExclTax(taxGroup,
2228 # taxItemGroup,
2229 # transactionIncomeExpenseTrans.businessDate,
2230 # currencyCode,
2231 # transactionIncomeExpenseTrans.Amount,
2232 # transactionIncomeExpenseTrans.taxModuleType());
2233 # }
2234 #
2235 # RetailTracer::Info('Posting',
2236 # 'RetailStatementPost::postIncomeExpenseLine()',
2237 # 'Post Income/Expense line: Account=%1, Amount=%2',
2238 # ledgerAccount, amount);
2239 #
2240 # this.createPaymentLedgerTrans(RetailLedgerBank::Ledger,
2241 # LedgerPostingType::LedgerJournal,
2242 # incomeExpenseAccountTable.LedgerDimension,
2243 # currencyCode,
2244 # amount,
2245 # transactionIncomeExpenseTrans.TableId,
2246 # transactionIncomeExpenseTrans.RecId,
2247 # transactionIncomeExpenseTrans.businessDate,
2248 # "@RET4319" + " - " +
2249 # "@RET4443" + transactionIncomeExpenseTrans.TransactionId +
2250 # "@RET4444" + transactionIncomeExpenseTrans.Store +
2251 # "@RET4445" + transactionIncomeExpenseTrans.Terminal,
2252 # documentNumber,
2253 # #SalesVoucher);
2254 #
2255 # roundingDiffAmount = -(transactionIncomeExpenseTrans.Amount + _transactionTable.paymentAmount);
2256 #
2257 # if(roundingDiffAmount != 0)
2258 # {
2259 # this.createPaymentLedgerTrans(RetailLedgerBank::Ledger,
2260 # LedgerPostingType::MSTDiff,
2261 # DimensionDefaultingService::serviceCreateLedgerDimension(
2262 # LedgerSystemAccounts::defaultAccount(LedgerPostingType::MSTDiff),
2263 # incomeExpenseAccountTable.LedgerDimension),
2264 # currencyCode,
2265 # roundingDiffAmount,
2266 # transactionIncomeExpenseTrans.TableId,
2267 # transactionIncomeExpenseTrans.RecId,
2268 # transactionIncomeExpenseTrans.transDate,
2269 # "@RET4319" + " - " +
2270 # "@RET4443" + transactionIncomeExpenseTrans.TransactionId +
2271 # "@RET4444" + transactionIncomeExpenseTrans.Store +
2272 # "@RET4445" + transactionIncomeExpenseTrans.Terminal,
2273 # documentNumber,
2274 # #SalesVoucher);
2275 #
2276 # }
2277 #
2278 # if (!purchTaxOnOperation)
2279 # {
2280 # amountUnrounded = Tax::baseAmountExclTaxRaw(taxGroup,
2281 # taxItemGroup,
2282 # transactionIncomeExpenseTrans.businessDate,
2283 # currencyCode,
2284 # transactionIncomeExpenseTrans.Amount,
2285 # transactionIncomeExpenseTrans.taxModuleType());
2286 # this.postIETax(documentNumber, transactionIncomeExpenseTrans, taxGroup, taxItemGroup, amountUnrounded, currencyCode);
2287 # }
2288 # }
2289 # // <GEERU>
2290 # }
2291 # else
2292 # {
2293 # // there is only one expense/income in one transaction
2294 # select firstOnly IncomeExepenseAccount from transactionIncomeExpenseTrans
2295 # index transactionLineIdx
2296 # where transactionIncomeExpenseTrans.TransactionId == _transactionTable.TransactionId
2297 # && transactionIncomeExpenseTrans.store == _transactionTable.store
2298 # && transactionIncomeExpenseTrans.terminal == _transactionTable.terminal
2299 # && transactionIncomeExpenseTrans.TransactionStatus == RetailEntryStatus::None;
2300 #
2301 # incomeExpenseAccountTable = RetailIncomeExpenseAccountTable::find(_transactionTable.store, transactionIncomeExpenseTrans.IncomeExepenseAccount);
2302 # }
2303 # // </GEERU>
2304 #
2305 # while select sum(amountCur) from payTransTable
2306 # group by tenderType, currency, exchRate, cardTypeId
2307 # // <GEERU>
2308 # , DefaultDimension
2309 # // </GEERU>
2310 # where payTransTable.store == _transactionTable.store
2311 # && payTransTable.terminal == _transactionTable.terminal
2312 # && payTransTable.transactionId == _transactionTable.transactionId
2313 # && payTransTable.transactionStatus == RetailEntryStatus::None
2314 # {
2315 # // <GEERU>
2316 # if (_expenseStatementPaymentJournal)
2317 # {
2318 # payStoreTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(_transactionTable.store).RecId, payTransTable.tenderType);
2319 # ledgerAccount = payStoreTenderTypeTable.LedgerDimension;
2320 # defaultDimension = DimensionDefaultingService::serviceMergeDefaultDimensions(payTransTable.DefaultDimension, payStoreTenderTypeTable.DefaultDimension);
2321 # if (payStoreTenderTypeTable.accountType == RetailLedgerBank::Ledger)
2322 # {
2323 # ledgerAccount = DimensionDefaultingService::serviceCreateLedgerDimension(ledgerAccount, defaultDimension);
2324 # }
2325 #
2326 # _expenseStatementPaymentJournal.createPaymentLedgerTrans(
2327 # payStoreTenderTypeTable.accountType,
2328 # ledgerAccount,
2329 # RetailLedgerBank::Ledger,
2330 # DimensionDefaultingService::serviceCreateLedgerDimension(incomeExpenseAccountTable.LedgerDimension, defaultDimension),
2331 # payTransTable.currency,
2332 # -payTransTable.amountCur,
2333 # _transactionTable.businessDate,
2334 # "@RET4319" + " - " +
2335 # "@RET4443" + _transactionTable.TransactionId +
2336 # "@RET4444" + _transactionTable.Store +
2337 # "@RET4445" + _transactionTable.Terminal,
2338 # statementTable.StatementId,
2339 # payTransTable.tenderType,
2340 # defaultDimension);
2341 # }
2342 # else
2343 # {
2344 # // </GEERU>
2345 # [accountType, ledgerAccount] = getLedgerOffsetAccount(
2346 # statementTable.storeId,
2347 # payTransTable.tenderType,
2348 # payTransTable.cardTypeId,
2349 # payTransTable.DefaultDimension);
2350 #
2351 # this.createPaymentLedgerTrans((accountType == LedgerJournalACType::Ledger) ? RetailLedgerBank::Ledger : RetailLedgerBank::Bank,
2352 # (accountType == LedgerJournalACType::Ledger) ? LedgerPostingType::LedgerJournal : LedgerPostingType::Bank,
2353 # ledgerAccount,
2354 # payTransTable.currency,
2355 # payTransTable.amountCur,
2356 # payTransTable.TableId,
2357 # payTransTable.RecId,
2358 # _transactionTable.businessDate,
2359 # "@RET4319" + " - " +
2360 # "@RET4443" + payTransTable.TransactionId +
2361 # "@RET4444" + payTransTable.Store +
2362 # "@RET4445" + payTransTable.Terminal,
2363 # documentNumber,
2364 # #SalesVoucher);
2365 # // <GEERU>
2366 # }
2367 # // </GEERU>
2368 # }
2369 #
2370 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepEnd(0, 'postIncomeExpenseLine');
2371 #}
2372 #
2373 ENDSOURCE
2374 SOURCE #postIncomeExpenseLine_Agregated_RU
2375 #// <GEERU>
2376 #private void postIncomeExpenseLine_Agregated_RU(RetailStatementPaymentJournal _expenseStatementPaymentJournal)
2377 #{
2378 # RetailTransactionPaymentTrans transactionPaymentTrans;
2379 # RetailTransactionIncomeExpenseTrans transactionIncomeExpenseTrans;
2380 # RetailIncomeExpenseAccountTable incomeExpenseAccountTable;
2381 # RetailStoreTenderTypeTable storeTenderTypeTable;
2382 # LedgerDimensionAccount ledgerAccount;
2383 # DimensionDefault defaultDimension;
2384 #
2385 # while select businessDate, TenderType, Currency, sum(amountCur) from transactionPaymentTrans
2386 # group by statementCode, Store, businessDate, TenderType, Currency, DefaultDimension
2387 # where transactionPaymentTrans.statementId == statementTable.statementId
2388 # && transactionPaymentTrans.transactionStatus == RetailEntryStatus::None
2389 # join IncomeExepenseAccount from transactionIncomeExpenseTrans
2390 # group by IncomeExepenseAccount
2391 # where transactionIncomeExpenseTrans.TransactionId == transactionPaymentTrans.TransactionId
2392 # && transactionIncomeExpenseTrans.store == transactionPaymentTrans.store
2393 # && transactionIncomeExpenseTrans.terminal == transactionPaymentTrans.terminal
2394 # && transactionIncomeExpenseTrans.TransactionStatus == RetailEntryStatus::None
2395 # {
2396 # if (!transactionPaymentTrans.amountCur)
2397 # continue;
2398 #
2399 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(transactionPaymentTrans.store).RecId, transactionPaymentTrans.tenderType);
2400 # ledgerAccount = storeTenderTypeTable.LedgerDimension;
2401 # defaultDimension = DimensionDefaultingService::serviceMergeDefaultDimensions(transactionPaymentTrans.DefaultDimension, storeTenderTypeTable.DefaultDimension);
2402 #
2403 # incomeExpenseAccountTable = RetailIncomeExpenseAccountTable::find(transactionPaymentTrans.store, transactionIncomeExpenseTrans.IncomeExepenseAccount);
2404 #
2405 # if (storeTenderTypeTable.accountType == RetailLedgerBank::Ledger)
2406 # {
2407 # ledgerAccount = DimensionDefaultingService::serviceCreateLedgerDimension(ledgerAccount, defaultDimension);
2408 # }
2409 #
2410 # _expenseStatementPaymentJournal.createPaymentLedgerTrans(
2411 # storeTenderTypeTable.accountType,
2412 # ledgerAccount,
2413 # RetailLedgerBank::Ledger,
2414 # DimensionDefaultingService::serviceCreateLedgerDimension(incomeExpenseAccountTable.LedgerDimension, defaultDimension),
2415 # transactionPaymentTrans.currency,
2416 # -transactionPaymentTrans.amountCur,
2417 # transactionPaymentTrans.businessDate,
2418 # "@RET4319" + " - " + incomeExpenseAccountTable.AccountNum,
2419 # statementTable.StatementId,
2420 # transactionPaymentTrans.tenderType,
2421 # defaultDimension);
2422 # }
2423 #}
2424 #// </GEERU>
2425 ENDSOURCE
2426 SOURCE #postLinkedFiscalDocument_BR
2427 #/// <summary>
2428 #/// Posts a retail fiscal document for a linked electronic fiscal document originally created at the POS.
2429 #/// </summary>
2430 #/// <param name="_transactionTable">
2431 #/// A <c>RetailTransactionTable</c> record being processed by the statement.
2432 #/// </param>
2433 #// <GBR>
2434 #protected void postLinkedFiscalDocument_BR(RetailTransactionTable _transactionTable)
2435 #{
2436 # RetailFiscalDocumentPost_BR retailFiscalDocumentPost;
2437 # RetailFiscalDocument_BR retailFiscalDocument;
2438 # RetailTransactionTable transactionTableCancel;
2439 # RetailEFDocumentToBeInquired_BR efDocumentToBeInquired;
2440 #
2441 # retailFiscalDocument = RetailFiscalDocument_BR::findByRetailTransaction(_transactionTable);
2442 #
2443 # if (retailFiscalDocument &&
2444 # (retailFiscalDocument.Status == FiscalDocumentStatus_BR::Approved || retailFiscalDocument.Status == FiscalDocumentStatus_BR::Denied))
2445 # {
2446 # retailFiscalDocumentPost = this.getFiscalDocPostWithoutCustInvJour_BR();
2447 # retailFiscalDocumentPost.run(retailFiscalDocument);
2448 # }
2449 # else if (retailFiscalDocument.Status == FiscalDocumentStatus_BR::Created && retailFiscalDocument.MessageStatus == EFDocMessageStatus_BR::Sent)
2450 # {
2451 # efDocumentToBeInquired.Status = RetailEFDocumentToBeInquiredStatus_BR::Unknown;
2452 # efDocumentToBeInquired.RetailFiscalDocument_BR = retailFiscalDocument.RecId;
2453 # efDocumentToBeInquired.insert();
2454 # }
2455 #
2456 # transactionTableCancel = this.getFDocCancelRetailTransaction_BR(_transactionTable.statementId, retailFiscalDocument.AccessKey);
2457 #
2458 # if (transactionTableCancel)
2459 # {
2460 # this.postLinkedFiscalDocumentCanceled_BR(transactionTableCancel);
2461 # }
2462 #}
2463 #// </GBR>
2464 ENDSOURCE
2465 SOURCE #postLinkedFiscalDocumentCanceled_BR
2466 #/// <summary>
2467 #/// Posts the canceling of a linked electronic fiscal document (model 55) originally created at the POS.
2468 #/// </summary>
2469 #/// <param name="_transactionTable">
2470 #/// A <c>RetailTransactionTable</c> record being processed by the statement.
2471 #/// </param>
2472 #/// <returns>
2473 #/// True if a fiscal document was found related to the transaction; otherwise, false.
2474 #/// </returns>
2475 #/// <remarks>
2476 #/// It could happen that this cancel method is called before the linked electronic fiscal document is posted.
2477 #/// </remarks>
2478 #// <GBR>
2479 #protected boolean postLinkedFiscalDocumentCanceled_BR(RetailTransactionTable _transactionTable)
2480 #{
2481 # boolean documentFound = false;
2482 # RetailFiscalDocumentPost_BR retailFiscalDocumentPost;
2483 # RetailFiscalDocumentCancel_BR retailFiscalDocumentCancel;
2484 # FiscalDocument_BR fiscalDocument;
2485 #
2486 # retailFiscalDocumentCancel = RetailFiscalDocumentCancel_BR::findByRetailTransaction(_transactionTable);
2487 #
2488 # if (retailFiscalDocumentCancel)
2489 # {
2490 # fiscalDocument = FiscalDocument_BR::findByAccessKey(retailFiscalDocumentCancel.AccessKey);
2491 #
2492 # if (fiscalDocument)
2493 # {
2494 # if (fiscalDocument.Status == FiscalDocumentStatus_BR::Approved)
2495 # {
2496 # // If there is a linked electronic fiscal document and it's not canceled (posted at another statement), then we proceed with cancelling it.
2497 # retailFiscalDocumentPost = this.getFiscalDocPostWithoutCustInvJour_BR();
2498 # retailFiscalDocumentPost.cancel(retailFiscalDocumentCancel);
2499 # }
2500 # // Else the linked electronic fiscal document was already canceled during its own posting.
2501 # }
2502 # // Else the linked electronic fiscal document will yet be posted (guaranteed by our validations during the calculate)
2503 #
2504 # documentFound = true;
2505 # }
2506 #
2507 # return documentFound;
2508 #}
2509 #// </GBR>
2510 ENDSOURCE
2511 SOURCE #postPayment
2512 #/// <summary>
2513 #/// Post the payment transactions.
2514 #/// </summary>
2515 #/// <remarks>
2516 #/// Post the difference amount, bank drop, safe drop, card Fee and Tenders.
2517 #/// </remarks>
2518 #void postPayment()
2519 #{
2520 # #define.TotalPayment(0)
2521 # #define.BankdropPayment(1)
2522 # #define.SafeDropPayment(2)
2523 # #define.TenderDeclaration(3)
2524 # #define.CardFeePayment(4)
2525 # #define.EmptyCardTypeId("")
2526 #
2527 # Map paymentTransMap;
2528 # Map lastTransDateMap;
2529 # RetailStatementPaymentJournal rboStatementPaymentJournal;
2530 #
2531 # #Retail
2532 #
2533 # LedgerDimensionAccount getOffsetLedgerAccount(RetailLedgerBank _accountType, LedgerDimensionDefaultAccount _ledgerDimension, DimensionDefault _defaultDimension)
2534 # {
2535 # LedgerDimensionAccount ledgerDimension = _ledgerdimension;
2536 # ;
2537 #
2538 # switch(_accountType)
2539 # {
2540 # case RetailLedgerBank::Ledger:
2541 # ledgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(_ledgerDimension, _defaultDimension);
2542 # break;
2543 # case RetailLedgerBank::Bank:
2544 # ledgerDimension = _ledgerDimension;
2545 # break;
2546 # // <GEERU>
2547 # case RetailLedgerBank::RCash:
2548 # ledgerDimension = _ledgerdimension;
2549 # break;
2550 # // <GEERU>
2551 # }
2552 #
2553 # return ledgerDimension;
2554 # }
2555 #
2556 # void updateTenderInfo(container _key, AmountCur _amount)
2557 # {
2558 # AmountCur amountCur;
2559 # ;
2560 #
2561 # if (_amount)
2562 # {
2563 # if (paymentTransMap.exists(_key))
2564 # {
2565 # amountCur = paymentTransMap.lookup(_key);
2566 # paymentTransMap.remove(_key);
2567 # }
2568 # amountCur += _amount;
2569 # paymentTransMap.insert(_key, amountCur);
2570 # }
2571 # }
2572 #
2573 # void insertLastTransDate(container _key, TransDate _transDate)
2574 # {
2575 # TransDate lastTransDate;
2576 # AmountCur amountCur;
2577 # ;
2578 #
2579 # if (lastTransDateMap.exists(_key))
2580 # {
2581 # [lastTransDate, amountCur] = lastTransDateMap.lookup(_key);
2582 # if (lastTransDate < _transDate)
2583 # {
2584 # lastTransDateMap.remove(_key);
2585 # lastTransDateMap.insert(_key, [_transDate, 0]);
2586 # }
2587 # }
2588 # else
2589 # {
2590 # lastTransDateMap.insert(_key, [_transDate, 0]);
2591 # }
2592 # }
2593 #
2594 # void postPaymentLedgerTrans(RetailTenderTypeId _tenderType,
2595 # RetailCardTypeId _cardTypeId,
2596 # CurrencyCode _currencyCode,
2597 # TransDate _transDate)
2598 # {
2599 # RetailStoreTenderTypeTable storeTenderTypeTable;
2600 # RetailStoreTenderTypeCardTable storeTenderTypeCardTable;
2601 # RetailStatementLine statementLine;
2602 # RetailTransactionBankedTenderTrans transactionBankedTenderTrans;
2603 # RetailTransactionSafeTenderTrans transactionSafeTenderTrans;
2604 # DimensionDefault differenceAccount;
2605 # RetailAccountType accountType;
2606 # DimensionDynamicDefaultAccount ledgerDimension;
2607 # AmountCur totalPayment, bankDropAmountCur, safeDropAmountCur, countedAmountCur, differenceAmountCur, accumulatedTenderDeclaration;
2608 # Boolean countingRequired;
2609 # TransDate lastTransDate;
2610 # // <GEERU>
2611 # DimensionDefault defaultDimension;
2612 # amountCur tenderFlowAmountCur;
2613 # // </GEERU>
2614 # str paymReferenceTxt, paymDescription;
2615 # ;
2616 #
2617 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostInfo(0, 'postPaymentLedgerTrans');
2618 #
2619 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(storeTable.StoreNumber).RecId, _tenderType);
2620 # // <GEERU>
2621 # if (countryRegion_W)
2622 # {
2623 # defaultDimension = DimensionDefaultingService::serviceMergeDefaultDimensions(statementTable.DefaultDimension, storeTenderTypeTable.DefaultDimension);
2624 # }
2625 # // </GEERU>
2626 # if (storeTenderTypeTable.Function != RetailTenderFunction::Customer)
2627 # {
2628 # if (paymentTransMap.exists([_tenderType, _currencyCode, _transDate, _cardTypeId, #TotalPayment]))
2629 # {
2630 # totalPayment = any2real(paymentTransMap.lookup([_tenderType, _currencyCode, _transDate, _cardTypeId, #TotalPayment]));
2631 # }
2632 # else
2633 # {
2634 # totalPayment = 0;
2635 # }
2636 #
2637 # if (!_cardTypeId && paymentTransMap.exists([_tenderType, _currencyCode, _transDate, #EmptyCardTypeId, #BankdropPayment]))
2638 # {
2639 # bankDropAmountCur = any2real(paymentTransMap.lookup([_tenderType, _currencyCode, _transDate, #EmptyCardTypeId, #BankdropPayment]));
2640 # }
2641 # else
2642 # {
2643 # bankDropAmountCur = 0;
2644 # }
2645 #
2646 # if (!_cardTypeId && paymentTransMap.exists([_tenderType, _currencyCode, _transDate, #EmptyCardTypeId, #SafedropPayment]))
2647 # {
2648 # safeDropAmountCur = any2real(paymentTransMap.lookup([_tenderType, _currencyCode, _transDate, #EmptyCardTypeId, #SafedropPayment]));
2649 # }
2650 # else
2651 # {
2652 # safeDropAmountCur = 0;
2653 # }
2654 #
2655 # if (_cardTypeId)
2656 # {
2657 # storeTenderTypeCardTable = RetailStoreTenderTypeCardTable::find(RetailStoreTable::find(storeTable.StoreNumber).RecId, _tenderType, _cardTypeId);
2658 # if (storeTenderTypeCardTable)
2659 # {
2660 # countingRequired = storeTenderTypeCardTable.countingRequired;
2661 # }
2662 # }
2663 # else
2664 # {
2665 # if (storeTenderTypeTable)
2666 # {
2667 # countingRequired = storeTenderTypeTable.countingRequired;
2668 # }
2669 # }
2670 #
2671 # if (countingRequired)
2672 # {
2673 # if (!_cardTypeId && paymentTransMap.exists([_tenderType, _currencyCode, _transDate, #EmptyCardTypeId, #TenderDeclaration]))
2674 # {
2675 # countedAmountCur = any2real(paymentTransMap.lookup([_tenderType, _currencyCode, _transDate, #EmptyCardTypeId, #TenderDeclaration]));
2676 # }
2677 # else
2678 # {
2679 # countedAmountCur = 0;
2680 # }
2681 #
2682 # if (lastTransDateMap.exists([_tenderType, _cardTypeId, _currencyCode]))
2683 # {
2684 # [lastTransDate, accumulatedTenderDeclaration] = lastTransDateMap.lookup([_tenderType, _cardTypeId, _currencyCode]);
2685 # if (lastTransDate == _transDate)
2686 # {
2687 # select sum(countedAmount) from statementLine
2688 # where statementLine.StatementId == statementTable.StatementId
2689 # && statementLine.TenderTypeId == _tenderType
2690 # && statementLine.cardTypeId == _cardTypeId
2691 # && statementLine.currency == _currencyCode;
2692 #
2693 # countedAmountCur = statementLine.countedAmount - accumulatedTenderDeclaration;
2694 # }
2695 # else if (countedAmountCur)
2696 # {
2697 # accumulatedTenderDeclaration += countedAmountCur;
2698 # lastTransDateMap.remove([_tenderType, _cardTypeId, _currencyCode]);
2699 # lastTransDateMap.insert([_tenderType, _cardTypeId, _currencyCode], [lastTransDate, accumulatedTenderDeclaration]);
2700 # }
2701 # }
2702 #
2703 # differenceAmountCur = totalPayment - (bankDropAmountCur + safeDropAmountCur + countedAmountCur);
2704 # }
2705 # else
2706 # {
2707 # countedAmountCur = totalPayment - (bankDropAmountCur + safeDropAmountCur);
2708 # differenceAmountCur = 0;
2709 # }
2710 #
2711 # // Post payment difference
2712 # if (differenceAmountCur)
2713 # {
2714 # if (_cardTypeId)
2715 # {
2716 # differenceAccount = abs(differenceAmountCur) > storeTenderTypeCardTable.MaxNormalDifferenceAmount
2717 # ? storeTenderTypeCardTable.DiffAccBigDiffLedgerDimension
2718 # : storeTenderTypeCardTable.DifferenceAccLedgerDimension;
2719 # accountType = storeTenderTypeCardTable.accountType;
2720 # ledgerDimension = storeTenderTypeCardTable.LedgerDimension;
2721 # }
2722 # else
2723 # {
2724 # differenceAccount = abs(differenceAmountCur) > storeTenderTypeTable.MaxNormalDifferenceAmount
2725 # ? storeTenderTypeTable.DiffAccBigDiffLedgerDimension
2726 # : storeTenderTypeTable.DifferenceAccLedgerDimension;
2727 # accountType = storeTenderTypeTable.accountType;
2728 # ledgerDimension = storeTenderTypeTable.LedgerDimension;
2729 # }
2730 #
2731 # paymDescription = strfmt("@RET4163", storeTenderTypeTable.TenderTypeId);
2732 #
2733 # if (accountType == RetailLedgerBank::Bank)
2734 # {
2735 # paymReferenceTxt = strFmt("@SYP4883747", storeTable.StoreNumber);
2736 # paymDescription += '. ' + RetailStatementPost::getTenderTypeName(storeTable, _tenderType, _cardTypeId, _currencyCode) + '. ' + storeTable.StoreNumber;
2737 # }
2738 #
2739 # rboStatementPaymentJournal.createPaymentLedgerTrans(
2740 # accountType,
2741 # getOffsetLedgerAccount(accountType, ledgerDimension,
2742 # // <GEERU>
2743 # countryRegion_W ?
2744 # defaultDimension :
2745 # // </GEERU>
2746 # DimensionDefaultingService::serviceMergeDefaultDimensions(storeTable.DefaultDimension, storeTenderTypeTable.DefaultDimension)),
2747 # RetailLedgerBank::Ledger,
2748 # DimensionDefaultingService::serviceCreateLedgerDimension(differenceAccount,
2749 # // <GEERU>
2750 # countryRegion_W ?
2751 # defaultDimension :
2752 # // </GEERU>
2753 # DimensionDefaultingService::serviceMergeDefaultDimensions(storeTable.DefaultDimension, storeTenderTypeTable.DefaultDimension)),
2754 # _currencyCode,
2755 # differenceAmountCur,
2756 # _transDate,
2757 # paymDescription,
2758 # statementTable.StatementId,
2759 # _tenderType
2760 # // <GEERU>
2761 # , countryRegion_W ? defaultDimension : 0
2762 # // </GEERU>
2763 # , paymReferenceTxt
2764 # );
2765 # }
2766 #
2767 # // Post bank drop
2768 # if (bankDropAmountCur
2769 # && storeTenderTypeTable.ActiveAccount
2770 # )
2771 # {
2772 # paymReferenceTxt = strFmt("@SYP4883747", storeTable.StoreNumber);
2773 #
2774 # if (parameters.PostBankedSum)
2775 # {
2776 # paymDescription = "@SYP4883748" + RetailStatementPost::getTenderTypeName(storeTable, _tenderType, _cardTypeId, _currencyCode) + '. ' + storeTable.StoreNumber;
2777 #
2778 # rboStatementPaymentJournal.createPaymentLedgerTrans(
2779 # storeTenderTypeTable.accountType,
2780 # getOffsetLedgerAccount(storeTenderTypeTable.accountType, storeTenderTypeTable.LedgerDimension,
2781 # // <GEERU>
2782 # countryRegion_W ?
2783 # defaultDimension :
2784 # // </GEERU>
2785 # storeTenderTypeTable.DefaultDimension),
2786 # storeTenderTypeTable.BankBagAccountType,
2787 # getOffsetLedgerAccount(storeTenderTypeTable.BankBagAccountType, storeTenderTypeTable.BankBagLedgerDimension,
2788 # // <GEERU>
2789 # countryRegion_W ?
2790 # defaultDimension :
2791 # // </GEERU>
2792 # storeTenderTypeTable.DefaultDimension),
2793 # _currencyCode,
2794 # bankDropAmountCur,
2795 # _transDate,
2796 # paymDescription,
2797 # statementTable.StatementId,
2798 # _tenderType
2799 # // <GEERU>
2800 # , countryRegion_W ? defaultDimension : 0
2801 # // </GEERU>
2802 # , paymReferenceTxt
2803 # , storeTenderTypeTable.bankTransactionType
2804 # );
2805 # }
2806 # else
2807 # {
2808 # if (!countryRegion_W) // There is method postBankDropLine_RU with non-aggregated bank drop posting For RU and EE countries.
2809 # {
2810 # while select AmountCur, BankBagNo from transactionBankedTenderTrans
2811 # where transactionBankedTenderTrans.statementId == statementTable.statementId
2812 # && transactionBankedTenderTrans.transactionStatus == RetailEntryStatus::None
2813 # && transactionBankedTenderTrans.Currency == _currencyCode
2814 # && transactionBankedTenderTrans.TransDate == _transDate
2815 # && transactionBankedTenderTrans.TenderType == _tenderType
2816 # {
2817 # bankDropAmountCur = transactionBankedTenderTrans.AmountCur;
2818 #
2819 # paymDescription = strFmt("@SYP4883749", transactionBankedTenderTrans.BankBagNo) + RetailStatementPost::getTenderTypeName(storeTable, _tenderType, _cardTypeId, _currencyCode) + '. ' + storeTable.StoreNumber;
2820 #
2821 # rboStatementPaymentJournal.createPaymentLedgerTrans(
2822 # storeTenderTypeTable.accountType,
2823 # getOffsetLedgerAccount(storeTenderTypeTable.accountType, storeTenderTypeTable.LedgerDimension,
2824 # // <GEERU>
2825 # countryRegion_W ?
2826 # defaultDimension :
2827 # // </GEERU>
2828 # storeTenderTypeTable.DefaultDimension),
2829 # storeTenderTypeTable.BankBagAccountType,
2830 # getOffsetLedgerAccount(storeTenderTypeTable.BankBagAccountType, storeTenderTypeTable.BankBagLedgerDimension,
2831 # // <GEERU>
2832 # countryRegion_W ?
2833 # defaultDimension :
2834 # // </GEERU>
2835 # storeTenderTypeTable.DefaultDimension),
2836 # _currencyCode,
2837 # bankDropAmountCur,
2838 # _transDate,
2839 # paymDescription,
2840 # statementTable.StatementId,
2841 # _tenderType
2842 # // <GEERU>
2843 # , countryRegion_W ? defaultDimension : 0
2844 # // </GEERU>
2845 # , paymReferenceTxt
2846 # , storeTenderTypeTable.bankTransactionType
2847 # );
2848 # }
2849 # }
2850 # }
2851 # }
2852 #
2853 # // Post safe drop
2854 # if (safeDropAmountCur
2855 # && storeTenderTypeTable.SafeActiveAccount
2856 # )
2857 # {
2858 # if (storeTenderTypeTable.safeAccountType == RetailLedgerBank::Bank)
2859 # {
2860 # paymReferenceTxt = strFmt("@SYP4883747", storeTable.StoreNumber);
2861 # }
2862 #
2863 # paymDescription = "@SYP4883750" + RetailStatementPost::getTenderTypeName(storeTable, _tenderType, _cardTypeId, _currencyCode) + '. ' + storeTable.StoreNumber;
2864 #
2865 # if(parameters.PostSafeSum)
2866 # {
2867 # rboStatementPaymentJournal.createPaymentLedgerTrans(
2868 # storeTenderTypeTable.accountType,
2869 # getOffsetLedgerAccount(storeTenderTypeTable.accountType , storeTenderTypeTable.LedgerDimension,
2870 # // <GEERU>
2871 # countryRegion_W ?
2872 # defaultDimension :
2873 # // </GEERU>
2874 # storeTenderTypeTable.DefaultDimension),
2875 # storeTenderTypeTable.safeAccountType,
2876 # getOffsetLedgerAccount(storeTenderTypeTable.safeAccountType, storeTenderTypeTable.SafeAccLedgerDimension,
2877 # // <GEERU>
2878 # countryRegion_W ?
2879 # defaultDimension :
2880 # // </GEERU>
2881 # storeTenderTypeTable.DefaultDimension),
2882 # _currencyCode,
2883 # safeDropAmountCur,
2884 # _transDate,
2885 # paymDescription,
2886 # statementTable.StatementId,
2887 # _tenderType
2888 # // <GEERU>
2889 # , countryRegion_W ? defaultDimension : 0
2890 # // </GEERU>
2891 # , paymReferenceTxt
2892 # );
2893 # }
2894 # else
2895 # {
2896 # if (!countryRegion_W) // There is method postSafeDropLine_RU with non-aggregated safe drop posting for RU and EE countries.
2897 # {
2898 # while select AmountCur from transactionSafeTenderTrans
2899 # where transactionSafeTenderTrans.statementId == statementTable.statementId
2900 # && transactionSafeTenderTrans.transactionStatus == RetailEntryStatus::None
2901 # && transactionSafeTenderTrans.Currency == _currencyCode
2902 # && transactionSafeTenderTrans.TransDate == _transDate
2903 # && transactionSafeTenderTrans.TenderType == _tenderType
2904 # {
2905 # safeDropAmountCur = transactionSafeTenderTrans.AmountCur;
2906 #
2907 # rboStatementPaymentJournal.createPaymentLedgerTrans(
2908 # storeTenderTypeTable.accountType,
2909 # getOffsetLedgerAccount(storeTenderTypeTable.accountType , storeTenderTypeTable.LedgerDimension,
2910 # // <GEERU>
2911 # countryRegion_W ?
2912 # defaultDimension :
2913 # // </GEERU>
2914 # storeTenderTypeTable.DefaultDimension),
2915 # storeTenderTypeTable.safeAccountType,
2916 # getOffsetLedgerAccount(storeTenderTypeTable.safeAccountType, storeTenderTypeTable.SafeAccLedgerDimension,
2917 # // <GEERU>
2918 # countryRegion_W ?
2919 # defaultDimension :
2920 # // </GEERU>
2921 # storeTenderTypeTable.DefaultDimension),
2922 # _currencyCode,
2923 # safeDropAmountCur,
2924 # _transDate,
2925 # paymDescription,
2926 # statementTable.StatementId,
2927 # _tenderType
2928 # // <GEERU>
2929 # , countryRegion_W ? defaultDimension : 0
2930 # // </GEERU>
2931 # , paymReferenceTxt
2932 # );
2933 # }
2934 # }
2935 # }
2936 #
2937 # }
2938 #
2939 # rboStatementPaymentJournal.postLedgerJournal();
2940 # // <GEERU>
2941 # rboStatementPaymentJournal.postLedgerJournal(LedgerJournalType::RCash);
2942 # // </GEERU>
2943 # }
2944 # }
2945 #
2946 # void postCardFee(RetailTenderTypeId _tenderType,
2947 # RetailCardTypeId _cardTypeId,
2948 # CurrencyCode _currencyCode,
2949 # TransDate _transDate,
2950 # AmountCur _amountCur)
2951 # {
2952 # RetailStoreTenderTypeTable storeTenderTypeTable;
2953 # RetailStoreTenderTypeCardTable storeTenderTypeCardTable;
2954 # DimensionDefault ledgerAccount, offsetAccount;
2955 # // <GEERU>
2956 # DimensionDefault defaultDimension;
2957 # // </GEERU>
2958 # ;
2959 #
2960 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostInfo(0, 'postCardFee');
2961 #
2962 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(storeTable.StoreNumber).RecId, _tenderType);
2963 # // <GEERU>
2964 # if (countryRegion_W)
2965 # {
2966 # defaultDimension = DimensionDefaultingService::serviceMergeDefaultDimensions(statementTable.DefaultDimension, storeTenderTypeTable.DefaultDimension);
2967 # }
2968 # // </GEERU>
2969 # if (_amountCur && storeTenderTypeTable.Function == RetailTenderFunction::Card)
2970 # {
2971 # storeTenderTypeCardTable = RetailStoreTenderTypeCardTable::find(RetailStoreTable::find(storeTable.StoreNumber).RecId, _tenderType, _cardTypeId);
2972 #
2973 # if (storeTenderTypeCardTable)
2974 # {
2975 # ledgerAccount = storeTenderTypeCardTable.CardFeeLedgerDimension;
2976 # offsetAccount = storeTenderTypeCardTable.CardFeeOffsetLedgerDimension;
2977 #
2978 # if (ledgerAccount && offsetAccount && ledgerAccount != offsetAccount)
2979 # {
2980 # rboStatementPaymentJournal.createPaymentLedgerTrans(
2981 # storeTenderTypeCardTable.cardFeeAccountType,
2982 # getOffsetLedgerAccount(
2983 # storeTenderTypeCardTable.cardFeeAccountType,
2984 # ledgerAccount,
2985 # // <GEERU>
2986 # countryRegion_W ?
2987 # defaultDimension :
2988 # // </GEERU>
2989 # storeTenderTypeTable.DefaultDimension),
2990 # storeTenderTypeCardTable.cardFeeOffsetAccountType,
2991 # getOffsetLedgerAccount(
2992 # storeTenderTypeCardTable.cardFeeOffsetAccountType,
2993 # offsetAccount,
2994 # // <GEERU>
2995 # countryRegion_W ?
2996 # defaultDimension :
2997 # // </GEERU>
2998 # storeTenderTypeTable.DefaultDimension),
2999 # _currencyCode,
3000 # _amountCur,
3001 # _transDate,
3002 # "@RET4331"+" - "+storeTenderTypeCardTable.tenderTypeId,
3003 # statementTable.StatementId,
3004 # _tenderType
3005 # // <GEERU>
3006 # , countryRegion_W ? defaultDimension : 0
3007 # // </GEERU>
3008 # );
3009 #
3010 # rboStatementPaymentJournal.postLedgerJournal();
3011 # }
3012 # }
3013 # }
3014 # }
3015 #
3016 # void postTenders()
3017 # {
3018 # RetailStatementLine statementLine;
3019 # CurrencyCode currencyCode;
3020 # LedgerAccount differenceAccount;
3021 # RetailStoreTenderTypeCardTable storeTenderTypeCardTable;
3022 #
3023 # MapIterator paymentsIterator;
3024 # TransDate transDate, lastTransDate;
3025 # RetailCardTypeId cardTypeId;
3026 # AmountCur totalPayment, cardFeeAmount;
3027 # RetailTenderTypeId tenderType;
3028 # AmountCur totalTenderDeclaration;
3029 # int paymentType;
3030 #
3031 # MapIterator lastTransDateIterator;
3032 # ;
3033 #
3034 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostInfo(0, 'postTenders');
3035 #
3036 # paymentsIterator = new MapIterator(paymentTransMap);
3037 #
3038 # while (paymentsIterator.more())
3039 # {
3040 # [tenderType, currencyCode, transDate, cardTypeId, paymentType] = paymentsIterator.key();
3041 #
3042 # if (paymentType == #TotalPayment)
3043 # {
3044 # if (lastTransDateMap.exists([tenderType, cardTypeId, currencyCode]))
3045 # {
3046 # [lastTransDate, totalTenderDeclaration] = lastTransDateMap.lookup([tenderType, cardTypeId, currencyCode]);
3047 # if (lastTransDate != transDate)
3048 # {
3049 # postPaymentLedgerTrans(tenderType,
3050 # cardTypeId,
3051 # currencyCode,
3052 # transDate);
3053 # }
3054 # }
3055 # }
3056 # else if (paymentType == #CardFeePayment)
3057 # {
3058 # cardFeeAmount = paymentsIterator.value();
3059 # postCardFee(tenderType, cardTypeId, currencyCode, transDate, cardFeeAmount);
3060 # }
3061 #
3062 # paymentsIterator.next();
3063 # }
3064 #
3065 # // Post payment of the last trans date in the statement,
3066 # lastTransDateIterator = new MapIterator(lastTransDateMap);
3067 # while (lastTransDateIterator.more())
3068 # {
3069 # [tenderType, cardTypeId, currencyCode] = lastTransDateIterator.key();
3070 # [lastTransDate, totalTenderDeclaration] = lastTransDateMap.lookup([tenderType, cardTypeId, currencyCode]);
3071 # postPaymentLedgerTrans(tenderType,
3072 # cardTypeId,
3073 # currencyCode,
3074 # lastTransDate);
3075 #
3076 # lastTransDateIterator.next();
3077 # }
3078 # }
3079 #
3080 # // Posts Safe Tender drop to the ledger/bank
3081 # void prepareSafeTenderDropInfo()
3082 # {
3083 # RetailTransactionSafeTenderTrans transactionSafeTenderTrans;
3084 # RetailStoreTenderTypeTable storeTenderTypeTable;
3085 #
3086 # AmountCur amountCur;
3087 #
3088 # CurrencyCode currencyCode;
3089 # ;
3090 #
3091 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostInfo(0, 'prepareSafeTenderDropInfo');
3092 #
3093 # while select sum(AmountCur),sum(AmountTendered),sum(AmountMST), TenderType, Currency, businessDate from transactionSafeTenderTrans
3094 # group by TenderType, Currency, businessDate
3095 # where transactionSafeTenderTrans.statementId == statementTable.statementId
3096 # && transactionSafeTenderTrans.transactionStatus == RetailEntryStatus::None
3097 # {
3098 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(storeTable.StoreNumber).RecId, transactionSafeTenderTrans.TenderType);
3099 #
3100 # currencyCode = transactionSafeTenderTrans.Currency ? transactionSafeTenderTrans.Currency : storeTable.Currency;
3101 #
3102 # updateTenderInfo([transactionSafeTenderTrans.TenderType, transactionSafeTenderTrans.Currency, transactionSafeTenderTrans.businessDate, #EmptyCardTypeId, #SafeDropPayment],
3103 # transactionSafeTenderTrans.AmountCur);
3104 #
3105 # insertLastTransDate([transactionSafeTenderTrans.TenderType, #EmptyCardTypeId, transactionSafeTenderTrans.Currency],
3106 # transactionSafeTenderTrans.businessDate);
3107 # }
3108 # }
3109 #
3110 # void prepareBankTenderDropInfo()
3111 # {
3112 # RetailTransactionBankedTenderTrans transactionBankedTenderTrans;
3113 # RetailStoreTenderTypeTable storeTenderTypeTable;
3114 #
3115 # AmountCur amountCur;
3116 #
3117 # CurrencyCode currencyCode;
3118 # ;
3119 #
3120 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostInfo(0, 'prepareBankTenderDropInfo');
3121 #
3122 # while select sum(AmountCur),sum(AmountTendered),sum(AmountMST), Currency, businessDate from transactionBankedTenderTrans
3123 # group by TenderType, Currency, businessDate
3124 # where transactionBankedTenderTrans.statementId == statementTable.statementId
3125 # && transactionBankedTenderTrans.transactionStatus == RetailEntryStatus::None
3126 # {
3127 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(storeTable.StoreNumber).RecId, transactionBankedTenderTrans.TenderType);
3128 #
3129 # currencyCode = transactionBankedTenderTrans.Currency ? transactionBankedTenderTrans.Currency : storeTable.Currency;
3130 #
3131 # updateTenderInfo([transactionBankedTenderTrans.TenderType, transactionBankedTenderTrans.Currency, transactionBankedTenderTrans.businessDate, #EmptyCardTypeId, #BankDropPayment],
3132 # transactionBankedTenderTrans.AmountCur);
3133 #
3134 # insertLastTransDate([transactionBankedTenderTrans.TenderType, #EmptyCardTypeId, transactionBankedTenderTrans.Currency],
3135 # transactionBankedTenderTrans.businessDate);
3136 # }
3137 # }
3138 #
3139 # void preparePaymentInfo()
3140 # {
3141 # RetailTransactionPaymentTrans transactionPaymentTrans;
3142 # RetailStoreTenderTypeTable storeTenderTypeTable;
3143 # TransDate lastTransDate;
3144 # AmountCur amountCur;
3145 # ;
3146 #
3147 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostInfo(0, 'preparePaymentInfo');
3148 #
3149 # while select businessDate, tenderType, cardTypeId, currency, sum(amountMST), sum(amountTendered), sum(amountCur)
3150 # from transactionPaymentTrans
3151 # index hint statementTenderCardCurIdx
3152 # group by store, businessDate, tenderType, cardTypeId, currency
3153 # where transactionPaymentTrans.statementId == statementTable.statementId
3154 # && transactionPaymentTrans.transactionStatus == RetailEntryStatus::None
3155 # // <GEERU>
3156 # && (!countryRegion_RU || transactionPaymentTrans.CashDocId_RU == '')
3157 # // </GEERU>
3158 # {
3159 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(transactionPaymentTrans.store).RecId, transactionPaymentTrans.tenderType);
3160 #
3161 # if (storeTenderTypeTable.Function != RetailTenderFunction::Customer)
3162 # {
3163 # updateTenderInfo([transactionPaymentTrans.TenderType, transactionPaymentTrans.Currency, transactionPaymentTrans.businessDate, transactionPaymentTrans.CardTypeId, #TotalPayment],
3164 # transactionPaymentTrans.AmountCur);
3165 #
3166 # insertLastTransDate([transactionPaymentTrans.TenderType, transactionPaymentTrans.cardTypeId, transactionPaymentTrans.Currency],
3167 # transactionPaymentTrans.businessDate);
3168 #
3169 # updateTenderInfo([transactionPaymentTrans.TenderType, transactionPaymentTrans.Currency, transactionPaymentTrans.businessDate, transactionPaymentTrans.cardTypeId, #CardFeePayment],
3170 # transactionPaymentTrans.calcCardFeeAmount());
3171 # }
3172 # }
3173 # }
3174 #
3175 # void prepareTenderDeclarationInfo()
3176 # {
3177 # RetailStoreTenderTypeTable storeTenderTypeTable;
3178 # RetailTransactionTenderDeclarationTrans tenderDeclarationTrans;
3179 #
3180 # AmountCur amountCur;
3181 # ;
3182 #
3183 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostInfo(0, 'prepareTenderDeclarationInfo');
3184 #
3185 # while select businessDate, tenderType, cardId, currency, sum(amountMST), sum(amountTendered), sum(amountCur)
3186 # from tenderDeclarationTrans
3187 # group by businessDate, tenderType, cardId, currency
3188 # where tenderDeclarationTrans.statementId == statementTable.statementId
3189 # && tenderDeclarationTrans.transactionStatus == RetailEntryStatus::None
3190 # {
3191 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(statementTable.storeId).RecId, tenderDeclarationTrans.tenderType);
3192 #
3193 # if (storeTenderTypeTable.Function != RetailTenderFunction::Customer)
3194 # {
3195 # updateTenderInfo([tenderDeclarationTrans.TenderType, tenderDeclarationTrans.Currency, tenderDeclarationTrans.businessDate, tenderDeclarationTrans.cardId, #TenderDeclaration],
3196 # tenderDeclarationTrans.AmountCur);
3197 # insertLastTransDate([tenderDeclarationTrans.TenderType, tenderDeclarationTrans.cardId, tenderDeclarationTrans.Currency], tenderDeclarationTrans.businessDate);
3198 # }
3199 # }
3200 # }
3201 #
3202 # // <GEERU>
3203 # // Set posted general journal headers containing disbursement slip lines with a reference to the current statement.
3204 # void setDisbursementSlipJournalsStatementRefs()
3205 # {
3206 # RetailTransactionPaymentTrans disbursementSlipPaymentTrans;
3207 # LedgerJournalTrans_RCash ledgerJournalTransRCash;
3208 # LedgerJournalTrans ledgerJournalTrans;
3209 # LedgerJournalTable ledgerJournalTable;
3210 # ;
3211 # ledgerJournalTable.skipDatabaseLog(true);
3212 # ledgerJournalTable.skipDataMethods(true);
3213 # ledgerJournalTable.skipDeleteActions(true);
3214 # ttsBegin;
3215 # update_recordSet ledgerJournalTable
3216 # setting RetailStatementId = statementTable.statementId
3217 # where ledgerJournalTable.Posted == NoYes::Yes
3218 # && ledgerJournalTable.RetailStatementId == ''
3219 # exists join ledgerJournalTrans
3220 # where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
3221 # exists join ledgerJournalTransRCash
3222 # where ledgerJournalTransRCash.RefRecId == ledgerJournalTrans.RecId
3223 # exists join disbursementSlipPaymentTrans
3224 # where disbursementSlipPaymentTrans.CashDocId_RU == ledgerJournalTransRCash.CashDocId
3225 # && disbursementSlipPaymentTrans.CashDocId_RU != ''
3226 # && disbursementSlipPaymentTrans.statementId == statementTable.statementId;
3227 # ttsCommit;
3228 # }
3229 # // </GEERU>
3230 # ;
3231 #
3232 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepStart(0, 'postPayment');
3233 #
3234 # rboStatementPaymentJournal = new RetailStatementPaymentJournal(statementTable);
3235 # rboStatementPaymentJournal.postPaymentJournal();
3236 #
3237 # // <GEERU>
3238 # if (countryRegion_W)
3239 # {
3240 # rboStatementPaymentJournal = new RetailStatementPaymentJournal(statementTable, LedgerJournalType::Daily);
3241 # }
3242 # // </GEERU>
3243 #
3244 # // Begin of main body of postPayment method.
3245 #
3246 # paymentTransMap = new Map(Types::Container, Types::Real);
3247 # lastTransDateMap = new Map(Types::Container, Types::Container);
3248 #
3249 # // prepare total payment information by reading from RetailTransactionPaymentTrans table,
3250 # // it saves #TotalPayment and #CardFeePayment information in the paymentTransMap.
3251 # preparePaymentInfo();
3252 #
3253 # // prepare tender declaration information by reading RBOTenderDeclarationTrans table, saved in paymentTransMap as #TenderDeclaration items.
3254 # // upon posting, the information is used as counted amount if the tender declaration isn't made on the posting date and counting is required.
3255 # prepareTenderDeclarationInfo();
3256 #
3257 # // prepare bank drop information, post a ledger trans if bank drop aggregation isn't configured. and calculates sum of bank drop information saved in paymentTransMap
3258 # // as #BankDropPayment entries.
3259 # prepareBankTenderDropInfo();
3260 #
3261 # // prepare bank drop information, post a ledger trans if safe drop aggregation isn't configured. and calculates sum of safe drop information saved in paymentTransMap
3262 # // as #SafeDropPayment entries.
3263 # prepareSafeTenderDropInfo();
3264 #
3265 # // <GEERU>
3266 # if (countryRegion_W && parameters.AggregateTenderFlow_RU)
3267 # {
3268 # this.postTenderFlowLine_Agregated_RU(rboStatementPaymentJournal);
3269 # }
3270 #
3271 # if (countryRegion_W && parameters.AggregateIncomeExpense_RU)
3272 # {
3273 # this.postIncomeExpenseLine_Agregated_RU(rboStatementPaymentJournal);
3274 # }
3275 # // </GEERU>
3276 #
3277 # // iterate each item in paymentTransMap and post the payment ledger trans. and accumulate counted amount for each trans date except the last trans date in the statement.
3278 # // post the last trans date payment trans after the counted amount is calculated for all trans date and calculate counted amount of the last day based on the manager input.
3279 # postTenders();
3280 #
3281 # // <GEERU>
3282 # if (countryRegion_RU)
3283 # {
3284 # setDisbursementSlipJournalsStatementRefs();
3285 # }
3286 # // </GEERU>
3287 #
3288 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepEnd(0, 'postPayment');
3289 #}
3290 ENDSOURCE
3291 SOURCE #postRetailFiscalDocument_BR
3292 #/// <summary>
3293 #/// Posts a consumer retail fiscal document (model 65) originally created at the POS.
3294 #/// </summary>
3295 #/// <param name="_transactionTable">
3296 #/// A <c>RetailTransactionTable</c> record being processed by the statement.
3297 #/// </param>
3298 #/// <returns>
3299 #/// True if a fiscal document was found related to the Sales transaction; otherwise, false.
3300 #/// </returns>
3301 #// <GBR>
3302 #protected boolean postRetailFiscalDocument_BR(RetailTransactionTable _transactionTable)
3303 #{
3304 # boolean documentFound = false;
3305 # CustInvoiceJour custInvoiceJour;
3306 # RetailTransactionTable transactionTableCancel;
3307 # RetailTransactionTable transactionTableReturn;
3308 # RetailFiscalDocumentPost_BR retailFiscalDocumentPost;
3309 # RetailFiscalDocument_BR retailFiscalDocument;
3310 # RetailFiscalDocumentReference_BR retailFiscalDocumentReference;
3311 # RetailEFDocumentToBeInquired_BR efDocumentToBeInquired;
3312 #
3313 # retailFiscalDocument = RetailFiscalDocument_BR::findByRetailTransaction(_transactionTable);
3314 #
3315 # while select retailFiscalDocument
3316 # where retailFiscalDocument.transactionId == _transactionTable.transactionId
3317 # && retailFiscalDocument.terminal == _transactionTable.terminal
3318 # && retailFiscalDocument.store == _transactionTable.store
3319 # && retailFiscalDocument.Channel == _transactionTable.Channel
3320 # {
3321 # if (retailFiscalDocument.Status == FiscalDocumentStatus_BR::Created && retailFiscalDocument.MessageStatus == EFDocMessageStatus_BR::Sent)
3322 # {
3323 # if (retailFiscalDocument.isElectronicConsumerFiscalDoc())
3324 # {
3325 # efDocumentToBeInquired.Status = RetailEFDocumentToBeInquiredStatus_BR::Unknown;
3326 # efDocumentToBeInquired.RetailFiscalDocument_BR = retailFiscalDocument.RecId;
3327 # efDocumentToBeInquired.insert();
3328 # }
3329 # }
3330 # else
3331 # {
3332 # select custInvoiceJour
3333 # where custInvoiceJour.InvoiceId == _transactionTable.invoiceId
3334 # && custInvoiceJour.InvoiceDate == _transactionTable.businessDate;
3335 #
3336 # retailFiscalDocumentPost = this.getRetailFiscalDocumentPost_BR(custInvoiceJour);
3337 # retailFiscalDocumentPost.run(retailFiscalDocument);
3338 #
3339 # transactionTableCancel = this.getFDocCancelRetailTransaction_BR(_transactionTable.statementId, retailFiscalDocument.AccessKey);
3340 #
3341 # if (transactionTableCancel)
3342 # {
3343 # this.postRetailFiscalDocumentCanceled_BR(transactionTableCancel);
3344 # }
3345 #
3346 # while select transactionTableReturn
3347 # exists join retailFiscalDocumentReference
3348 # where transactionTableReturn.transactionId == retailFiscalDocumentReference.transactionId
3349 # && transactionTableReturn.store == retailFiscalDocumentReference.store
3350 # && transactionTableReturn.terminal == retailFiscalDocumentReference.terminal
3351 # && transactionTableReturn.statementId == _transactionTable.statementId
3352 # && retailFiscalDocumentReference.RefAccessKey == retailFiscalDocument.AccessKey
3353 # {
3354 # this.postRetailReturnFiscalDocument_BR(transactionTableReturn, true);
3355 # }
3356 #
3357 # documentFound = true;
3358 # }
3359 # }
3360 #
3361 # return documentFound;
3362 #}
3363 #// </GBR>
3364 ENDSOURCE
3365 SOURCE #postRetailFiscalDocumentCanceled_BR
3366 #/// <summary>
3367 #/// Posts the canceling of a consumer retail fiscal document (model 65) originally created at the POS.
3368 #/// </summary>
3369 #/// <param name="_transactionTable">
3370 #/// A <c>RetailTransactionTable</c> record being processed by the statement.
3371 #/// </param>
3372 #/// <returns>
3373 #/// True if a fiscal document was found related to the Sales transaction; otherwise, false.
3374 #/// </returns>
3375 #/// <remarks>
3376 #/// It could happen that this cancel method is called before the NFC-e is posted.
3377 #/// </remarks>
3378 #// <GBR>
3379 #protected boolean postRetailFiscalDocumentCanceled_BR(RetailTransactionTable _transactionTable)
3380 #{
3381 # boolean documentFound = false;
3382 # CustInvoiceJour custInvoiceJour;
3383 # RetailFiscalDocumentPost_BR retailFiscalDocumentPost;
3384 # RetailFiscalDocumentCancel_BR retailFiscalDocumentCancel;
3385 # FiscalDocument_BR fiscalDocument;
3386 #
3387 # retailFiscalDocumentCancel = RetailFiscalDocumentCancel_BR::findByRetailTransaction(_transactionTable);
3388 #
3389 # if (retailFiscalDocumentCancel)
3390 # {
3391 # fiscalDocument = FiscalDocument_BR::findByAccessKey(retailFiscalDocumentCancel.AccessKey);
3392 #
3393 # if (fiscalDocument)
3394 # {
3395 # if (fiscalDocument.Status == FiscalDocumentStatus_BR::Approved)
3396 # {
3397 # // If there is a NFC-e and it's not canceled (posted at another statement), then we proceed with cancelling it.
3398 #
3399 # select custInvoiceJour
3400 # where custInvoiceJour.InvoiceId == _transactionTable.invoiceId
3401 # && custInvoiceJour.InvoiceDate == _transactionTable.businessDate;
3402 #
3403 # retailFiscalDocumentPost = this.getRetailFiscalDocumentPost_BR(custInvoiceJour);
3404 # retailFiscalDocumentPost.cancel(retailFiscalDocumentCancel);
3405 # }
3406 # // Else the NFC-e was already canceled during its own posting.
3407 # }
3408 # // Else the NFC-e will yet be posted (guaranteed by our validations during the calculate)
3409 #
3410 # documentFound = true;
3411 # }
3412 #
3413 # return documentFound;
3414 #}
3415 #// </GBR>
3416 ENDSOURCE
3417 SOURCE #postRetailReturnFiscalDocument_BR
3418 #/// <summary>
3419 #/// Posts a retail return fiscal document (model 55).
3420 #/// </summary>
3421 #/// <param name="_transactionTable">
3422 #/// A <c>RetailTransactionTable</c> record being processed by the statement.
3423 #/// </param>
3424 #/// <param name="_calledFromPostRetailFiscalDocument">
3425 #/// A boolean value to determine if the method is being called by the psotRetailFiscalDocument_BR method.
3426 #/// </param>
3427 #/// <returns>
3428 #/// True if a fiscal document was found related to the Sales transaction; otherwise, false.
3429 #/// </returns>
3430 #// <GBR>
3431 #protected boolean postRetailReturnFiscalDocument_BR(RetailTransactionTable _transactionTable, boolean _calledFromPostRetailFiscalDocument = false)
3432 #{
3433 # boolean documentFound = false;
3434 # CustInvoiceJour custInvoiceJour;
3435 # RetailFiscalDocumentPost_BR retailFiscalDocumentPost;
3436 # RetailFiscalDocument_BR retailFiscalDocument;
3437 # RetailFiscalDocumentReference_BR retailFiscalDocumentReference;
3438 # FiscalDocument_BR fiscalDocument;
3439 #
3440 # void post()
3441 # {
3442 # select custInvoiceJour
3443 # where custInvoiceJour.InvoiceId == _transactionTable.invoiceId
3444 # && custInvoiceJour.InvoiceDate == _transactionTable.businessDate;
3445 #
3446 # retailFiscalDocumentPost = this.getRetailFiscalDocumentPost_BR(custInvoiceJour);
3447 # fiscalDocument = retailFiscalDocumentPost.run(retailFiscalDocument);
3448 #
3449 # documentFound = true;
3450 # }
3451 #
3452 # retailFiscalDocument = RetailFiscalDocument_BR::findByRetailTransaction(_transactionTable);
3453 #
3454 # if (retailFiscalDocument)
3455 # {
3456 # select firstOnly RefAccessKey from retailFiscalDocumentReference
3457 # where retailFiscalDocumentReference.store == retailFiscalDocument.store
3458 # && retailFiscalDocumentReference.transactionId == retailFiscalDocument.transactionId
3459 # && retailFiscalDocumentReference.Channel == retailFiscalDocument.Channel
3460 # && retailFiscalDocumentReference.terminal == retailFiscalDocument.terminal;
3461 #
3462 # if (retailFiscalDocumentReference.RefAccessKey) // Fiscal document referenced
3463 # {
3464 # // If the original transaction is not in the same statement, we post it here otherwise it will be posted in the original transaction.
3465 # // The referenced fiscal document is being validated during the calculate
3466 # if (_calledFromPostRetailFiscalDocument || !this.getOriginalFDocRetailTransaction_BR(_transactionTable.statementId, retailFiscalDocumentReference.RefAccessKey))
3467 # {
3468 # post();
3469 # }
3470 # }
3471 # else // Fiscal receipt referenced
3472 # {
3473 # post();
3474 # }
3475 # }
3476 #
3477 # return documentFound;
3478 #}
3479 #// </GBR>
3480 ENDSOURCE
3481 SOURCE #postRetailSpecific
3482 #/// <summary>
3483 #/// Post the sales trans.
3484 #/// </summary>
3485 #/// <remarks>
3486 #/// Posts the payment transactions, discounts. Mark the transactions for post and inserts the record in the StatementJour and StatementLines.
3487 #/// </remarks>
3488 #/// <exception cref="Exception::UpdateConflictNotRecovered">
3489 #/// Cannot update if any other user is trying update simultaneously. The update conflict cannot be recovered.
3490 #/// </exception>
3491 #/// <exception cref="Exception::UpdateConflict">
3492 #/// Update conflict as any other user is trying to update the record at the same time.
3493 #/// </exception>
3494 #public void postRetailSpecific()
3495 #{
3496 # #OccRetryCount
3497 # RetailTransactionTable transactionTable;
3498 # RetailTransactionSalesTrans transactionSalesTrans;
3499 # RetailTransactionDiscountTrans transactionDiscountTrans;
3500 # RetailTransactionSalesTransReserveHist salesTransReserveHistory;
3501 # int irecordCounter = 1;
3502 # str documentNumber;
3503 # // <GBR>
3504 # boolean isBrazilEnabled = BrazilParameters::isEnabled();
3505 # // </GBR>
3506 # // <GEERU>
3507 # RetailStatementPaymentJournal transactionStatementPaymentJournal;
3508 # // </GEERU>
3509 # #Retail
3510 #
3511 # // <GEERU>
3512 # void createTransactionStatementPaymentJournal_RU()
3513 # {
3514 # if (countryRegion_W && !transactionStatementPaymentJournal)
3515 # {
3516 # transactionStatementPaymentJournal = new RetailStatementPaymentJournal(statementTable, LedgerJournalType::Daily);
3517 # }
3518 # }
3519 # // </GEERU>
3520 # ;
3521 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepStart(0, 'postRetailSpecific');
3522 #
3523 # RetailTracer::Info('Posting', 'RetailStatementPost::postRetailSpecific()', 'Posting retail specific data %1 start', statementTable.statementId);
3524 #
3525 # if (this.parmStatementId())
3526 # {
3527 # // Running inside a batch framework task, so initialize the statementTable record buffer.
3528 # statementTable = RetailStatementTable::find(this.parmStatementId(), true);
3529 # }
3530 #
3531 # parameters = RetailParameters::find();
3532 #
3533 # storeTable = RetailStoreTable::find(statementTable.StoreId);
3534 #
3535 # #AVIFiles
3536 #
3537 # operationProgress = SysOperationProgress::newMultiBar(3, #AviTransfer, "@RET4266");
3538 #
3539 # operationProgress.setTotal(statementTable.CalculatedLines);
3540 # operationProgress.setText("@RET4266");
3541 #
3542 # try
3543 # {
3544 # ttsbegin;
3545 #
3546 # irecordCounter = 1;
3547 # ledgerVoucher = null;
3548 # voucherList = new Map(Types::Container,Types::String);
3549 #
3550 # // Fetch dimension from store if not set in statement.
3551 #
3552 # if (!statementTable.DefaultDimension)
3553 # {
3554 # statementTable.DefaultDimension = storeTable.DefaultDimension;
3555 # statementTable.doUpdate();
3556 # }
3557 #
3558 # if (parameters.aggregateBeforePosting)
3559 # {
3560 # this.postAggregatedDiscounts();
3561 # }
3562 #
3563 # //Run through all the transactions in this statement
3564 # while select forupdate transactionTable
3565 # index hint statementIdx
3566 # where transactionTable.StatementId == statementTable.StatementId &&
3567 # transactionTable.type != RetailTransactionType::Logon &&
3568 # transactionTable.type != RetailTransactionType::Logoff
3569 # && transactionTable.type != RetailTransactionType::KitDisassembly
3570 #
3571 # {
3572 # irecordCounter++;
3573 # operationProgress.setCount(irecordCounter, 1);
3574 #
3575 # if (transactionTable.EntryStatus == RetailEntryStatus::Posted && transactionTable.type != RetailTransactionType::CustomerOrder && transactionTable.type != RetailTransactionType::PendingSalesOrder)
3576 # {
3577 # error(strfmt("@RET4162", statementTable.StatementId));
3578 # }
3579 #
3580 # if (! transactionTable.Currency)
3581 # transactionTable.Currency = CompanyInfo::standardCurrency();
3582 #
3583 # documentNumber = #T + strrem(transactionTable.TransactionId, ",.");
3584 #
3585 # if (! parameters.aggregateBeforePosting)
3586 # {
3587 # while select forupdate transactionSalesTrans
3588 # where transactionSalesTrans.Store == transactionTable.Store
3589 # && transactionSalesTrans.TerminalId == transactionTable.Terminal
3590 # && transactionSalesTrans.TransactionId == transactionTable.TransactionId
3591 # && transactionSalesTrans.TransactionStatus == RetailEntryStatus::None
3592 # join transactionDiscountTrans
3593 # where transactionDiscountTrans.StoreId == transactionSalesTrans.Store
3594 # && transactionDiscountTrans.TerminalId == transactionSalesTrans.TerminalId
3595 # && transactionDiscountTrans.TransactionId == transactionSalesTrans.TransactionId
3596 # && transactionDiscountTrans.SaleLineNum == transactionSalesTrans.lineNum
3597 # {
3598 # RetailTracer::Info('Posting', 'RetailStatementPost::postRetailSpecific()',
3599 # 'Displaying field values of RetailTransactionSalesTrans. ItemId = %1, Store = %2, Terminal = %3, taxGroup = %4, TaxItemGroup = %5, DefaultDimension = %6, TransactionId = %7',
3600 # transactionSalesTrans.itemId, transactionSalesTrans.store, transactionSalesTrans.terminalId, transactionSalesTrans.taxGroup, transactionSalesTrans.TaxItemGroup, transactionSalesTrans.DefaultDimension, transactionSalesTrans.transactionId);
3601 #
3602 # RetailTracer::Info('Posting', 'RetailStatementPost::postRetailSpecific()',
3603 # 'Displaying field values of RetailTransactionDiscountTrans. PeriodicDiscountOfferId = %1, DiscountCost = %2, TransactionId = %3',
3604 # transactionDiscountTrans.PeriodicDiscountOfferId, transactionDiscountTrans.DiscountCost, transactionDiscountTrans.TransactionId);
3605 #
3606 # this.postDiscounts(documentNumber, transactionSalesTrans, transactionDiscountTrans, transactionTable.Currency, transactionTable.CustAccount);
3607 # }
3608 # }
3609 #
3610 # // Post income expense line.
3611 # if (transactionTable.incomeExpenseAmount
3612 # // <GEERU>
3613 # && (!countryRegion_W || !parameters.AggregateIncomeExpense_RU)
3614 # // <GEERU>
3615 # )
3616 # {
3617 # // <GEERU>
3618 # createTransactionStatementPaymentJournal_RU();
3619 # // </GEERU>
3620 # this.postIncomeExpenseLine(transactionTable
3621 # // <GEERU>
3622 # , transactionStatementPaymentJournal
3623 # // </GEERU>
3624 # );
3625 # }
3626 # // <GEERU>
3627 # if (countryRegion_W &&
3628 # !parameters.AggregateTenderFlow_RU &&
3629 # (transactionTable.type == RetailTransactionType::StartingAmount ||
3630 # transactionTable.type == RetailTransactionType::RemoveTender ||
3631 # transactionTable.type == RetailTransactionType::FloatEntry))
3632 # {
3633 # createTransactionStatementPaymentJournal_RU();
3634 # this.postTenderFlowLine_RU(transactionTable, transactionStatementPaymentJournal);
3635 # }
3636 #
3637 # if (countryRegion_W &&
3638 # transactionTable.type == RetailTransactionType::BankDrop &&
3639 # !parameters.postBankedSum)
3640 # {
3641 # createTransactionStatementPaymentJournal_RU();
3642 # this.postBankDropLine_RU(transactionTable, transactionStatementPaymentJournal);
3643 # }
3644 #
3645 # if (countryRegion_W &&
3646 # transactionTable.type == RetailTransactionType::SafeDrop &&
3647 # !parameters.PostSafeSum)
3648 # {
3649 # createTransactionStatementPaymentJournal_RU();
3650 # this.postSafeDropLine_RU(transactionTable, transactionStatementPaymentJournal);
3651 # }
3652 # // </GEERU>
3653 #
3654 # // <GBR>
3655 # if (isBrazilEnabled)
3656 # {
3657 # this.postBrazilSpecific_BR(transactionTable);
3658 # }
3659 # // </GBR>
3660 # }
3661 #
3662 # // <GEERU>
3663 # if (transactionStatementPaymentJournal)
3664 # {
3665 # transactionStatementPaymentJournal.postLedgerJournal();
3666 # transactionStatementPaymentJournal.postLedgerJournal(LedgerJournalType::RCash);
3667 # }
3668 # // </GEERU>
3669 #
3670 # this.linkSalesOrderVouchersToStatement();
3671 #
3672 # this.postPayment();
3673 #
3674 # if (ledgerVoucher)
3675 # {
3676 # ledgerVoucher.end();
3677 # }
3678 #
3679 # this.markTransactions(statementTable);
3680 #
3681 # RetailPosBatchTable::markAsPosted(statementTable.statementId);
3682 #
3683 # // If Retail Parameter Tax on Gift Card is set and price includesSalesTax is set then run Posting on Gift Card Sales Tax provisioning to Holding account.
3684 # if (RetailParameters::find().TaxOnGiftCards && RetailStoreTable::find(statementTable.storeId).PriceIncludesSalesTax)
3685 # {
3686 # this.postGiftCardForSalesTaxProvision();
3687 # }
3688 #
3689 # this.postCrossCompanyGiftcard();
3690 #
3691 # this.insertStatementJour(statementTable);
3692 #
3693 # // <GBR>
3694 # if (isBrazilEnabled)
3695 # {
3696 # this.concludePost_BR(statementTable);
3697 # }
3698 # // </GBR>
3699 #
3700 # this.deleteStatement(statementTable);
3701 #
3702 # // clean up the item reservation history as the sales order is created.
3703 # delete_from salesTransReserveHistory where salesTransReserveHistory.statementId == this.parmStatementId();
3704 #
3705 # ttscommit;
3706 # }
3707 # catch (Exception::Deadlock)
3708 # {
3709 # info("@SYS65063"); // Deadlock detected
3710 # retry;
3711 # }
3712 # catch (Exception::UpdateConflict)
3713 # {
3714 # if (appl.ttsLevel() == 0)
3715 # {
3716 # if (xSession::currentRetryCount() >= #RetryNum)
3717 # {
3718 # throw Exception::UpdateConflictNotRecovered;
3719 # }
3720 # else
3721 # {
3722 # info("@SYS107548"); // Update conflicts
3723 # retry;
3724 # }
3725 # }
3726 # else
3727 # {
3728 # throw Exception::UpdateConflict;
3729 # }
3730 # }
3731 #
3732 # RetailTracer::Info('Posting', 'RetailStatementPost::postRetailSpecific()', 'Posting retail specific data %1 end', statementTable.statementId);
3733 #
3734 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepEnd(0, 'postRetailSpecific');
3735 #}
3736 #
3737 ENDSOURCE
3738 SOURCE #postSafeDropLine_RU
3739 #// <GEERU>
3740 #private void postSafeDropLine_RU(RetailTransactionTable _transactionTable,
3741 # RetailStatementPaymentJournal _statementJournal)
3742 #{
3743 # RetailTransactionSafeTenderTrans transactionSafeTenderTrans;
3744 # RetailStoreTenderTypeTable storeTenderTypeTable;
3745 # LedgerDimensionAccount ledgerAccount, offsetLedgerAccount;
3746 # DimensionDefault defaultDimension;
3747 #
3748 # while select sum(AmountCur), Currency, businessDate, TenderType from transactionSafeTenderTrans
3749 # group by TenderType, Currency, businessDate
3750 # where transactionSafeTenderTrans.Store == _transactionTable.store
3751 # && transactionSafeTenderTrans.Terminal == _transactionTable.terminal
3752 # && transactionSafeTenderTrans.TransactionId == _transactionTable.transactionId
3753 # && transactionSafeTenderTrans.TransactionStatus == RetailEntryStatus::None
3754 # {
3755 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(storeTable.StoreNumber).RecId, transactionSafeTenderTrans.TenderType);
3756 # defaultDimension = DimensionDefaultingService::serviceMergeDefaultDimensions(statementTable.DefaultDimension, storeTenderTypeTable.DefaultDimension);
3757 #
3758 # ledgerAccount = storeTenderTypeTable.LedgerDimension;
3759 # offsetLedgerAccount = storeTenderTypeTable.SafeAccLedgerDimension;
3760 #
3761 # if (ledgerAccount == offsetLedgerAccount || !storeTenderTypeTable.safeActiveAccount)
3762 # continue;
3763 #
3764 # if (storeTenderTypeTable.accountType == RetailLedgerBank::Ledger)
3765 # {
3766 # ledgerAccount = DimensionDefaultingService::serviceCreateLedgerDimension(ledgerAccount, defaultDimension);
3767 # }
3768 #
3769 # if (storeTenderTypeTable.safeAccountType == RetailLedgerBank::Ledger)
3770 # {
3771 # offsetLedgerAccount = DimensionDefaultingService::serviceCreateLedgerDimension(storeTenderTypeTable.SafeAccLedgerDimension, defaultDimension);
3772 # }
3773 #
3774 # _statementJournal.createPaymentLedgerTrans(
3775 # storeTenderTypeTable.accountType,
3776 # ledgerAccount,
3777 # storeTenderTypeTable.safeAccountType,
3778 # offsetLedgerAccount,
3779 # transactionSafeTenderTrans.Currency ? transactionSafeTenderTrans.Currency : storeTable.Currency,
3780 # transactionSafeTenderTrans.AmountCur,
3781 # transactionSafeTenderTrans.businessDate,
3782 # "@RET4703" + " - " + "@RET4514" + storeTenderTypeTable.tenderTypeId,
3783 # statementTable.StatementId,
3784 # transactionSafeTenderTrans.TenderType,
3785 # defaultDimension);
3786 # }
3787 #}
3788 #// </GEERU>
3789 ENDSOURCE
3790 SOURCE #postSalesOrders
3791 #/// <summary>
3792 #/// Post sales orders.
3793 #/// </summary>
3794 #/// <remarks>
3795 #/// Post sales-orders for current statement.
3796 #/// </remarks>
3797 #public void postSalesOrders()
3798 #{
3799 # RetailStatementPostSalesOrders postSalesOrders;
3800 #
3801 # ;
3802 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepStart(0, 'postSalesOrders');
3803 #
3804 # RetailTracer::Info('Posting', 'RetailStatementPost::postSalesOrders()', 'Posting Sales Order %1 start', statementTable.statementId);
3805 #
3806 # // Post sales-orders for current statement.
3807 # postSalesOrders = new RetailStatementPostSalesOrders();
3808 # postSalesOrders.parmStatementId(statementTable.statementId);
3809 # postSalesOrders.parmInBatch(this.isInBatch());
3810 # postSalesOrders.run();
3811 #
3812 # RetailTracer::Info('Posting', 'RetailStatementPost::postSalesOrders()', 'Posting Sales Order %1 end', statementTable.statementId);
3813 #
3814 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepEnd(0, 'postSalesOrders');
3815 #}
3816 ENDSOURCE
3817 SOURCE #postTenderFlowLine_Agregated_RU
3818 #// <GEERU>
3819 #private void postTenderFlowLine_Agregated_RU(RetailStatementPaymentJournal _tenderFlowStatementJournal)
3820 #{
3821 # RetailTransactionPaymentTrans transactionPaymentTrans;
3822 # RetailTransactionTable transactionTable;
3823 # RetailStoreTenderTypeTable storeTenderTypeTable;
3824 # LedgerDimensionAccount ledgerAccount, offsetLedgerAccount;
3825 # DimensionDefault defaultDimension;
3826 # RetailLedgerBank accountType;
3827 #
3828 # while select sum(amountTendered) from transactionPaymentTrans
3829 # group by statementCode, Store, businessDate, TenderType, Currency, DefaultDimension
3830 # where transactionPaymentTrans.statementId == statementTable.statementId
3831 # && transactionPaymentTrans.transactionStatus == RetailEntryStatus::None
3832 # exists join transactionTable
3833 # where transactionTable.transactionId == transactionPaymentTrans.transactionId &&
3834 # transactionTable.store == transactionPaymentTrans.store &&
3835 # transactionTable.terminal == transactionPaymentTrans.terminal &&
3836 # (transactionTable.type == RetailTransactionType::StartingAmount ||
3837 # transactionTable.type == RetailTransactionType::RemoveTender ||
3838 # transactionTable.type == RetailTransactionType::FloatEntry)
3839 # {
3840 # if (!transactionPaymentTrans.amountTendered)
3841 # continue;
3842 #
3843 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(transactionPaymentTrans.store).RecId, transactionPaymentTrans.tenderType);
3844 # ledgerAccount = storeTenderTypeTable.LedgerDimension;
3845 #
3846 # accountType = storeTenderTypeTable.accountType;
3847 # ledgerAccount = storeTenderTypeTable.LedgerDimension;
3848 # defaultDimension = DimensionDefaultingService::serviceMergeDefaultDimensions(transactionPaymentTrans.DefaultDimension, storeTenderTypeTable.DefaultDimension);
3849 #
3850 # if (accountType == RetailLedgerBank::Ledger)
3851 # {
3852 # ledgerAccount = DimensionDefaultingService::serviceCreateLedgerDimension(ledgerAccount, defaultDimension);
3853 # }
3854 #
3855 # offsetLedgerAccount = DimensionDefaultingService::serviceCreateLedgerDimension(storeTenderTypeTable.TenderFlowLedgerDimension_RU, defaultDimension);
3856 #
3857 # if (!offsetLedgerAccount)
3858 # throw error(strFmt("@SYS4002014", transactionPaymentTrans.tenderType));
3859 #
3860 # _tenderFlowStatementJournal.createPaymentLedgerTrans(
3861 # accountType,
3862 # ledgerAccount,
3863 # RetailLedgerBank::Ledger,
3864 # offsetLedgerAccount,
3865 # transactionPaymentTrans.currency,
3866 # -transactionPaymentTrans.amountTendered,
3867 # transactionPaymentTrans.businessDate,
3868 # "@RET3021" + " - " + "@RET4514" + storeTenderTypeTable.tenderTypeId,
3869 # statementTable.StatementId,
3870 # transactionPaymentTrans.TenderType,
3871 # defaultDimension);
3872 # }
3873 #}
3874 #// </GEERU>
3875 ENDSOURCE
3876 SOURCE #postTenderFlowLine_RU
3877 #// <GEERU>
3878 #private void postTenderFlowLine_RU(RetailTransactionTable _transactionTable,
3879 # RetailStatementPaymentJournal _tenderFlowStatementJournal)
3880 #{
3881 # RetailTransactionPaymentTrans transactionPaymentTrans;
3882 # RetailStoreTenderTypeTable storeTenderTypeTable;
3883 # LedgerDimensionAccount ledgerAccount, offsetLedgerAccount;
3884 # RetailLedgerBank accountType;
3885 # DimensionDefault defaultDimension;
3886 #
3887 # while select sum(amountTendered) from transactionPaymentTrans
3888 # group by tenderType, currency, exchRate, cardTypeId, DefaultDimension
3889 # where transactionPaymentTrans.Store == _transactionTable.store
3890 # && transactionPaymentTrans.Terminal == _transactionTable.terminal
3891 # && transactionPaymentTrans.TransactionId == _transactionTable.transactionId
3892 # && transactionPaymentTrans.TransactionStatus == RetailEntryStatus::None
3893 # {
3894 # if (transactionPaymentTrans.cardTypeId)
3895 # continue;
3896 #
3897 # storeTenderTypeTable = RetailStoreTenderTypeTable::find(RetailStoreTable::find(_transactionTable.store).RecId, transactionPaymentTrans.tenderType);
3898 #
3899 # accountType = storeTenderTypeTable.accountType;
3900 # ledgerAccount = storeTenderTypeTable.LedgerDimension;
3901 # defaultDimension = DimensionDefaultingService::serviceMergeDefaultDimensions(transactionPaymentTrans.DefaultDimension, storeTenderTypeTable.DefaultDimension);
3902 #
3903 # if (accountType == RetailLedgerBank::Ledger)
3904 # {
3905 # ledgerAccount = DimensionDefaultingService::serviceCreateLedgerDimension(ledgerAccount, defaultDimension);
3906 # }
3907 #
3908 # offsetLedgerAccount = DimensionDefaultingService::serviceCreateLedgerDimension(storeTenderTypeTable.TenderFlowLedgerDimension_RU, defaultDimension);
3909 #
3910 # if (!offsetLedgerAccount)
3911 # throw error(strFmt("@SYS4002014", transactionPaymentTrans.tenderType));
3912 #
3913 # _tenderFlowStatementJournal.createPaymentLedgerTrans(
3914 # accountType,
3915 # ledgerAccount,
3916 # RetailLedgerBank::Ledger,
3917 # offsetLedgerAccount,
3918 # transactionPaymentTrans.currency,
3919 # -transactionPaymentTrans.amountTendered,
3920 # _transactionTable.businessDate,
3921 # "@RET3021" + " - " +
3922 # "@RET4443" + _transactionTable.TransactionId +
3923 # "@RET4444" + _transactionTable.Store +
3924 # "@RET4445" + _transactionTable.Terminal,
3925 # statementTable.StatementId,
3926 # transactionPaymentTrans.TenderType,
3927 # defaultDimension
3928 # );
3929 # }
3930 #}
3931 #// </GEERU>
3932 ENDSOURCE
3933 SOURCE #postTransactionBackCompatibility
3934 #/// <summary>
3935 #/// Process the <c>RetailTransactionTable</c> record without using subtype to keep backward compatibility.
3936 #/// </summary>
3937 #/// <param name="_transactionTable">
3938 #/// A <c>RetailTransactionTable</c> record being processed by the statement.
3939 #/// </param>
3940 #/// <returns>
3941 #/// True if the transaction was posted. Otherwise, false.
3942 #/// </returns>
3943 #/// <remarks>
3944 #/// This method just consider CU8 brazilian operations related to electronic fiscal document model 65,
3945 #/// fiscal receipt and fiscal document model 2.
3946 #/// </remarks>
3947 #protected boolean postTransactionBackCompatibility(RetailTransactionTable _transactionTable)
3948 #{
3949 # boolean documentFound;
3950 # RetailTransactionSubType subType;
3951 #
3952 # documentFound = this.postRetailFiscalDocument_BR(_transactionTable);
3953 # subType = RetailTransactionSubType::ConsumerEFDocument;
3954 #
3955 # if (!documentFound)
3956 # {
3957 # documentFound = this.postRetailFiscalDocumentCanceled_BR(_transactionTable);
3958 # subType = RetailTransactionSubType::ConsumerEFDocumentCancelling;
3959 # }
3960 #
3961 # if (!documentFound)
3962 # {
3963 # documentFound = this.postFiscalReceipt_BR(_transactionTable);
3964 # subType = RetailTransactionSubType::FiscalReceipt;
3965 # }
3966 #
3967 # if (!documentFound)
3968 # {
3969 # documentFound = this.postFiscalReceiptVoided_BR(_transactionTable);
3970 # subType = RetailTransactionSubType::FiscalReceiptCancelling;
3971 # }
3972 #
3973 # if (!documentFound)
3974 # {
3975 # documentFound = this.postFiscalDocumentModel2_BR(_transactionTable);
3976 # subType = RetailTransactionSubType::FiscalDocumentModel2;
3977 # }
3978 #
3979 # if (documentFound)
3980 # {
3981 # _transactionTable.SubType = subType;
3982 # _transactionTable.update();
3983 # }
3984 #
3985 # return documentFound;
3986 #}
3987 ENDSOURCE
3988 SOURCE #postZReport_BR
3989 #/// <summary>
3990 #/// Processes a Z report issued by the fiscal printer.
3991 #/// </summary>
3992 #/// <param name="_transactionTable">
3993 #/// The Retail sales transaction related to the Z report.
3994 #/// </param>
3995 #// <GBR>
3996 #protected void postZReport_BR(RetailTransactionTable _transactionTable)
3997 #{
3998 # boolean ok = true;
3999 # RetailZReport_BR retailZReport;
4000 # TaxRetailZReport_BR taxRetailZReport;
4001 #
4002 # select forUpdate retailZReport
4003 # where retailZReport.StoreId == _transactionTable.Store
4004 # && retailZReport.TerminalId == _transactionTable.terminal
4005 # && retailZReport.TransactionId == _transactionTable.transactionId;
4006 #
4007 # if (retailZReport)
4008 # {
4009 # // Post the Z report
4010 # this.initVoucher(retailZReport.AccountingDate);
4011 # ledgerVoucherObject.lastTransTxt(this.getTransactionText_BR(retailZReport));
4012 #
4013 # taxRetailZReport = this.getTaxRetailZReport_BR(retailZReport);
4014 # taxRetailZReport.calcAndPost(this.getLedgerPostingController_BR());
4015 #
4016 # taxRetailZReport.populateTaxPovertyAmount();
4017 #
4018 # retailZReport.IsStatementPosted = NoYes::Yes;
4019 # retailZReport.update();
4020 # }
4021 #}
4022 #// </GBR>
4023 #
4024 ENDSOURCE
4025 SOURCE #rollbackInventoryReservations
4026 #/// <summary>
4027 #/// Rollback inventory reservations for sales belonging to the current statement, since we want sales-orders to do the reservation.
4028 #/// </summary>
4029 #void rollbackInventoryReservations()
4030 #{
4031 # RetailTransactionSalesTrans saleLine;
4032 # ;
4033 # // Rollback inventory reservations for sales belonging to the current statement, since we
4034 # // want sales-orders to do the reservation. Since rollbackInventoryReservations() is called in the
4035 # // same transaction-context as the code creating sales-orders, there'll never be a case where
4036 # // creation of sales-orders has failed but inventory reservations have been rolled back - creating
4037 # // an inaccurate representation of current inventory which would have caused bigger issues.
4038 #
4039 # while select saleLine
4040 # where saleLine.statementId == statementTable.statementId
4041 # {
4042 # InventUpd_DeleteMovement::newMovement(InventMovement::construct(saleLine)).updateNow();
4043 # }
4044 #
4045 # update_recordset saleLine
4046 # setting inventTransId = ''
4047 # where saleLine.statementId == statementTable.statementId;
4048 #
4049 #}
4050 ENDSOURCE
4051 SOURCE #run
4052 #/// <summary>
4053 #/// Validates and post the Retail statement.
4054 #/// </summary>
4055 #/// <remarks>
4056 #/// Also posts the discounts, payment, Income expense amount and sales orders.
4057 #/// </remarks>
4058 #/// <exception cref="Exception::Error">
4059 #/// If the statement is incorrect, posting is cancelled and the status of batch framework task changes to error.
4060 #/// </exception>
4061 #/// <exception cref="Exception::UpdateConflictNotRecovered">
4062 #/// Cannot update if any other user is trying update simultaneously. The update conflict cannot be recovered.
4063 #/// </exception>
4064 #/// <exception cref="Exception::UpdateConflict">
4065 #/// Update conflict as any other user is trying to update the record at the same time.
4066 #/// </exception>
4067 #public void run()
4068 #{
4069 # #OccRetryCount
4070 # InfoLogData infoLogData;
4071 #
4072 # #Retail
4073 # ;
4074 #
4075 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStart(0, "");
4076 # RetailTracer::Info('Posting', 'RetailStatementPost::run()', 'Financial posting start');
4077 #
4078 # try
4079 # {
4080 # this.postRetailSpecific();
4081 # }
4082 # catch
4083 # {
4084 # if (this.parmStatementId())
4085 # {
4086 # // Running inside a batch framework task, so initialize the statementTable record buffer.
4087 # statementTable = RetailStatementTable::find(this.parmStatementId(), true);
4088 # if (statementTable.RecId)
4089 # {
4090 # ttsbegin;
4091 # infoLogData = InfoLog.export();
4092 # statementTable.selectForUpdate(true);
4093 # statementTable.stmtPostInfoLog = infoLogData;
4094 # statementTable.doUpdate();
4095 # ttscommit;
4096 # }
4097 # }
4098 # throw Exception::Error;
4099 # }
4100 #
4101 # if (formDS)
4102 # {
4103 # formDS.research();
4104 # }
4105 #
4106 # // Show the info dialog only if not running inside a batch framework task.
4107 # if (! this.parmStatementId())
4108 # {
4109 # if (operationProgress)
4110 # {
4111 # operationprogress.reset();
4112 # }
4113 # if (callerObject)
4114 # {
4115 # callerObject.activate(true);
4116 # }
4117 #
4118 # Box::info("@RET4164");
4119 # }
4120 #
4121 # RetailTracer::Info('Posting', 'RetailStatementPost::run()', 'Financial posting end');
4122 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostEnd(0, "");
4123 #}
4124 #
4125 ENDSOURCE
4126 SOURCE #setLVTOTransTxt
4127 #/// <summary>
4128 #/// Sets the ledger voucher transaction text.
4129 #/// </summary>
4130 #/// <param name="_transObject">
4131 #/// The current instance of <c>LedgerVoucherTransObject</c> class.
4132 #/// </param>
4133 #/// <param name="_transTxtType">
4134 #/// The current value of Transaction text type.
4135 #/// </param>
4136 #/// <param name="_additionalTxt">
4137 #/// The additional text to be added to original text.
4138 #/// </param>
4139 #/// <returns>
4140 #/// The whole text after concatenating original text to additional text.
4141 #/// </returns>
4142 #private TransTxt setLVTOTransTxt(LedgerVoucherTransObject _transObject,
4143 # LedgerTransTxt _transTxtType,
4144 # TransTxt _additionalTxt)
4145 #{
4146 # TransTxt wholeTxt, originalTxt;
4147 # TransactionTxt transTxt;
4148 # ;
4149 #
4150 # transTxt = new TransactionTxt(_transTxtType);
4151 #
4152 # originalTxt = transTxt.txt();
4153 #
4154 # wholeTxt = this.concatTransTxt(originalTxt, _additionalTxt);
4155 #
4156 # _transObject.parmTransTxt(wholeTxt);
4157 #
4158 # return wholeTxt;
4159 #}
4160 ENDSOURCE
4161 SOURCE #stampSOInvoiceIdsOnHeaders
4162 #/// <summary>
4163 #/// Updates <c>RetailTransactionTable</c> after posting with the Invoice ID.
4164 #/// </summary>
4165 #void stampSOInvoiceIdsOnHeaders()
4166 #{
4167 # RetailTransactionTable rboHeaders;
4168 # CustInvoiceJour custInvoiceJour;
4169 # ;
4170 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepStart(0, 'stampSOInvoiceIdsOnHeaders');
4171 #
4172 # update_recordset rboHeaders
4173 # setting InvoiceId = custInvoiceJour.InvoiceId
4174 # join custInvoiceJour
4175 # where custInvoiceJour.SalesId == rboHeaders.salesOrderId
4176 # && rboHeaders.statementId == statementTable.statementId
4177 # && rboHeaders.salesOrderId
4178 # && (! rboHeaders.invoiceId);
4179 #
4180 # RetailTracer::Info('Posting', 'RetailStatementPost::stampSOInvoiceIdsOnHeaders()', 'Updated %1 transactions with sales order ID', rboHeaders.RowCount());
4181 #
4182 # Microsoft.Dynamics.Retail.Tracing.RetailAXTraceProvider::EventWriteRAXStatementPostStepEnd(0, 'stampSOInvoiceIdsOnHeaders');
4183 #}
4184 ENDSOURCE
4185 SOURCE #unpack
4186 #public boolean unpack(container _packedClass)
4187 #{
4188 # Integer version = conpeek(_packedClass,1);
4189 # ;
4190 #
4191 # switch (version)
4192 # {
4193 # case #CurrentVersion:
4194 # [version, #CurrentList] = _packedClass;
4195 # break;
4196 # default:
4197 # return false;
4198 # }
4199 #
4200 # return true;
4201 #}
4202 ENDSOURCE
4203 SOURCE #updateCustInvoiceJour
4204 #/// <summary>
4205 #/// Inserts the document to the posted sales order with the comments passed in the parameter.
4206 #/// </summary>
4207 #/// <param name="invoiceDate">
4208 #/// The current value of invoice date.
4209 #/// </param>
4210 #/// <param name="voucher">
4211 #/// The current value of the voucher.
4212 #/// </param>
4213 #/// <param name="_salesTableComment">
4214 #/// The comment to be added to the sales orders.
4215 #/// </param>
4216 #[SysObsoleteAttribute('This method is obsolete.', true)]
4217 #void updateCustInvoiceJour(
4218 # TransDate invoiceDate,
4219 # Voucher voucher,
4220 # RetailCommentEx5 _salesTableComment)
4221 #{
4222 #}
4223 #
4224 ENDSOURCE
4225 SOURCE #updateShift
4226 #/// <summary>
4227 #/// Updates the status in the <c>RetailStoreWorkShiftTable</c> and <c>RetailStoreWorkShiftTrans</c> after posting.
4228 #/// </summary>
4229 #/// <param name="_statementTable">
4230 #/// The current instance of statment table.
4231 #/// </param>
4232 #void updateShift(RetailStatementTable _statementTable)
4233 #{
4234 # RetailStoreWorkShiftTable workShiftTable;
4235 # RetailStoreWorkShiftTrans workShiftTrans;
4236 #
4237 # if (_statementTable.ClosingMethod == RetailClosingMethodType::PosBatch)
4238 # {
4239 # select firstonly forupdate workShiftTable
4240 # where workShiftTable.StoreRecId == RetailStoreTable::find(_statementTable.storeId).RecId
4241 # && workShiftTable.ShiftDate == _statementTable.ShiftDate
4242 # && workShiftTable.ShiftId == _statementTable.ShiftId;
4243 #
4244 # if (workShiftTable)
4245 # {
4246 # workShiftTable.WorkShiftStatus = RetailWorkShiftStatus::Posted;
4247 # workShiftTable.doUpdate();
4248 #
4249 # while select forupdate workShiftTrans
4250 # where workShiftTrans.StoreRecId == workShiftTable.StoreRecId
4251 # && workShiftTrans.ShiftDate == workShiftTable.ShiftDate
4252 # && workShiftTrans.ShiftId == workShiftTable.ShiftId
4253 # {
4254 # workShiftTrans.Status = RetailWorkShiftStatus::Posted;
4255 # workShiftTrans.doUpdate();
4256 # }
4257 # }
4258 # }
4259 #}
4260 ENDSOURCE
4261 SOURCE #GetTenderTypeName
4262 #/// <summary>
4263 #/// Gets the tender type name.
4264 #/// </summary>
4265 #/// <param name="_storeTable">
4266 #/// The Retail store record.
4267 #/// </param>
4268 #/// <param name="_tenderTypeId">
4269 #/// The tender type Id.
4270 #/// </param>
4271 #/// <param name="_cardTypeId">
4272 #/// Card Id if the tender type is 'Cards'. Optional.
4273 #/// </param>
4274 #/// <param name="_currencyCode">
4275 #/// Currency code. Optional.
4276 #/// </param>
4277 #/// <returns>
4278 #/// The name of tender type card; otherwise empty string.
4279 #/// </returns>
4280 #static str GetTenderTypeName(RetailStoreTable _storeTable,
4281 # RetailTenderTypeId _tenderTypeId,
4282 # RetailCardTypeId _cardTypeId = '',
4283 # CurrencyCode _currencyCode = '')
4284 #{
4285 # RetailStoreTenderTypeTable tenderTypeTable;
4286 # RetailStoreTenderTypeCardTable tenderTypeCardTable;
4287 # RetailTenderTypeCardTable tenderCardTable;
4288 #
4289 # str ret;
4290 #
4291 # tenderTypeTable = RetailStoreTenderTypeTable::find(_storeTable.RecId, _tenderTypeId);
4292 # if (tenderTypeTable)
4293 # {
4294 # ret = tenderTypeTable.Name;
4295 # }
4296 # else
4297 # {
4298 # ret = "@RET4041";
4299 # }
4300 #
4301 # if (_cardTypeId)
4302 # {
4303 # tenderTypeCardTable = RetailStoreTenderTypeCardTable::find(_storeTable.RecId, _tenderTypeId, _cardTypeId);
4304 # if (tenderTypeCardTable)
4305 # {
4306 # if (tenderTypeCardTable.Name)
4307 # {
4308 # ret += ', ' + tenderTypeCardTable.Name;
4309 # }
4310 # else
4311 # {
4312 # tenderCardTable = RetailTenderTypeCardTable::find(tenderTypeCardTable.cardTypeId);
4313 # if (tenderCardTable)
4314 # {
4315 # ret += ', ' + tenderCardTable.name;
4316 # }
4317 # else
4318 # {
4319 # ret += ', ' + "@RET4040";
4320 # }
4321 # }
4322 # }
4323 # else
4324 # {
4325 # ret += ', ' + "@RET4040";
4326 # }
4327 # }
4328 #
4329 # if (_currencyCode)
4330 # {
4331 # ret += ' ' + _currencyCode;
4332 # }
4333 #
4334 # return ret;
4335 #}
4336 ENDSOURCE
4337 SOURCE #main
4338 #public static void main(Args _args)
4339 #{
4340 # #OccRetryCount
4341 # RetailStatementPost statementPost = new RetailStatementPost();
4342 #
4343 # try
4344 # {
4345 # ttsBegin;
4346 # statementPost.initFromArgs(_args);
4347 # statementPost.postSalesOrders();
4348 # statementPost.run();
4349 # ttsCommit;
4350 # }
4351 # catch (Exception::Deadlock)
4352 # {
4353 # info("@SYS65063"); // Deadlock detected
4354 # retry;
4355 # }
4356 # catch (Exception::UpdateConflict)
4357 # {
4358 # if (appl.ttsLevel() == 0)
4359 # {
4360 # if (xSession::currentRetryCount() >= #RetryNum)
4361 # {
4362 # throw Exception::UpdateConflictNotRecovered;
4363 # }
4364 # else
4365 # {
4366 # info("@SYS107548"); // Update conflicts
4367 # retry;
4368 # }
4369 # }
4370 # else
4371 # {
4372 # throw Exception::UpdateConflict;
4373 # }
4374 # }
4375 #}
4376 ENDSOURCE
4377 ENDMETHODS
4378 ENDCLASS
4379
4380***Element: END