public DataView CostAnalysis(string pGRVNo)
        {
            Receipt receipt = new Receipt(ReceiptID);
               PO PO = receipt.ReceiptInvoice.PO;
               ReceiptInvoice receiptInvoice = receipt.ReceiptInvoice;
               ReceiveDoc receiveDoc = new ReceiveDoc();
               receiveDoc.LoadByReceiptID(ReceiptID);

               Activity activity = new Activity();
               activity.LoadByPrimaryKey(receiveDoc.StoreID);
               JournalEntry UnitCostJournal = new JournalEntry(activity.AccountName, activity.SubAccountName, activity.Name, PO.Supplier.CompanyName, "", PO.PONumber, pGRVNo, receiptInvoice.STVOrInvoiceNo, receiptInvoice.TransitTransferNo, receiptInvoice.WayBillNo, receiptInvoice.InsurancePolicyNo);

            double SupplierClaim = Convert.ToDouble(GetSupplierClaim());
            double InsuranceClaim = Convert.ToDouble(GetInsuranceClaim());
            double Provision = Convert.ToDouble(Math.Round(CostBuildUp.Provision, 2));
            double GrandTotal = Math.Round(GetGrandTotal(), 2);
            double PriceDifference = Math.Round(_PriceDifference, 2);
            double Bonus = Convert.ToDouble(Math.Round(_Bonus,2));
            //Request from Mery Formula Provide by Phone
            //Wednesday October 10
            double GIT = Math.Round(GrandTotal + SupplierClaim + InsuranceClaim + _PriceDifference - Provision - Convert.ToDouble(Bonus), 2);

            // trying out Sprout Method to Handle
            if(receiveDoc.ReturnedStock)
            {
                double stock = Math.Round(GetGrandTotalForSRM(),2);
                return SRMCostAnalysis(UnitCostJournal,_CommodityType, stock, stock,ReceiptID);
            }

                if(POType.GetModes(PO.PurchaseType) == POType.STANDARD && CostBuildUp.Invoice.InvoiceTypeID != ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE && CostBuildUp.Invoice.InvoiceTypeID  != ReceiptInvoiceType.InvoiceType.CIP)
                {
                    UnitCostJournal.AddNewEntry(String.Format("Stock ({0})", _CommodityType), GrandTotal, null);
                    UnitCostJournal.AddNewEntry("ClaimFromSupplier", SupplierClaim, null);
                    UnitCostJournal.AddNewEntry("ClaimFromInsurance", InsuranceClaim, null);

                    if (PriceDifference < 0)
                    {
                        UnitCostJournal.AddNewEntry("Price Difference", null, Math.Abs(PriceDifference));
                    }
                    else if (PriceDifference > 0)
                    {
                        UnitCostJournal.AddNewEntry("Price Difference", Math.Abs(PriceDifference), null);
                    }

                    UnitCostJournal.AddNewEntry("GIT", null, GIT);
                    UnitCostJournal.AddNewEntry("Provision", null, Provision);
                    if (Bonus > 0)
                    {
                        UnitCostJournal.AddNewEntry("Other Income", null, Math.Abs(Bonus));
                    }
                }
                else if (activity.IsHealthProgram())
                {
                    UnitCostJournal.AddNewEntry(String.Format("Stock ({0})", _CommodityType), Math.Round(GrandTotal, Settings.NoOfDigitsAfterTheDecimalPoint), null);
                    if (PriceDifference < 0)
                    {
                        UnitCostJournal.AddNewEntry("Price Difference", null, Math.Abs(PriceDifference));
                    }
                    else if (PriceDifference > 0)
                    {
                        UnitCostJournal.AddNewEntry("Price Difference", Math.Abs(PriceDifference), null);
                    }
                    UnitCostJournal.AddNewEntry(String.Format("Net Asset ({0})", _Supplier), null, Math.Round(GrandTotal - PriceDifference - Bonus, Settings.NoOfDigitsAfterTheDecimalPoint));
                    if (Bonus > 0)
                    {
                        UnitCostJournal.AddNewEntry("Other Income", null, Math.Abs(Bonus));
                    }
                }
                else
                {
                    UnitCostJournal.AddNewEntry(String.Format("Stock ({0})", _CommodityType), Math.Round(GrandTotal, Settings.NoOfDigitsAfterTheDecimalPoint), null);
                    if (PriceDifference > 0)
                    {
                        UnitCostJournal.AddNewEntry("Price Difference", null, Math.Abs(PriceDifference));
                    }
                    else if (PriceDifference < 0)
                    {
                        UnitCostJournal.AddNewEntry("Price Difference", Math.Abs(PriceDifference), null);
                    }
                    UnitCostJournal.AddNewEntry(String.Format("Account Payable ({0})", _Supplier), null, Math.Round(GIT - Convert.ToDouble(GetTotalDamagedAndShortlanded())-Bonus, Settings.NoOfDigitsAfterTheDecimalPoint));
                    if (Bonus > 0)
                    {
                        UnitCostJournal.AddNewEntry("Other Income", null, Math.Abs(Bonus));
                    }
                }

            return UnitCostJournal.DefaultView();
        }
