public void CloseTransaction(Data.SalesTransactionItemDetails mTopItemDetails, decimal AmountPaid, decimal ChangeAmount, decimal BalanceAmount, decimal CashPayment, decimal ChequePayment, decimal CreditCardPayment, decimal CreditPayment, decimal CreditChargeAmount, decimal DebitPayment, decimal RewardConvertedPayment, decimal RewardPointsPayment, PaymentTypes PaymentType, ArrayList arrCashPaymentDetails, ArrayList arrChequePaymentDetails, ArrayList arrCreditCardPaymentDetails, ArrayList arrCreditPaymentDetails, ArrayList arrDebitPaymentDetails) { mclsSalesTransactionDetails.AmountPaid = AmountPaid; mclsSalesTransactionDetails.ChangeAmount = ChangeAmount; mclsSalesTransactionDetails.CashPayment = CashPayment; mclsSalesTransactionDetails.ChequePayment = ChequePayment; mclsSalesTransactionDetails.CreditCardPayment = CreditCardPayment; mclsSalesTransactionDetails.CreditPayment = CreditPayment; // include credit charge amount mclsSalesTransactionDetails.CreditChargeAmount = CreditChargeAmount; mclsSalesTransactionDetails.AmountDue += mclsSalesTransactionDetails.CreditChargeAmount; mclsSalesTransactionDetails.DebitPayment = DebitPayment; mclsSalesTransactionDetails.RewardPointsPayment = RewardConvertedPayment; /*** * Nov 04, 2011 : for payments using reward points ***/ mclsSalesTransactionDetails.RewardPointsPayment = RewardPointsPayment; mclsSalesTransactionDetails.RewardConvertedPayment = RewardConvertedPayment; /*** * Oct 17, 2011 : Move this code here. * check if will print transaction or not before opening any connection to database. ***/ mboDoNotPrintTransactionDate = false; if (mclsTerminalDetails.AutoPrint == PrintingPreference.AskFirst) { if (MessageBox.Show("Would you like to print this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, (mclsSysConfigDetails.isDefaultButtonYesInPrintTransaction ? MessageBoxDefaultButton.Button1 : MessageBoxDefaultButton.Button2)) == DialogResult.Yes) { mclsTerminalDetails.AutoPrint = PrintingPreference.Normal; if (mclsSysConfigDetails.WillAskDoNotPrintTransactionDate) if (MessageBox.Show("Would you like the system NOT to print the transaction date?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes) mboDoNotPrintTransactionDate = true; } } // Mar 17, 2009 // open drawer first before printing. //OpenDrawerDelegate opendrawerDel = new OpenDrawerDelegate(OpenDrawer); //Invoke(opendrawerDel); OpenDrawer(); Cursor.Current = Cursors.WaitCursor; clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] saving payments...", true); // for assignment of payments mclsSalesTransactionDetails.PaymentDetails = AssignArrayListPayments(arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails); // start a connection for the database. //update the transaction table Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; SavePayments(arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails); if (mclsSalesTransactionDetails.CreditChargeAmount != 0) { //Aug 30, 2014 delete need to move this from here to mainwnd clsSalesTransactions.UpdateCreditChargeAmount(mclsSalesTransactionDetails.BranchID, mclsSalesTransactionDetails.TerminalNo, mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.CreditChargeAmount); } Data.Products clsProduct = new Data.Products(mConnection, mTransaction); mConnection = clsProduct.Connection; mTransaction = clsProduct.Transaction; TransactionStatus clsTransactionStatus = TransactionStatus.Closed; if (mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE) { clsTransactionStatus = TransactionStatus.CreditPayment; } else if (mboIsRefund) { clsTransactionStatus = TransactionStatus.Refund; if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode) { clsTransactionStatus = TransactionStatus.ClosedOutOfStockRefund; } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode) { clsTransactionStatus = TransactionStatus.ClosedWalkInRefund; } else if (mclsSalesTransactionDetails.isConsignment) { clsTransactionStatus = TransactionStatus.ConsignmentRefund; } } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode) { clsTransactionStatus = TransactionStatus.ClosedOutOfStock; } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode) { clsTransactionStatus = TransactionStatus.ClosedWalkIn; } else if (mclsSalesTransactionDetails.isConsignment) { clsTransactionStatus = TransactionStatus.Consignment; } if (mboIsRefund && !mclsTerminalDetails.IsParkingTerminal) { #region mboIsRefund clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] updating refund terminal no...", true, mclsSysConfigDetails.WillWriteSystemLog); clsSalesTransactions.UpdateTerminalNo(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo); if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode || mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode) { // 20Feb2015 : Added as an exemption clsEvent.AddEventLn(" no need to apply an ORNo. Customer is " + mclsSalesTransactionDetails.CustomerDetails.ContactCode, true, mclsSysConfigDetails.WillWriteSystemLog); } else if (!mclsSalesTransactionDetails.isConsignment) { // 04Sep2014 : Added to put as OR No - Void NO-OR mclsSalesTransactionDetails.ORNo = clsSalesTransactions.CreateORNo(mclsTerminalDetails.ORSeriesBranchID, mclsTerminalDetails.ORSeriesTerminalNo); clsEvent.AddEventLn(" applying ORNo".PadRight(15) + ":" + mclsSalesTransactionDetails.ORNo, true, mclsSysConfigDetails.WillWriteSystemLog); } clsSalesTransactions.Refund(clsTransactionStatus, mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ORNo, -mclsSalesTransactionDetails.ItemSold, -mclsSalesTransactionDetails.QuantitySold, -mclsSalesTransactionDetails.GrossSales, -mclsSalesTransactionDetails.SubTotal, -mclsSalesTransactionDetails.NetSales, -mclsSalesTransactionDetails.ItemsDiscount, -mclsSalesTransactionDetails.SNRItemsDiscount, -mclsSalesTransactionDetails.PWDItemsDiscount, -mclsSalesTransactionDetails.OtherItemsDiscount, -mclsSalesTransactionDetails.Discount, -mclsSalesTransactionDetails.SNRDiscount, -mclsSalesTransactionDetails.PWDDiscount, -mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, -mclsSalesTransactionDetails.VAT, -mclsSalesTransactionDetails.VATableAmount, -mclsSalesTransactionDetails.ZeroRatedSales, - mclsSalesTransactionDetails.NonVATableAmount, -mclsSalesTransactionDetails.VATExempt, -mclsSalesTransactionDetails.EVAT, -mclsSalesTransactionDetails.EVATableAmount, -mclsSalesTransactionDetails.NonEVATableAmount, -mclsSalesTransactionDetails.LocalTax, -mclsSalesTransactionDetails.AmountPaid, -CashPayment, -ChequePayment, -CreditCardPayment, -CreditPayment, -DebitPayment, -RewardPointsPayment, -RewardConvertedPayment, -BalanceAmount, -ChangeAmount, PaymentType, mclsSalesTransactionDetails.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, -mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.CashierID, mclsSalesTransactionDetails.CashierName); //UpdateTerminalReportDelegate updateterminalDel = new UpdateTerminalReportDelegate(UpdateTerminalReport); clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] updating refund terminal report...", true, mclsSysConfigDetails.WillWriteSystemLog); UpdateTerminalReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType); //UpdateCashierReportDelegate updatecashierDel = new UpdateCashierReportDelegate(UpdateCashierReport); clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] updating redunf cashier report...", true, mclsSysConfigDetails.WillWriteSystemLog); UpdateCashierReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType); // Sep 24, 2014 : update back the LastCheckInDate to min date Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE); // Sep 14, 2014 Control printing in mclsFilePrinter.Write //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal) //print items if not yet printed //{ clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] printing refund items...", true, mclsSysConfigDetails.WillWriteSystemLog); foreach (System.Data.DataRow dr in ItemDataTable.Rows) { if (dr["Quantity"].ToString() != "VOID") { string stItemNo = "" + dr["ItemNo"].ToString(); string stProductCode = "" + dr["ProductCode"].ToString(); if (dr["MatrixDescription"].ToString() != string.Empty && dr["MatrixDescription"].ToString() != null) stProductCode += "-" + dr["MatrixDescription"].ToString(); string stProductUnitCode = "" + dr["ProductUnitCode"].ToString(); decimal decQuantity = Convert.ToDecimal(dr["Quantity"]); decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decDiscount = Convert.ToDecimal(dr["Discount"]); decimal decAmount = Convert.ToDecimal(dr["Amount"]); decimal decVAT = Convert.ToDecimal(dr["VAT"]); decimal decEVAT = Convert.ToDecimal(dr["EVAT"]); decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]); string stDiscountCode = "" + dr["DiscountCode"].ToString(); DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString()); if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType); } } if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) PrintReportFooterSection(true, TransactionStatus.Refund, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.AmountPaid, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, ChangeAmount, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails); //} // Sep 14, 2014 Control printing in mclsFilePrinter.Write // Sep 24, 2011 Lemuel E. Aceron // Added order slip wherein all punch items will not change sales and inventory // a customer named ORDER SLIP should be defined in contacts // lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER // Added May 7, 2011 to Cater Reserved and Commit functionality // !mclsTerminalDetails.ReservedAndCommit // Sep 14, 2013: Remove the reserved and commit. //if (lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && !mclsTerminalDetails.ReservedAndCommit && !mclsTerminalDetails.IsParkingTerminal) if (mclsSalesTransactionDetails.CustomerName.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && !mclsTerminalDetails.IsParkingTerminal && mclsSalesTransactionDetails.CustomerDetails.ContactCode.Trim() != mclsSysConfigDetails.OutOfStockCustomerCode) // do not change the inventory if OUT_OF_STOCK_CUSTOMER_CODE { clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] adding the refund items quantity to inv...", true, mclsSysConfigDetails.WillWriteSystemLog); Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction); mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction; foreach (System.Data.DataRow dr in ItemDataTable.Rows) { Int64 lProductID = Convert.ToInt64(dr["ProductID"]); Int64 lVariationsMatrixID = Convert.ToInt64(dr["VariationsMatrixID"]); Int32 iProductUnitID = Convert.ToInt32(dr["ProductUnitID"]); decimal decQuantity = 0; decimal decPackageQuantity = 0; decimal decNewQuantity = 0; if (dr["Quantity"].ToString().IndexOf("RETURN") != -1) { decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decPurchasePrice = Convert.ToDecimal(dr["PurchasePrice"]); decimal decDiscount = Convert.ToDecimal(dr["Discount"]); decimal decAmount = -Convert.ToDecimal(dr["Amount"]); decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim()); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); decNewQuantity = -decNewQuantity; clsEvent.AddEventLn(" subtracting refund-return item: prdid-" + lProductID.ToString() + " to inv: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.SubtractQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_REFUND_RETURN) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1) { decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim()); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsEvent.AddEventLn(" adding refund-demo item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_REFUND_DEMO_ITEM) + " Ter#: " + mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } else if (dr["Quantity"].ToString() != "VOID") { decQuantity = Convert.ToDecimal(dr["Quantity"]); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsEvent.AddEventLn(" adding refund item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_REFUND_ITEM) + " Ter#: " + mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } } } #endregion } else if (!mboIsRefund) { #region Normal and ParkingTerminal clsEvent.AddEventLn(" closing transaction...", true, mclsSysConfigDetails.WillWriteSystemLog); if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode || mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode) { // 20Feb2015 : Added as an exemption clsEvent.AddEventLn(" no need to apply an ORNo. Customer is " + mclsSalesTransactionDetails.CustomerDetails.ContactCode, true, mclsSysConfigDetails.WillWriteSystemLog); } else if (!mclsSalesTransactionDetails.isConsignment) { // 04Sep2014 : Added to put as OR No - Void NO-OR if (mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_REPLACEMENT_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE) { clsEvent.AddEventLn(" no need to apply an ORNo. Product is " + mTopItemDetails.BarCode, true, mclsSysConfigDetails.WillWriteSystemLog); } else { mclsSalesTransactionDetails.ORNo = clsSalesTransactions.CreateORNo(mclsTerminalDetails.ORSeriesBranchID, mclsTerminalDetails.ORSeriesTerminalNo); clsEvent.AddEventLn(" applying ORNo".PadRight(15) + ":" + mclsSalesTransactionDetails.ORNo, true, mclsSysConfigDetails.WillWriteSystemLog); } } // clsSalesTransactions.UpdateTerminalNo(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo); // remove the above. Include the TerminalNo in clsSalesTransactions.Close below clsSalesTransactions.Close(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo, mclsSalesTransactionDetails.ORNo, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.AmountPaid, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, BalanceAmount, ChangeAmount, PaymentType, mclsSalesTransactionDetails.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.CashierID, mclsSalesTransactionDetails.CashierName, clsTransactionStatus); //UpdateTerminalReportDelegate updateterminalDel = new UpdateTerminalReportDelegate(UpdateTerminalReport); clsEvent.AddEventLn(" updating terminal report...", true, mclsSysConfigDetails.WillWriteSystemLog); UpdateTerminalReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType); //UpdateCashierReportDelegate updatecashierDel = new UpdateCashierReportDelegate(UpdateCashierReport); clsEvent.AddEventLn(" updating cashier's report...", true, mclsSysConfigDetails.WillWriteSystemLog); UpdateCashierReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType); // Sep 24, 2014 : update back the LastCheckInDate to min date Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE); // Sep 24, 2011 Lemuel E. Aceron // Added order slip wherein all punch items will not change sales and inventory // a customer named ORDER SLIP should be defined in contacts //if (lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER) // Added May 7, 2011 to Cater Reserved and Commit functionality // !mclsTerminalDetails.ReservedAndCommit if (mclsTerminalDetails.IsParkingTerminal) { clsEvent.AddEventLn(" adding back the parking slot to inv...", true, mclsSysConfigDetails.WillWriteSystemLog); Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction); mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction; Data.ProductVariationsMatrix clsProductVariationsMatrix = new Data.ProductVariationsMatrix(mConnection, mTransaction); foreach (System.Data.DataRow dr in ItemDataTable.Rows) { long lProductID = Convert.ToInt64(dr["ProductID"]); long lVariationsMatrixID = Convert.ToInt64(dr["VariationsMatrixID"]); int iProductUnitID = Convert.ToInt32(dr["ProductUnitID"]); decimal decQuantity = 0; decimal decPackageQuantity = 0; decimal decNewQuantity = 0; decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decPurchasePrice = Convert.ToDecimal(dr["PurchasePrice"]); if ((dr["Quantity"].ToString().IndexOf("RETURN") == -1) && (dr["Quantity"].ToString() != "VOID")) { decQuantity = Convert.ToDecimal(dr["Quantity"]); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.PARKING_OUT), mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } } } else if (mclsSalesTransactionDetails.CustomerName.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && !mclsTerminalDetails.IsParkingTerminal && mclsSalesTransactionDetails.CustomerDetails.ContactCode.Trim() != mclsSysConfigDetails.OutOfStockCustomerCode) // do not change the inventory if OUT_OF_STOCK_CUSTOMER_CODE { Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction); mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction; Data.ProductVariationsMatrix clsProductVariationsMatrix = new Data.ProductVariationsMatrix(mConnection, mTransaction); Data.SalesTransactionItems clsSalesTransactionItems = new Data.SalesTransactionItems(mConnection, mTransaction); foreach (System.Data.DataRow dr in ItemDataTable.Rows) { long lProductID = Convert.ToInt64(dr["ProductID"]); long lVariationsMatrixID = Convert.ToInt64(dr["VariationsMatrixID"]); int iProductUnitID = Convert.ToInt32(dr["ProductUnitID"]); decimal decQuantity = 0; decimal decPackageQuantity = 0; decimal decNewQuantity = 0; decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decPurchasePrice = Convert.ToDecimal(dr["PurchasePrice"]); decimal decDiscount = Convert.ToDecimal(dr["Discount"]); decimal decAmount = Convert.ToDecimal(dr["Amount"]); if (dr["Quantity"].ToString().IndexOf("RETURN") != -1) { decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim()); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsEvent.AddEventLn(" adding return item: prdid-" + lProductID.ToString() + " to inv: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_RETURN_ITEM) + " Ter#: " + mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); // 28JUn2015 : Add the RefReturnTransactionItemsID to the Int64 intReturnTransactionItemsID = Convert.ToInt64(dr["ReturnTransactionItemsID"]); Int64 intTransactionItemsID = Convert.ToInt64(dr["TransactionItemsID"]); clsSalesTransactionItems.UpdateRefReturnTransactionItemsID(intReturnTransactionItemsID, intTransactionItemsID); } else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1) { decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim()); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsEvent.AddEventLn(" subtracting demo item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.SubtractQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_DEMO_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); clsProduct.SubtractReservedQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_DEMO_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } else if (dr["Quantity"].ToString() != "VOID") { decQuantity = Convert.ToDecimal(dr["Quantity"]); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsEvent.AddEventLn(" subtracting sold item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.SubtractQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_SOLD_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); clsProduct.SubtractReservedQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_SOLD_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } } } // Nov 1, 2011 : Lemu - disabled reward points if product is exempted clsEvent.AddEventLn(" checking if rewards is enabled...", true, mclsSysConfigDetails.WillWriteSystemLog); if (mclsSalesTransactionDetails.RewardCardActive && mclsTerminalDetails.RewardPointsDetails.EnableRewardPoints) { // Note: mTopItemDetails is already set in the MainWnd.CloseTransaction() if (mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_REPLACEMENT_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE) { mclsTerminalDetails.RewardPointsDetails.EnableRewardPoints = false; } } #endregion } // Oct 23, 2011 : Lemu - Added Reward Points #region Reward Payment if (mclsSalesTransactionDetails.RewardPointsPayment != 0) { clsEvent.AddEventLn(" deducting rewards payment...", true, mclsSysConfigDetails.WillWriteSystemLog); // this should comes before earning of points otherwise this will be wrong. Data.ContactReward clsContactReward = new Data.ContactReward(mConnection, mTransaction); mConnection = clsContactReward.Connection; mTransaction = clsContactReward.Transaction; clsContactReward.DeductPoints(mclsSalesTransactionDetails.CustomerID, mclsSalesTransactionDetails.RewardPointsPayment); string strReason = "Redeemed " + mclsSalesTransactionDetails.RewardPointsPayment + " using Reward Card #: " + mclsSalesTransactionDetails.RewardCardNo; clsContactReward.AddMovement(mclsSalesTransactionDetails.CustomerID, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.RewardCurrentPoints, -mclsSalesTransactionDetails.RewardPointsPayment, mclsSalesTransactionDetails.RewardCurrentPoints - mclsSalesTransactionDetails.RewardPointsPayment, mclsSalesTransactionDetails.RewardCardExpiry, strReason, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierName, mclsSalesTransactionDetails.TransactionNo); mclsSalesTransactionDetails.RewardPreviousPoints = mclsSalesTransactionDetails.RewardCurrentPoints; mclsSalesTransactionDetails.RewardCurrentPoints -= mclsSalesTransactionDetails.RewardPointsPayment; mclsSalesTransactionDetails.RewardEarnedPoints = 0; clsEvent.AddEventLn(" printing rewards slip...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintRewardsRedemptionSlip(); // do this after printing so that it will be equal mclsSalesTransactionDetails.RewardPreviousPoints = mclsSalesTransactionDetails.RewardCurrentPoints; } #endregion #region Add reward points to customer if (mclsTerminalDetails.RewardPointsDetails.EnableRewardPoints && mclsSalesTransactionDetails.RewardCardActive && mclsSalesTransactionDetails.RewardsCustomerID != Constants.C_RETAILPLUS_CUSTOMERID && mclsTerminalDetails.RewardPointsDetails.RewardPointsMinimum <= mclsSalesTransactionDetails.AmountDue) { decimal decRewardPoints = 0; try { decRewardPoints = (mclsSalesTransactionDetails.AmountDue - mclsSalesTransactionDetails.RewardConvertedPayment) / mclsTerminalDetails.RewardPointsDetails.RewardPointsEvery * mclsTerminalDetails.RewardPointsDetails.RewardPoints; // round down points if RoundDown is enabled if (mclsTerminalDetails.RewardPointsDetails.RoundDownRewardPoints) decRewardPoints = decimal.Floor(decRewardPoints); //Data.Product clsProduct //long lngProductID = 0; foreach (System.Data.DataRow dr in ItemDataTable.Rows) { //lngProductID = decimal.Parse(dr["RewardPoints"].ToString()); //decRewardPoints += clsProduct.Details1(mclsTerminalDetails.BranchID, lngProductID).RewardPoints; decRewardPoints += decimal.Parse(dr["RewardPoints"].ToString()); } } catch { } mclsSalesTransactionDetails.RewardEarnedPoints = decRewardPoints; mclsSalesTransactionDetails.RewardCurrentPoints = mclsSalesTransactionDetails.RewardPreviousPoints + mclsSalesTransactionDetails.RewardEarnedPoints; Data.ContactReward clsContactReward = new Data.ContactReward(mConnection, mTransaction); mConnection = clsContactReward.Connection; mTransaction = clsContactReward.Transaction; clsContactReward.AddPoints(mclsSalesTransactionDetails.RewardsCustomerID, mclsSalesTransactionDetails.RewardEarnedPoints); clsContactReward.AddPurchase(mclsSalesTransactionDetails.RewardsCustomerID, mclsSalesTransactionDetails.AmountDue); string strReason = "Purchase " + mclsSalesTransactionDetails.AmountDue.ToString("#,##0.#0") + " using Reward Card #: " + mclsSalesTransactionDetails.RewardCardNo; clsContactReward.AddMovement(mclsSalesTransactionDetails.RewardsCustomerID, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.RewardPreviousPoints, mclsSalesTransactionDetails.RewardEarnedPoints, mclsSalesTransactionDetails.RewardCurrentPoints, mclsSalesTransactionDetails.RewardCardExpiry, strReason, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierName, mclsSalesTransactionDetails.TransactionNo); } #endregion #region 3Nov2014 : autoamtically deposit the change if credit payment //#region Auto deposit for creditpayment //if (clsTransactionStatus == TransactionStatus.CreditPayment && mclsSysConfigDetails.WillDepositChangeOfCreditPayment) //{ // InsertAuditLog(AccessTypes.Deposit, "Auto depositing change of trx #: " + mclsSalesTransactionDetails.TransactionNo + "."); // clsEvent.AddEventLn("Auto depositing change of trx #: " + mclsSalesTransactionDetails.TransactionNo + ".", true); // Data.Deposits clsDeposit = new Data.Deposits(mConnection, mTransaction); // mConnection = clsDeposit.Connection; mTransaction = clsDeposit.Transaction; // Data.DepositDetails clsDepositDetails = new Data.DepositDetails() // { // BranchDetails = mclsTerminalDetails.BranchDetails, // TerminalNo = mclsTerminalDetails.TerminalNo, // Amount = mclsSalesTransactionDetails.ChangeAmount, // PaymentType = mclsSalesTransactionDetails.PaymentType, // DateCreated = DateTime.Now, // CashierID = mclsSalesTransactionDetails.CashierID, // CashierName = mclsSalesTransactionDetails.CashierName, // ContactID = mclsSalesTransactionDetails.CustomerDetails.ContactID, // ContactName = mclsSalesTransactionDetails.CustomerDetails.ContactName, // Remarks = "Auto deposit from trx #: " + mclsSalesTransactionDetails.TransactionNo + ".", // CreatedOn = DateTime.Now, // LastModified = DateTime.Now // }; // clsDeposit.Insert(clsDepositDetails); // clsContact = new Data.Contacts(mConnection, mTransaction); // mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; // clsContact.AddDebit(clsDepositDetails.ContactID, clsDepositDetails.Amount); // clsDeposit.CommitAndDispose(); // InsertAuditLog(AccessTypes.Deposit, "Deposit: type='" + clsDepositDetails.PaymentType.ToString("G") + "' amount='" + clsDepositDetails.Amount.ToString(",##0.#0") + "'" + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode); // clsEvent.AddEventLn("Done! type=" + clsDepositDetails.PaymentType.ToString("G") + " amount=" + clsDepositDetails.Amount.ToString("#,###.#0"), true); //} //#endregion #endregion // 22Nov2014 : remove the merge tables when closed or void if (mclsTerminalDetails.WithRestaurantFeatures) RemoveFromMergeTable(mclsSalesTransactionDetails.CustomerDetails.ContactCode); // commit the transactions here. // in case error s encoutered n printing. transaction is already committed. clsEvent.AddEventLn(" commiting transaction to database...", true, mclsSysConfigDetails.WillWriteSystemLog); clsSalesTransactions.CommitAndDispose(); /*** * print the transaction ***/ #region printing if (mclsTerminalDetails.AutoPrint != PrintingPreference.AskFirst) { try { if (mclsSalesTransactionDetails.isConsignment) { // 18Feb2015 : Print DR only if the transaction is consignment clsEvent.AddEventLn(" printing delivery receipt as consginment...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintDeliveryReceipt(); } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode && (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice || mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt || mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR)) { clsEvent.AddEventLn(" printing out of stock orders...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintOSReceipt(); } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode && (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice || mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt || mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR)) { clsEvent.AddEventLn(" printing walk-in customer quote form...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintWalkInReceipt(); } else if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.CreditPayment && mclsSysConfigDetails.CreditPaymentType == CreditPaymentType.Houseware) { // do another report for credit payment if HP PrintCreditPayment(); // do this twice as per request of CN trader's and CS PrintCreditPayment(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice) { clsEvent.AddEventLn(" printing sales invoice...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintSalesInvoice(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt) { clsEvent.AddEventLn(" printing delivery receipt...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintDeliveryReceipt(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR) { clsEvent.AddEventLn(" printing sales invoice & delivery receipt...", true, mclsSysConfigDetails.WillWriteSystemLog); if (mclsSalesTransactionDetails.TransactionStatus != TransactionStatus.Void) { clsEvent.AddEventLn(" will not print sales invoice. trx is void...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintSalesInvoice(); } PrintDeliveryReceipt(); } // 10Feb2010 : print sales invoice to LX as required by Wireless Link else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300Printer) { clsEvent.AddEventLn(" printing sales invoice for LX300...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300Printer); } //Added May 11, 2010 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceOrDR) { clsEvent.AddEventLn(" printing sales invoice or OR...", true, mclsSysConfigDetails.WillWriteSystemLog); if (mclsSalesTransactionDetails.CashPayment != 0 || mclsSalesTransactionDetails.CreditCardPayment != 0) PrintSalesInvoice(); if (mclsSalesTransactionDetails.ChequePayment != 0 || mclsSalesTransactionDetails.CreditPayment != 0) PrintDeliveryReceipt(); } //Added January 17, 2011 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusPrinter) { clsEvent.AddEventLn(" printing sales invoice for LX300 Plus...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusPrinter); } //Added February 22, 2011 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusAmazon) { clsEvent.AddEventLn(" printing sales invoice for LX300 Plus Amazon...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusAmazon); } else if (!mboIsRefund) // do not print if refund coz its already printed above { // Sep 14, 2014 Control printing in mclsFilePrinter.Write //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal) //print items if not yet printed //{ clsEvent.AddEventLn(" printing items to POS printer...", true, mclsSysConfigDetails.WillWriteSystemLog); foreach (System.Data.DataRow dr in ItemDataTable.Rows) { string stItemNo = "" + dr["ItemNo"].ToString(); string stProductUnitCode = "" + dr["ProductUnitCode"].ToString(); decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decDiscount = Convert.ToDecimal(dr["Discount"]); decimal decAmount = Convert.ToDecimal(dr["Amount"]); decimal decVAT = Convert.ToDecimal(dr["VAT"]); decimal decEVAT = Convert.ToDecimal(dr["EVAT"]); decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]); string stProductCode = "" + dr["ProductCode"].ToString(); if (dr["MatrixDescription"].ToString() != string.Empty && dr["MatrixDescription"].ToString() != null) stProductCode += "-" + dr["MatrixDescription"].ToString(); decimal decQuantity = 0; string stDiscountCode = "" + dr["DiscountCode"].ToString(); DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString()); if (dr["Quantity"].ToString().IndexOf("RETURN") != -1) { stProductCode = "" + dr["ProductCode"].ToString() + "-RET"; decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim()); decAmount = -decAmount; } else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1) { stProductCode = "" + dr["ProductCode"].ToString() + "-DEMO"; decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim()); decAmount = 0; } else if (dr["Quantity"].ToString() != "VOID") { decQuantity = Convert.ToDecimal(dr["Quantity"]); } if (dr["Quantity"].ToString().IndexOf("VOID") != -1) { if (mclsTerminalDetails.WillPrintVoidItem) if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType); } else { if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType); } } if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) { PrintReportFooterSection(true, clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.AmountPaid, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, ChangeAmount, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails); // print the charge slip if not refund and will print if (mclsTerminalDetails.WillPrintChargeSlip && !mboIsRefund) { clsEvent.AddEventLn(" printing charge slip...", true, mclsSysConfigDetails.WillWriteSystemLog); // Nov 05, 2011 : Print Charge Slip PrintChargeSlip(ChargeSlipType.Customer); PrintChargeSlip(ChargeSlipType.Original); if (mclsTerminalDetails.IncludeCreditChargeAgreement && mclsSalesTransactionDetails.CustomerDetails.CreditDetails.CardTypeDetails.WithGuarantor) //if (!mclsTerminalDetails.IncludeCreditChargeAgreement) //do not print the guarantor if there is no agreement printed { PrintChargeSlip(ChargeSlipType.Guarantor); } } } //} // Sep 14, 2014 Control printing in mclsFilePrinter.Write } } catch (Exception ex) { clsEvent.AddErrorEventLn(ex); clsEvent.AddEventLn("Error printing transaction no: " + mclsSalesTransactionDetails.TransactionNo + ". Already commited in the database.", true); } } #endregion // print all the coupon's #region Printing of coupons // print coupon's only for customer's with reward cards as per request of Sir Guy, // sa susunod ilalagay na sya sa selection if (mclsContactDetails.ContactID != Constants.C_RETAILPLUS_CUSTOMERID && mclsContactDetails.RewardDetails.ContactID != 0) { Data.PromoBySupplier clsPromoBySupplier = new Data.PromoBySupplier(mConnection, mTransaction); mConnection = clsPromoBySupplier.Connection; mTransaction = clsPromoBySupplier.Transaction; try { clsEvent.AddEventLn("Printing coupon if necessary...", true); Data.PromoBySupplierDetails clsPromoBySupplierDetails = clsPromoBySupplier.getPromoBySupplierID(); if (clsPromoBySupplierDetails.PromoBySupplierID != 0) { Data.PromoBySupplierItems clsPromoBySupplierItems = new Data.PromoBySupplierItems(mConnection, mTransaction); mConnection = clsPromoBySupplierItems.Connection; mTransaction = clsPromoBySupplierItems.Transaction; Data.ProductGroup clsProductGroup = new Data.ProductGroup(mConnection, mTransaction); mConnection = clsProductGroup.Connection; mTransaction = clsProductGroup.Transaction; Data.ProductSubGroup clsProductSubGroup = new Data.ProductSubGroup(mConnection, mTransaction); mConnection = clsProductSubGroup.Connection; mTransaction = clsProductSubGroup.Transaction; decimal decPromoBySupplierValue = -1; decimal decItemAmount = 0; string strCouponRemarks = ""; var lstItems = mclsSalesTransactionDetails.TransactionItemsList; Int64 ProductGroupID = 0, ProductSubGroupID = 0; switch (clsPromoBySupplierDetails.PromoLevel) { case PromoLevel.All: lstItems = mclsSalesTransactionDetails.TransactionItemsList; decPromoBySupplierValue = -1; decItemAmount = mclsSalesTransactionDetails.TransactionItemsList.Sum(x => x.Amount); if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, 0, 0, 0, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(lstItems[0], strCouponRemarks); } } break; case PromoLevel.Contact: lstItems = mclsSalesTransactionDetails.TransactionItemsList .GroupBy(x => new { x.SupplierID, x.SupplierName }) .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = "All", ProductSubGroup = "All", Amount = data.Sum(x => x.Amount) }).ToList(); foreach (Data.SalesTransactionItemDetails item in lstItems) { decPromoBySupplierValue = -1; decItemAmount = item.Amount; if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, 0, 0, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(item, strCouponRemarks); } } } break; case PromoLevel.ProductGroup: lstItems = mclsSalesTransactionDetails.TransactionItemsList .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup }) .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = "All", Amount = data.Sum(x => x.Amount) }).ToList(); foreach (Data.SalesTransactionItemDetails item in lstItems) { decPromoBySupplierValue = -1; decItemAmount = item.Amount; ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID; if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, 0, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(item, strCouponRemarks); } } } break; case PromoLevel.ProductSubGroup: lstItems = mclsSalesTransactionDetails.TransactionItemsList .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup, x.ProductSubGroup }) .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = data.Key.ProductSubGroup, Amount = data.Sum(x => x.Amount) }).ToList(); foreach (Data.SalesTransactionItemDetails item in lstItems) { decPromoBySupplierValue = -1; decItemAmount = item.Amount; ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID; ProductSubGroupID = clsProductSubGroup.DetailsByName(item.ProductSubGroup).ProductSubGroupID; if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, ProductSubGroupID, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(item, strCouponRemarks); } } } break; case PromoLevel.Product: lstItems = mclsSalesTransactionDetails.TransactionItemsList .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup, x.ProductSubGroup, x.ProductID }) .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = data.Key.ProductSubGroup, ProductID = data.Key.ProductID, Amount = data.Sum(x => x.Amount) }).ToList(); foreach (Data.SalesTransactionItemDetails item in lstItems) { decPromoBySupplierValue = -1; decItemAmount = item.Amount; ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID; ProductSubGroupID = clsProductSubGroup.DetailsByName(item.ProductSubGroup).ProductSubGroupID; if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, ProductSubGroupID, item.ProductID, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(item, strCouponRemarks); } } } break; case PromoLevel.Variation: lstItems = mclsSalesTransactionDetails.TransactionItemsList .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup, x.ProductSubGroup, x.ProductID, x.VariationsMatrixID }) .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = data.Key.ProductSubGroup, ProductID = data.Key.ProductID, VariationsMatrixID = data.Key.VariationsMatrixID, Amount = data.Sum(x => x.Amount) }).ToList(); foreach (Data.SalesTransactionItemDetails item in lstItems) { decPromoBySupplierValue = -1; decItemAmount = item.Amount; ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID; ProductSubGroupID = clsProductSubGroup.DetailsByName(item.ProductSubGroup).ProductSubGroupID; if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, ProductSubGroupID, item.ProductID, item.VariationsMatrixID, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(item, strCouponRemarks); } } } break; } } clsEvent.AddEventLn("done...", true); } catch (Exception ex) { clsEvent.AddEventLn("Error printing coupon", true); clsEvent.AddErrorEventLn(ex); } finally { clsPromoBySupplier.CommitAndDispose(); } } #endregion InsertAuditLog(AccessTypes.CloseTransaction, "Close transaction #: " + mclsSalesTransactionDetails.TransactionNo + "... Subtotal: " + mclsSalesTransactionDetails.SubTotal.ToString("#,###.#0") + " Discount: " + mclsSalesTransactionDetails.Discount.ToString("#,###.#0") + " AmountPaid: " + mclsSalesTransactionDetails.AmountPaid.ToString("#,###.#0") + " CashPayment: " + CashPayment.ToString("#,###.#0") + " ChequePayment: " + ChequePayment.ToString("#,###.#0") + " CreditCardPayment: " + CreditCardPayment + " CreditPayment: " + CreditPayment.ToString("#,###.#0") + " DebitPayment: " + DebitPayment.ToString("#,###.#0") + " ChangeAmount: " + ChangeAmount.ToString("#,###.#0") + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode); clsEvent.AddEventLn("Done! Transaction no. " + mclsSalesTransactionDetails.TransactionNo + " has been closed. Subtotal: " + mclsSalesTransactionDetails.SubTotal.ToString("#,###.#0") + " Discount: " + mclsSalesTransactionDetails.Discount.ToString("#,###.#0") + " AmountPaid: " + mclsSalesTransactionDetails.AmountPaid.ToString("#,###.#0") + " CashPayment: " + CashPayment.ToString("#,###.#0") + " ChequePayment: " + ChequePayment.ToString("#,###.#0") + " CreditCardPayment: " + CreditCardPayment + " CreditPayment: " + CreditPayment.ToString("#,###.#0") + " DebitPayment: " + DebitPayment.ToString("#,###.#0") + " ChangeAmount: " + ChangeAmount.ToString("#,###.#0"), true); }