示例#2
0
        public DataView CostAnalysis(string pGRVNo)
        {
            Receipt        receipt        = new Receipt(ReceiptID);
            PO             PO             = receipt.ReceiptInvoice.PO;
            ReceiptInvoice receiptInvoice = receipt.ReceiptInvoice;
            ReceiveDoc     receiveDoc     = new ReceiveDoc();

            receiveDoc.LoadByReceiptID(ReceiptID);

            Activity activity = new Activity();

            activity.LoadByPrimaryKey(receiveDoc.StoreID);
            JournalEntry UnitCostJournal = new JournalEntry(activity.AccountName, activity.SubAccountName, activity.Name, PO.Supplier.CompanyName, "", PO.PONumber, pGRVNo, receiptInvoice.STVOrInvoiceNo, receiptInvoice.TransitTransferNo, receiptInvoice.WayBillNo, receiptInvoice.InsurancePolicyNo);

            double SupplierClaim   = Convert.ToDouble(GetSupplierClaim());
            double InsuranceClaim  = Convert.ToDouble(GetInsuranceClaim());
            double Provision       = Convert.ToDouble(Math.Round(CostBuildUp.Provision, 2));
            double GrandTotal      = Math.Round(GetGrandTotal(), 2);
            double PriceDifference = Math.Round(_PriceDifference, 2);
            double Bonus           = Convert.ToDouble(Math.Round(_Bonus, 2));
            //Request from Mery Formula Provide by Phone
            //Wednesday October 10
            double GIT = Math.Round(GrandTotal + SupplierClaim + InsuranceClaim + _PriceDifference - Provision - Convert.ToDouble(Bonus), 2);

            // trying out Sprout Method to Handle
            if (receiveDoc.ReturnedStock)
            {
                double stock = Math.Round(GetGrandTotalForSRM(), 2);
                return(SRMCostAnalysis(UnitCostJournal, _CommodityType, stock, stock, ReceiptID));
            }


            if (POType.GetModes(PO.PurchaseType) == POType.STANDARD && CostBuildUp.Invoice.InvoiceTypeID != ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE && CostBuildUp.Invoice.InvoiceTypeID != ReceiptInvoiceType.InvoiceType.CIP)
            {
                UnitCostJournal.AddNewEntry(String.Format("Stock ({0})", _CommodityType), GrandTotal, null);
                UnitCostJournal.AddNewEntry("ClaimFromSupplier", SupplierClaim, null);
                UnitCostJournal.AddNewEntry("ClaimFromInsurance", InsuranceClaim, null);

                if (PriceDifference < 0)
                {
                    UnitCostJournal.AddNewEntry("Price Difference", null, Math.Abs(PriceDifference));
                }
                else if (PriceDifference > 0)
                {
                    UnitCostJournal.AddNewEntry("Price Difference", Math.Abs(PriceDifference), null);
                }

                UnitCostJournal.AddNewEntry("GIT", null, GIT);
                UnitCostJournal.AddNewEntry("Provision", null, Provision);
                if (Bonus > 0)
                {
                    UnitCostJournal.AddNewEntry("Other Income", null, Math.Abs(Bonus));
                }
            }
            else if (activity.IsHealthProgram())
            {
                UnitCostJournal.AddNewEntry(String.Format("Stock ({0})", _CommodityType), Math.Round(GrandTotal, Settings.NoOfDigitsAfterTheDecimalPoint), null);
                if (PriceDifference < 0)
                {
                    UnitCostJournal.AddNewEntry("Price Difference", null, Math.Abs(PriceDifference));
                }
                else if (PriceDifference > 0)
                {
                    UnitCostJournal.AddNewEntry("Price Difference", Math.Abs(PriceDifference), null);
                }
                UnitCostJournal.AddNewEntry(String.Format("Net Asset ({0})", _Supplier), null, Math.Round(GrandTotal - PriceDifference - Bonus, Settings.NoOfDigitsAfterTheDecimalPoint));
                if (Bonus > 0)
                {
                    UnitCostJournal.AddNewEntry("Other Income", null, Math.Abs(Bonus));
                }
            }
            else
            {
                UnitCostJournal.AddNewEntry(String.Format("Stock ({0})", _CommodityType), Math.Round(GrandTotal, Settings.NoOfDigitsAfterTheDecimalPoint), null);
                if (PriceDifference > 0)
                {
                    UnitCostJournal.AddNewEntry("Price Difference", null, Math.Abs(PriceDifference));
                }
                else if (PriceDifference < 0)
                {
                    UnitCostJournal.AddNewEntry("Price Difference", Math.Abs(PriceDifference), null);
                }
                UnitCostJournal.AddNewEntry(String.Format("Account Payable ({0})", _Supplier), null, Math.Round(GIT - Convert.ToDouble(GetTotalDamagedAndShortlanded()) - Bonus, Settings.NoOfDigitsAfterTheDecimalPoint));
                if (Bonus > 0)
                {
                    UnitCostJournal.AddNewEntry("Other Income", null, Math.Abs(Bonus));
                }
            }

            return(UnitCostJournal.DefaultView());
        }
        private bool IsRecieveGridValid()
        {
            bool valid = true;
            for (int i = 0; i < gridRecieveView.RowCount; i++)
            {
                DataRow dr = gridRecieveView.GetDataRow(i);
                Item itm = new Item();
                itm.LoadByPrimaryKey(Convert.ToInt32(dr["ID"]));
                dr.ClearErrors();

                if (!BLL.Settings.HandleGRV && srm != true)
                //The price is entered right here if we don't handle the GRVs
                {
                    //Unless it is a receive by delivery note, price needs to be entered.
                    //txtSTVNo.Text = txtRefNo.Text;
                    if ((dr["Price/Pack"] == DBNull.Value || dr["Price/Pack"] == null ||
                         dr["Price/Pack"].ToString() == "") && deliveryNoteType == DeliveryNoteType.NotSet)
                    {
                        dr.SetColumnError("Price/Pack", @"Please fill the cost");

                        valid = false;
                    }

                    //If it is a delivery note receive, it cannot have price.
                    //var pricePerPack = "";
                    if (dr["Price/Pack"] != DBNull.Value && dr["Price/Pack"] != null)
                    {
                      var  pricePerPack = Convert.ToString(dr["Price/Pack"]);

                        if ((deliveryNoteType != DeliveryNoteType.NotSet) &&
                            (pricePerPack != "" && Convert.ToDouble(pricePerPack) != 0))
                        {
                            dr.SetColumnError("Price/Pack", @"A Delivery note receive cannot have price information");

                            valid = false;
                        }
                    }

                }

                // Require batch if the store (account type) is the program/Free store or if the EnforceBatch Setting is set to true.
                bool enforceBatch = BLL.Settings.EnforceBatchTracking;
                //Check if Empty before checking Batch
                if (lkAccounts.EditValue != null)
                {
                    var activity = new Activity();
                    activity.LoadByPrimaryKey(int.Parse(lkAccounts.EditValue.ToString()));

                    if (activity.IsHealthProgram() || enforceBatch)
                    {
                        if ((!itm.IsColumnNull("NeedExpiryBatch") && itm.NeedExpiryBatch) &&
                            (dr["Batch No"] == DBNull.Value || dr["Batch No"].ToString() == ""))
                        {
                            dr.SetColumnError("Batch No", @"Can not be Null");
                            valid = false;
                        }
                    }
                }

                if (dr["UnitID"] == DBNull.Value)
                {
                    dr.SetColumnError("UnitID", @"Can not be Null");
                    valid = false;
                }

                if (dr["Pack Qty"] == DBNull.Value)
                {
                    dr.SetColumnError("Pack Qty", @"Can not be Null");
                    valid = false;
                }

                else
                {
                    if (srm && !chkSRMForOldSystemIssues.Checked &&
                        Convert.ToDecimal(dr["Pack Qty"]) > Convert.ToDecimal(dr["IssuedQty"]))
                    {
                        dr.SetColumnError("Pack Qty", @"Can not exceed issued quantity!");
                        valid = false;
                        XtraMessageBox.Show(
                            "Returned quantity cannot be greater than the issued quantity.  Please review the grid.",
                            "SRM Error");
                    }
                }

                if ((!itm.IsColumnNull("NeedExpiryBatch") && itm.NeedExpiryBatch) && (dr["Expiry Date"] == DBNull.Value))
                {
                    dr.SetColumnError("Expiry Date", @"Can not be Null");
                    //gridRecieveView.SetColumnError(gridRecieveView.Columns[], );
                    valid = false;
                }
                else
                {
                    if (dr["Expiry Date"] != DBNull.Value)
                    {
                        DateTime expiryDate = Convert.ToDateTime(dr["Expiry Date"]);
                        if (DateTime.Today.Subtract(expiryDate).Days > 0)
                        {
                            dr["IsDamaged"] = true;
                        }
                    }
                }

                if (dr["Manufacturer"] == DBNull.Value || dr["Manufacturer"].ToString() == "")
                {
                    dr.SetColumnError("Manufacturer", @"Manufacturer cannot be left null");
                    valid = false;
                }
                gridRecieveView.RefreshData();
            }
            if (!beginningBalance && (deliveryNoteType == DeliveryNoteType.NotSet) && !srm && !BLL.Settings.HandleGRV &&
                !dxValidateRefNo.Validate())
            {
                //XtraMessageBox.Show("Please Fill the Goods Receive Note Number!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                valid = false;
            }
            else
            {
                // TODO: check if the reference number is unique.

            }

            return valid && ValidateStep2() && ValidateStep2DuplicateRows();
        }
        private void ReceiptInvoiceDialog_Load(object sender, EventArgs e)
        {
            InitializeForm();
            LayoutAndBindingByAccess();
            LoadDecimalFormatings();
            ConstructTableColumns();
            gridViewInvoiceDetail.RowStyle += new RowStyleEventHandler(gridInvoiceDetail_RowStyle);
            lkInvoiceType.Properties.DataSource = BLL.Settings.IsCenter
                ? ReceiptInvoiceType.GetAllInvoiceTypes()
                : ReceiptInvoiceType.GetAllInvoiceTypeByCode("INT"); //Internal for Hubs

            lkInvoiceType.EditValue = BLL.Settings.IsCenter ? -1 : ReceiptInvoiceType.InvoiceType.INTERNAL;
            lkCurrencyLCID.Properties.DataSource = Helpers.FormattingHelpers.GetCurrencyList();
            var etb = Convert.ToInt32(Helpers.FormattingHelpers.GetCurrencyList().ToTable().Select("Symbol = 'ETB'")[0]["ID"]);
            lkCurrencyLCID.EditValue = etb; //ETB is the default value

            PO Order = new PO(_orderID);

            if (_orderID != 0)
            {

                Activity act = new Activity();
                act.LoadByPrimaryKey(Order.StoreID);
                lblAccount.Text = act.AccountName;
                lblAccountDetail.Text = act.AccountName;
                lblSubAccount.Text = act.SubAccountName;
                lblSubAccountDetail.Text = act.SubAccountName;
                lblActivity.Text = act.Name;
                lblActivityDetail.Text = act.Name;

                lblPOType.Text = POType.GetPOTypeNameByID(Order.PurchaseType);
                lblPOTypeDetail.Text = POType.GetPOTypeNameByID(Order.PurchaseType);
                lblPONumberDetail.Text = Order.PONumber.ToString();

                //lblInvoiceNoDetail.Text =

                var poStatus = new PurchaseOrderStatus();
                poStatus.LoadByPrimaryKey(Order.PurchaseOrderStatusID);
                lblOrderStatus.Text = poStatus.Name;

                var Mode = new Mode();
                Mode.LoadByPrimaryKey(Order.ModeID);
                lblMode.Text = Mode.TypeName;
                lblModeDetail.Text = Mode.TypeName;

                var receiptInvoice = new ReceiptInvoice();

                receiptInvoice.LoadForPO(_orderID);

                try
                {
                    lblInvoiceNoDetail.Text = !receiptInvoice.IsColumnNull("STVOrInvoiceNo") ? receiptInvoice.STVOrInvoiceNo : "-";
                }
                catch (Exception)
                {
                    lblInvoiceNoDetail.Text = "-";
                }
                var invoiceType = new ReceiptInvoiceType();
                HeaderGroup.Text = "PO No: " + Order.PONumber;
            }

            //documentType
            var po = new PO(_orderID);
            var documentTypes = BLL.DocumentType.GetDocumentTypesByPOType(po.PurchaseType);
            lkDocumentType.Properties.DataSource = documentTypes;

            lkDocumentType.EditValue = documentTypes.Rows.Count > 0 ? documentTypes.Rows[0]["DocumentTypeID"] : -1;

            if (_receiptInvoiceID != 0)
            {
                ReceiptInvoice rinvoice = new ReceiptInvoice(_receiptInvoiceID);
                //bind data to invoicedetail tab
                BindInvoiceDetail(rinvoice);

                lblOrderNumber.Text = rinvoice.PO.PONumber;

                lblSupplier.Text = rinvoice.PO.Supplier.IsActive ? rinvoice.PO.Supplier.CompanyName : "";
                lblRefNo.Text = rinvoice.PO.RefNo != "" ? rinvoice.PO.RefNo : "-";
                gridGrv.DataSource = rinvoice.Receipts.DefaultView;
                txtInsurance.Text = rinvoice.InsurancePolicyNo;
                txtInvoiceNumber.Text = rinvoice.STVOrInvoiceNo;
                txtTransitNumber.Text = rinvoice.TransitTransferNo;
                txtWayBill.Text = rinvoice.WayBillNo;
                dtInvoiceDate.EditValue = !rinvoice.IsColumnNull("DateofEntry")
                    ? rinvoice.DateOfEntry
                    : DateTimeHelper.ServerDateTime;
                txtTotalValue.EditValue = !rinvoice.IsColumnNull("TotalValue") ? rinvoice.TotalValue : 0;
                lkInvoiceType.EditValue = !rinvoice.IsColumnNull("InvoiceTypeID") ? rinvoice.InvoiceTypeID : 0;
                txtInvoiceAirFreight.EditValue = !rinvoice.IsColumnNull("AirFreight") ? rinvoice.AirFreight : 0;
                txtInvoiceSeaFreight.EditValue = !rinvoice.IsColumnNull("SeaFreight") ? rinvoice.SeaFreight : 0;
                txtInvoiceInlandFreight.EditValue = !rinvoice.IsColumnNull("InlandFreight") ? rinvoice.InlandFreight : 0;
                txtInvoiceCustomDutyTax.EditValue = !rinvoice.IsColumnNull("CustomDutyTax") ? rinvoice.CustomDutyTax : 0;
                txtInvoiceCBEServiceCharge.EditValue = !rinvoice.IsColumnNull("CBE") ? rinvoice.CBE : 0;
                txtExchangeRate.EditValue = !rinvoice.IsColumnNull("ExchangeRate") ? rinvoice.ExchangeRate : 1;
                lkCurrencyLCID.EditValue = _currency = !rinvoice.IsColumnNull("LCID") ? rinvoice.LCID : 0;
                lkDocumentType.EditValue = !rinvoice.IsColumnNull("DocumentTypeID") ? rinvoice.DocumentTypeID : -1;
                DisableEditDependingOnSetting();
                var activity = new Activity();
                activity.LoadByPrimaryKey(rinvoice.ActivityID);
                if (activity.IsHealthProgram())
                {
                    txtInvoiceCustomDutyTax.EditValue = 0;
                    txtInvoiceCustomDutyTax.Enabled = false;
                }

                // var receiptINvoice = new ReceiptInvoice();
                // receiptINvoice.LoadForPO(_orderID);
                lblInvoiceNoDetail.Text = rinvoice.STVOrInvoiceNo.ToString();
                lblInvoiceTypeDetail.Text = lkInvoiceType.Text;

            }
            else
            {
                PO PO = new PO(_orderID);
                lblOrderNumber.Text = PO.PONumber;

                BindInvoiceDetailByPO(PO.ID);

                lblSupplier.Text = PO.Supplier.IsActive ? PO.Supplier.CompanyName : "_";
                lkCurrencyLCID.EditValue = 1118; //ETB is the dafault
                lblRefNo.Text = PO.RefNo != "" ? PO.RefNo : "-";

                if (PO.StoreID != null)
                {
                    var activity = new Activity();
                    activity.LoadByPrimaryKey(po.StoreID);
                    if (activity.IsHealthProgram())
                    {
                        txtInvoiceCustomDutyTax.EditValue = 0;
                        txtInvoiceCustomDutyTax.Enabled = false;
                    }
                }
                layoutGoodsReceived.Enabled = false;
            }
            //gridViewInvoiceDetail.ValidateRow += GridViewInvoiceDetailOnValidateRow;
        }
        private void lkInvoiceType_EditValueChanged(object sender, EventArgs e)
        {
            int InvoiceType = Convert.ToInt32(lkInvoiceType.EditValue);
            if (InvoiceType == ReceiptInvoiceType.InvoiceType.INVOICE_AIR)
            {

                txtTotalValue.Enabled = BLL.Settings.IsCenter;

                txtInvoiceAirFreight.Enabled = true;
                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled = false;
                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled = false;
                txtInvoiceCustomDutyTax.Enabled = true;
                txtInvoiceCBEServiceCharge.Enabled = true;
            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.INVOICE_SEA)
            {

                txtTotalValue.Enabled = BLL.Settings.IsCenter;

                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled = false;
                txtInvoiceSeaFreight.Enabled = true;
                txtInvoiceInlandFreight.Enabled = true;
                txtInvoiceCustomDutyTax.Enabled = true;
                txtInvoiceCBEServiceCharge.Enabled = true;

            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.CIP ||
                     InvoiceType == ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE)
            {

                txtTotalValue.Enabled = BLL.Settings.IsCenter;
                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled = false;

                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled = false;

                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled = false;

                txtInvoiceCustomDutyTax.EditValue = 0;
                txtInvoiceCustomDutyTax.Enabled = false;
                txtInvoiceCBEServiceCharge.EditValue = 0;
                txtInvoiceCBEServiceCharge.Enabled = false;

            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.INVENTORY)
            {

                txtTotalValue.EditValue = 0;
                txtTotalValue.Enabled = false;
                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled = false;

                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled = false;

                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled = false;

                txtInvoiceCustomDutyTax.EditValue = 0;
                txtInvoiceCustomDutyTax.Enabled = false;
                txtInvoiceCBEServiceCharge.EditValue = 0;
                txtInvoiceCBEServiceCharge.Enabled = false;

            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.STV)
            {
                txtTotalValue.Enabled = BLL.Settings.IsCenter;
                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled = false;

                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled = false;

                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled = false;

                txtInvoiceCustomDutyTax.EditValue = 0;
                txtInvoiceCustomDutyTax.Enabled = false;
                txtInvoiceCBEServiceCharge.EditValue = 0;
                txtInvoiceCBEServiceCharge.Enabled = false;

            }

            PO PO = new PO(_orderID);
            if (PO.StoreID != null)
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(PO.StoreID);
                if (activity.IsHealthProgram())
                {
                    txtInvoiceCustomDutyTax.EditValue = 0;
                    txtInvoiceCustomDutyTax.Enabled = false;
                }
            }
        }
        public void LoadByReceiptIDInvoiceIDAndPoID(int ReceiptID, int InvoiceID, int PoID, string GRNString,double GRVTotalValue)
        {
            purchaseOrder = new PO();
            Invoice = new ReceiptInvoice();
            GRV = new Receipt();

            //Load

            this.GRVTotal = GRVTotalValue;
            LoadData(ReceiptID, InvoiceID, PoID);

            _activity = new Activity();
            _activity.LoadByPrimaryKey(Invoice.ActivityID);

            Supplier = purchaseOrder.Supplier.CompanyName;
            OrderNo = purchaseOrder.PONumber;
            InvoiceNo = Invoice.STVOrInvoiceNo;
            GRVNo = GRNString;
            AWBNo = Invoice.WayBillNo;
            ShippedBy = Invoice.ShippedBy;
            if (Invoice.IsColumnNull("InvoiceTypeID") || GRV.ReceiptTypeID == ReceiptType.CONSTANTS.STOCK_RETURN)
            {
                AutoProrate = false;
                purchaseOrder.ExhangeRate = FOBExchangeRate = 1;
            }
            else if (Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.NON_STANDARD)
            {
                AutoProrate = false;
                purchaseOrder.ExhangeRate = FOBExchangeRate = 1;
            }
            else
            {

                if (purchaseOrder.PurchaseType == POType.COST_AND_EST_FREIGHT)
                {
                    ProrateUsingFreightOnPO = true;
                    ProrateUsingFreightOnInvoice = true;
                    UsePOFreight = true;
                }
                else if (purchaseOrder.PurchaseType == POType.COST_AND_FREIGHT)
                {
                    ProrateUsingFreightOnPO = true;
                    ProrateUsingFreightOnInvoice = true;
                    UsePOFreight = false;
                }
            }

                if (!_activity.IsHealthProgram())
                    UseCustomDutyTax = true;
                if (AutoProrate && Invoice.InvoiceTypeID != -255 && Invoice.InvoiceTypeID != InvoiceType.Internal)
                    Prorate();

                if (Invoice.IsColumnNull("InvoiceTypeID") || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.CIP || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.NON_STANDARD || _activity.IsHealthProgram())
                UseProvison = false;
            else
                UseProvison = true;

            CalculateCostCoefficient();
            PopulateDataTable();
        }
        private void btnConfirmIssue_Click(object sender, EventArgs e)
        {
            var Instance = new SoftwareSettings();
            Instance.GetValue("IsCenter");
            dxValidationProvider1.Validate();
            BLL.Issue stv = new BLL.Issue();
            stv.LoadByPrimaryKey(_activeSTVID);
            // bool isValid = dxValidationProvider1.Validate();
            var activity = new Activity();
            activity.LoadByPrimaryKey(stv.StoreID);

            if (activity.IsHealthProgram()) // if (!isValid && Mode.IsFreeStore(stv.StoreID))
            {
                dxValidationProvider1.RemoveControlError(txtPreprintedInvoiceNo);
            }

            if (Convert.ToBoolean(Instance.Value)) // When IsCenter is true. txtPreprintedInvoiceNo should be disabled as a requirment
            {
                dxValidationProvider1.RemoveControlError(txtPreprintedInvoiceNo);
            }

            if (Convert.ToBoolean(Instance.Value) && !activity.IsHealthProgram())
            {
                dxValidationProvider1.RemoveControlError(txtPreprintedInvoiceNo);
            }
            if (!Convert.ToBoolean(Instance.Value) && !activity.IsHealthProgram())  //   if (!isValid && !Mode.IsFreeStore(stv.StoreID))
            {
                if (!dxValidationProvider1.Validate())
                    return;
                //XtraMessageBox.Show("Please input the required fields.", "Required Fields Missing", MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
                //return;
            }
            if (XtraMessageBox.Show("Are you sure you want to confirm this dispatch?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                try
                {
                    mgr.BeginTransaction();
                    //Mark the dispatch as confirmed. (Store the differences in the dispatched values somewhere)
                    int? preprintedID;
                    if (txtPreprintedInvoiceNo.Text == "")
                        preprintedID = null;
                    else
                        preprintedID = int.Parse(txtPreprintedInvoiceNo.Text);

                    if (!stv.MarkAsDispatched(CurrentContext.UserId, preprintedID))
                    {
                        XtraMessageBox.Show("Void request has been sent for this STV, you can't dispatch it!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        throw new Exception("Void request sent on this STV number");
                    }
                    if (_discrepancyIssueDoc.Count > 0)
                    {
                        //Save the discrepancies.
                        BLL.IssueDoc.RecordDiscrepancy(_discrepancyIssueDoc);
                    }
                    this.LogActivity("Confirm-Dispatch", _activeSTVID);
                    mgr.CommitTransaction();
                    XtraMessageBox.Show("STV marked as dispatched!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception exp)
                {
                    mgr.RollbackTransaction();
                    XtraMessageBox.Show("System couldn't save the dispatch, Please contact administrator", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ErrorHandler.Handle(exp);
                }
                BindUnconfirmedIssues();
                gridUndispatchedIssueDetails.DataSource = null;
            }
        }
示例#8
0
        public void LoadByReceiptIDInvoiceIDAndPoID(int ReceiptID, int InvoiceID, int PoID, string GRNString, double GRVTotalValue)
        {
            purchaseOrder = new PO();
            Invoice       = new ReceiptInvoice();
            GRV           = new Receipt();

            //Load

            this.GRVTotal = GRVTotalValue;
            LoadData(ReceiptID, InvoiceID, PoID);

            _activity = new Activity();
            _activity.LoadByPrimaryKey(Invoice.ActivityID);


            Supplier  = purchaseOrder.Supplier.CompanyName;
            OrderNo   = purchaseOrder.PONumber;
            InvoiceNo = Invoice.STVOrInvoiceNo;
            GRVNo     = GRNString;
            AWBNo     = Invoice.WayBillNo;
            ShippedBy = Invoice.ShippedBy;
            if (Invoice.IsColumnNull("InvoiceTypeID") || GRV.ReceiptTypeID == ReceiptType.CONSTANTS.STOCK_RETURN)
            {
                AutoProrate = false;
                purchaseOrder.ExhangeRate = FOBExchangeRate = 1;
            }
            else if (Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.NON_STANDARD)
            {
                AutoProrate = false;
                purchaseOrder.ExhangeRate = FOBExchangeRate = 1;
            }
            else
            {
                if (purchaseOrder.PurchaseType == POType.COST_AND_EST_FREIGHT)
                {
                    ProrateUsingFreightOnPO      = true;
                    ProrateUsingFreightOnInvoice = true;
                    UsePOFreight = true;
                }
                else if (purchaseOrder.PurchaseType == POType.COST_AND_FREIGHT)
                {
                    ProrateUsingFreightOnPO      = true;
                    ProrateUsingFreightOnInvoice = true;
                    UsePOFreight = false;
                }
            }



            if (!_activity.IsHealthProgram())
            {
                UseCustomDutyTax = true;
            }
            if (AutoProrate && Invoice.InvoiceTypeID != -255 && Invoice.InvoiceTypeID != InvoiceType.Internal)
            {
                Prorate();
            }

            if (Invoice.IsColumnNull("InvoiceTypeID") || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.CIP || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.NON_STANDARD || _activity.IsHealthProgram())
            {
                UseProvison = false;
            }
            else
            {
                UseProvison = true;
            }

            CalculateCostCoefficient();
            PopulateDataTable();
        }