Ejemplo n.º 1
0
 public static void DeleteList(List <int> list)
 {
     BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice();
     foreach (int v in list)
     {
         // try to load by primary key
         bv.LoadByPrimaryKey(v);
         // if the entry doesn't exist, create it
         if (bv.RowCount > 0)
         {
             bv.MarkAsDeleted();
             bv.Save();
         }
         // populate the contents of v on the to the database list
     }
 }
        public static Receipt CreateAutomaticReceiptInvoiceForSTVTransfer(int POID, int warehouseID, int IDPrinted, int userID)
        {
            BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
            rctInvoice.AddNew();

            //Enter Invoice Related Information
            //We should Save the STV Number Here
            rctInvoice.POID           = POID;
            rctInvoice.STVOrInvoiceNo = IDPrinted.ToString("00000");
            rctInvoice.ExchangeRate   = 1;
            rctInvoice.Insurance      = 0;
            rctInvoice.DateOfEntry    = DateTimeHelper.ServerDateTime;
            rctInvoice.IsDeliveryNote = false;
            rctInvoice.Save();
            //Save the receipt
            BLL.Receipt receipt   = new Receipt();
            int         receiptID = receipt.AddNewReceipt(BLL.ReceiptType.CONSTANTS.STANDARD_RECEIPT, warehouseID, userID, rctInvoice.ID, null, ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED);

            receipt.LoadByPrimaryKey(receiptID);
            return(receipt);
        }
Ejemplo n.º 3
0
        public static void SaveList(List <HCMIS.Desktop.STVSyncService.STVList> list, int userID)
        {
            BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice();
            foreach (HCMIS.Desktop.STVSyncService.STVList v in list)
            {
                // try to load by primary key
                bv.LoadBySTVNoAndAccountType(v.STVNo, v.AccountID);

                // if the entry doesn't exist, create it
                if (bv.RowCount == 0)
                {
                    BLL.PO po = new BLL.PO();
                    po.AddNew();
                    if (v.AccountID.HasValue)
                    {
                        po.StoreID = v.AccountID.Value;
                    }
                    po.SupplierID = BLL.Supplier.CONSTANTS.HOME_OFFICE;
                    if (v.HubID.HasValue)
                    {
                        po.PONumber = v.HubID.Value + "-" + v.STVNo;
                    }
                    po.Save();

                    bv.AddNew();
                    bv.STVOrInvoiceNo = v.STVNo.ToString();
                    bv.InvoiceTypeID  = BLL.ReceiptInvoiceType.InvoiceType.STV;
                    bv.DateOfEntry    = DateTimeHelper.ServerDateTime;
                    bv.POID           = po.ID;
                    bv.SavedByUserID  = userID;
                }
                // populate the contents of v on the to the database list
                bv.TotalValue    = v.InvoiceTotalValue;
                bv.Insurance     = v.Insurance;
                bv.SavedByUserID = userID;
                bv.Save();
            }
        }
        public static Receipt CreateReceiptInvoiceAndReceiptForTransfer(int receiptTypeID, int POID, int warehouseID, int IDPrinted, int userID)
        {
            BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
            rctInvoice.AddNew();
            var po = new BLL.PO();

            po.LoadByPrimaryKey(POID);
            var activityID = po.StoreID;

            //Enter Invoice Related Information
            //We should Save the STV Number Here
            rctInvoice.POID           = POID;
            rctInvoice.STVOrInvoiceNo = IDPrinted.ToString("00000");
            rctInvoice.ExchangeRate   = 1;
            rctInvoice.Insurance      = 0;
            rctInvoice.DateOfEntry    = DateTimeHelper.ServerDateTime;
            rctInvoice.SavedByUserID  = userID;
            rctInvoice.ActivityID     = activityID;
            rctInvoice.IsDeliveryNote = false;
            rctInvoice.InvoiceTypeID  = BLL.InvoiceType.InternalSTV;

            rctInvoice.PrintedDate  = DateTimeHelper.ServerDateTime;
            rctInvoice.Rowguid      = Guid.NewGuid();
            rctInvoice.IsVoided     = false;
            rctInvoice.ShippingSite = " ";
            rctInvoice.IsConvertedFromDeliveryNote = false;
            rctInvoice.DocumentTypeID = DocumentType.CONSTANTS.STV;

            rctInvoice.Save();
            //Save the receipt
            BLL.Receipt receipt   = new Receipt();
            int         receiptID = receipt.AddNewReceipt(receiptTypeID, warehouseID, userID, rctInvoice.ID, null, ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED);

            receipt.LoadByPrimaryKey(receiptID);
            return(receipt);
        }
 private void btnSTV_Click(object sender, EventArgs e)
 {
     BLL.Receipt receipt = new BLL.Receipt();
     receipt.LoadByPrimaryKey(ReceiptID);
     receipt.STVOrInvoiceNo = txtSTVNo.EditValue.ToString();
     receipt.Save();
     ReceiptInvoice invoice = new ReceiptInvoice();
     invoice.LoadByPrimaryKey(receipt.ReceiptInvoiceID);
     invoice.STVOrInvoiceNo = txtSTVNo.EditValue.ToString();
     invoice.Save();
     this.LogActivity("Set-New-STV-No", ReceiptID);
     XtraMessageBox.Show("STV Number has been saved");
 }
        private int SaveRelevantReceiptHeaders(int receiptTypeID, int warehouseID)
        {
            int receiptID;
            var receipt = new BLL.Receipt();
            var sup = new BLL.Supplier();

            if (lkReceiptInvoice.EditValue != null && Convert.ToInt32(lkReceiptInvoice.EditValue) != -1)
            {
                receiptID = receipt.AddNewReceipt(receiptTypeID, warehouseID, CurrentContext.UserId,
                    Convert.ToInt32(lkReceiptInvoice.EditValue), txtEditTransferNo.Text,
                    ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED);
                // , txtTransitNo.Text, txtInsuranceNo.Text, txtWayBillNo.Text);
            }
            else
            {
                //PO and ReceiptInvoice created automatically.
                //Needs to be fixed.
                BLL.PO po = new PO();
                BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();

                po.AddNew();
                var serverDateTime = DateTimeHelper.ServerDateTime;
                po.PODate = serverDateTime;
                po.DateOfEntry = serverDateTime;
                po.PurchaseType = POType.INVENTORY;
                po.IsElectronic = false;
                po.POFinalized = false;
                po.Rowguid = Guid.NewGuid();
                po.Identifier = "00000";

                po.PaymentTypeID = BLL.PaymentType.Constants.STV;
                po.TermOfPayement = BLL.PaymentTerm.Internal;
                po.PurchaseOrderStatusID = PurchaseOrderStatus.Processed;

                rctInvoice.AddNew();

                po.StoreID = Convert.ToInt32(lkAccounts.EditValue);
                Activity acc = new Activity();
                acc.LoadByPrimaryKey(po.StoreID);
                po.ModeID = acc.ModeID;

                //po.PONumber = srm ? lkSTVInvoiceNo.EditValue.ToString() : (deliveryNote ? txtRefNo.Text : (beginningBalance ? "BeginningBalance" : String.Empty));

                if (lcSTVNo.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always)
                {
                    po.PONumber = srm && !chkSRMForOldSystemIssues.Checked
                        ? txtSTVNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtSTVNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtRefNo.Text)));
                }
                else
                {
                    po.PONumber = srm && !chkSRMForOldSystemIssues.Checked
                        ? lkSTVInvoiceNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtRefNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtRefNo.Text)));
                }

                   //TODO: Ugly hack, supplier. To be fixed.
                    if (srm)
                    {
                        po.SupplierID = BLL.Supplier.CONSTANTS.RETURNED_FROM_FACILITY;

                        //Let's put Finance Required stuff here.
                        po.Insurance = 0;
                        po.ExhangeRate = 1;
                        rctInvoice.ExchangeRate = 1;
                        rctInvoice.Insurance = 0;

                        rctInvoice.InvoiceTypeID = ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE;

                        if (chkSRMForOldSystemIssues.Checked)
                        {
                            if (lkForFacility.EditValue == null)
                                throw new Exception("Facility not chosen!");
                            po.RefNo = lkForFacility.EditValue.ToString();
                        }
                    }

                po.SavedbyUserID = CurrentContext.LoggedInUser.ID;
                po.Save();

                rctInvoice.POID = po.ID;
                if (lcSTVNo.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always)
                {
                    rctInvoice.STVOrInvoiceNo = srm && !chkSRMForOldSystemIssues.Checked
                        ? txtSTVNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtSTVNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtSTVNo.Text)));
                }
                else
                {
                    rctInvoice.STVOrInvoiceNo = srm && !chkSRMForOldSystemIssues.Checked
                        ? lkSTVInvoiceNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtRefNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtRefNo.Text)));
                }
                rctInvoice.DateOfEntry = DateTimeHelper.ServerDateTime;
                rctInvoice.ActivityID = po.StoreID;
                rctInvoice.SavedByUserID = CurrentContext.LoggedInUser.ID;
                rctInvoice.IsDeliveryNote = false;

                rctInvoice.Rowguid = Guid.NewGuid();
                rctInvoice.PrintedDate = po.DateOfEntry;
                rctInvoice.IsVoided = false;
                rctInvoice.ShippingSite = " ";
                rctInvoice.IsConvertedFromDeliveryNote = false;
                rctInvoice.IsDeliveryNote = false;
                rctInvoice.DocumentTypeID = DocumentType.CONSTANTS.SRM;

                rctInvoice.Save();

                receiptID = receipt.AddNewReceipt(receiptTypeID, warehouseID, CurrentContext.UserId, rctInvoice.ID,
                    txtTransitTransferVoucherNo.Text, ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED);

                //receiptID = receipt.AddNewReceipt(receiptTypeID, NewMainWindow.UserId);
            }
            return receiptID;
        }
        private void btnSaveInvoice_Click(object sender, EventArgs e)
        {
            PO po = new PO(_orderID);
            if (dxValidation.Validate())
            {
                ReceiptInvoice invoice = new ReceiptInvoice();
                if (_receiptInvoiceID != 0)
                {
                    invoice.LoadByPrimaryKey(_receiptInvoiceID);

                }
                else
                {
                    invoice.AddNew();
                }
                //TODO: save the Invoice Type Here.
                invoice.InvoiceTypeID = 1;
                invoice.InsurancePolicyNo = txtInsurance.Text;
                double TotalValue = 0;
                if (!invoice.IsColumnNull("TotalValue"))
                {
                    TotalValue = invoice.TotalValue;
                }
                if (_receiptInvoiceID != 0 && po.Remaining + TotalValue < Convert.ToDouble(txtTotalValue.EditValue)
                    && POType.GetModes(po.PurchaseType) == POType.STANDARD)
                {
                    XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value",
                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
                invoice.TotalValue = Convert.ToDouble(txtTotalValue.EditValue);
                if (po.Remaining < invoice.TotalValue && POType.GetModes(po.PurchaseType) == POType.STANDARD &&
                    _receiptInvoiceID == 0)
                {
                    XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value",
                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }

                invoice.WayBillNo = txtWayBill.Text;
                invoice.TransitTransferNo = txtTransitNumber.Text;
                invoice.STVOrInvoiceNo = txtInvoiceNumber.Text;
                invoice.POID = _orderID;
                invoice.SavedByUserID = CurrentContext.UserId;
                invoice.AirFreight = Convert.ToDouble(txtInvoiceAirFreight.EditValue);
                invoice.SeaFreight = Convert.ToDouble(txtInvoiceSeaFreight.EditValue);
                invoice.InlandFreight = Convert.ToDouble(txtInvoiceInlandFreight.EditValue);
                invoice.CustomDutyTax = Convert.ToDouble(txtInvoiceCustomDutyTax.EditValue);
                invoice.CBE = Convert.ToDouble(txtInvoiceCBEServiceCharge.EditValue);
                invoice.InvoiceTypeID = Convert.ToInt32(lkInvoiceType.EditValue);
                invoice.DateOfEntry = Convert.ToDateTime(dtInvoiceDate.EditValue);
                invoice.ExchangeRate = Convert.ToDouble(txtExchangeRate.EditValue);
                invoice.LCID = Convert.ToInt32(lkCurrencyLCID.EditValue);
                invoice.ActivityID = po.StoreID;
                invoice.Rowguid = Guid.NewGuid();
                invoice.PrintedDate = dtInvoiceDate.DateTime;
                invoice.IsVoided = false ;
                invoice.ShippingSite = " ";
                invoice.IsConvertedFromDeliveryNote = false;
                invoice.IsDeliveryNote = Convert.ToInt32(lkDocumentType.EditValue) == DocumentType.CONSTANTS.DLVN;
                if (Convert.ToInt32(lkDocumentType.EditValue) != -1)
                    invoice.DocumentTypeID = Convert.ToInt32(lkDocumentType.EditValue);
                invoice.Save();
                this.LogActivity("Save-Invoice", invoice.ID);

                lblInvoiceNoDetail.Text = txtInvoiceNumber.EditValue.ToString();
                lblInvoiceTypeDetail.Text = lkInvoiceType.Text;

                BLL.Receipt receipt = new BLL.Receipt();
                receipt.UpdateInvoiceRelatedHeaders(invoice);
                _receiptInvoiceID = invoice.ID;
                MessageBox.Show("Invoice saved!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                HeaderGroupDetail.Text = "Invoice No: " + txtInvoiceNumber.EditValue.ToString();
            }
        }
        public static Receipt CreateReceiptInvoiceAndReceiptForTransfer(int receiptTypeID, int POID, int warehouseID, int IDPrinted, int userID)
        {
            BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
            rctInvoice.AddNew();
            var po = new BLL.PO();
            po.LoadByPrimaryKey(POID);
            var activityID = po.StoreID;

            //Enter Invoice Related Information
            //We should Save the STV Number Here
            rctInvoice.POID = POID;
            rctInvoice.STVOrInvoiceNo = IDPrinted.ToString("00000");
            rctInvoice.ExchangeRate = 1;
            rctInvoice.Insurance = 0;
            rctInvoice.DateOfEntry = DateTimeHelper.ServerDateTime;
            rctInvoice.SavedByUserID = userID;
            rctInvoice.ActivityID = activityID;
            rctInvoice.IsDeliveryNote = false;
            rctInvoice.InvoiceTypeID = BLL.InvoiceType.InternalSTV;

            rctInvoice.PrintedDate = DateTimeHelper.ServerDateTime;
            rctInvoice.Rowguid = Guid.NewGuid();
            rctInvoice.IsVoided = false;
            rctInvoice.ShippingSite = " ";
            rctInvoice.IsConvertedFromDeliveryNote = false;
            rctInvoice.DocumentTypeID = DocumentType.CONSTANTS.STV;

            rctInvoice.Save();
            //Save the receipt
            BLL.Receipt receipt = new Receipt();
            int receiptID = receipt.AddNewReceipt(receiptTypeID, warehouseID, userID, rctInvoice.ID, null, ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED);
            receipt.LoadByPrimaryKey(receiptID);
            return receipt;
        }
        public static Receipt CreateAutomaticReceiptInvoiceForSTVTransfer(int POID, int warehouseID, int IDPrinted, int userID)
        {
            BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
            rctInvoice.AddNew();

            //Enter Invoice Related Information
            //We should Save the STV Number Here
            rctInvoice.POID = POID;
            rctInvoice.STVOrInvoiceNo = IDPrinted.ToString("00000");
            rctInvoice.ExchangeRate = 1;
            rctInvoice.Insurance = 0;
            rctInvoice.DateOfEntry = DateTimeHelper.ServerDateTime;
            rctInvoice.IsDeliveryNote = false;
            rctInvoice.Save();
            //Save the receipt
            BLL.Receipt receipt = new Receipt();
            int receiptID = receipt.AddNewReceipt(BLL.ReceiptType.CONSTANTS.STANDARD_RECEIPT, warehouseID, userID, rctInvoice.ID, null, ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED);
            receipt.LoadByPrimaryKey(receiptID);
            return receipt;
        }
Ejemplo n.º 10
0
        private void btnSaveInvoice_Click(object sender, EventArgs e)
        {
            PO po = new PO(_orderID);

            if (dxValidation.Validate())
            {
                ReceiptInvoice invoice = new ReceiptInvoice();
                if (_receiptInvoiceID != 0)
                {
                    invoice.LoadByPrimaryKey(_receiptInvoiceID);
                }
                else
                {
                    invoice.AddNew();
                }
                //TODO: save the Invoice Type Here.
                invoice.InvoiceTypeID     = 1;
                invoice.InsurancePolicyNo = txtInsurance.Text;
                double TotalValue = 0;
                if (!invoice.IsColumnNull("TotalValue"))
                {
                    TotalValue = invoice.TotalValue;
                }
                if (_receiptInvoiceID != 0 && po.Remaining + TotalValue < Convert.ToDouble(txtTotalValue.EditValue) &&
                    POType.GetModes(po.PurchaseType) == POType.STANDARD)
                {
                    XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value",
                                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
                invoice.TotalValue = Convert.ToDouble(txtTotalValue.EditValue);
                if (po.Remaining < invoice.TotalValue && POType.GetModes(po.PurchaseType) == POType.STANDARD &&
                    _receiptInvoiceID == 0)
                {
                    XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value",
                                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }

                invoice.WayBillNo         = txtWayBill.Text;
                invoice.TransitTransferNo = txtTransitNumber.Text;
                invoice.STVOrInvoiceNo    = txtInvoiceNumber.Text;
                invoice.POID          = _orderID;
                invoice.SavedByUserID = CurrentContext.UserId;
                invoice.AirFreight    = Convert.ToDouble(txtInvoiceAirFreight.EditValue);
                invoice.SeaFreight    = Convert.ToDouble(txtInvoiceSeaFreight.EditValue);
                invoice.InlandFreight = Convert.ToDouble(txtInvoiceInlandFreight.EditValue);
                invoice.CustomDutyTax = Convert.ToDouble(txtInvoiceCustomDutyTax.EditValue);
                invoice.CBE           = Convert.ToDouble(txtInvoiceCBEServiceCharge.EditValue);
                invoice.InvoiceTypeID = Convert.ToInt32(lkInvoiceType.EditValue);
                invoice.DateOfEntry   = Convert.ToDateTime(dtInvoiceDate.EditValue);
                invoice.ExchangeRate  = Convert.ToDouble(txtExchangeRate.EditValue);
                invoice.LCID          = Convert.ToInt32(lkCurrencyLCID.EditValue);
                invoice.ActivityID    = po.StoreID;
                invoice.Rowguid       = Guid.NewGuid();
                invoice.PrintedDate   = dtInvoiceDate.DateTime;
                invoice.IsVoided      = false;
                invoice.ShippingSite  = " ";
                invoice.IsConvertedFromDeliveryNote = false;
                invoice.IsDeliveryNote = Convert.ToInt32(lkDocumentType.EditValue) == DocumentType.CONSTANTS.DLVN;
                if (Convert.ToInt32(lkDocumentType.EditValue) != -1)
                {
                    invoice.DocumentTypeID = Convert.ToInt32(lkDocumentType.EditValue);
                }
                invoice.Save();
                this.LogActivity("Save-Invoice", invoice.ID);

                lblInvoiceNoDetail.Text   = txtInvoiceNumber.EditValue.ToString();
                lblInvoiceTypeDetail.Text = lkInvoiceType.Text;

                BLL.Receipt receipt = new BLL.Receipt();
                receipt.UpdateInvoiceRelatedHeaders(invoice);
                _receiptInvoiceID = invoice.ID;
                MessageBox.Show("Invoice saved!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                HeaderGroupDetail.Text = "Invoice No: " + txtInvoiceNumber.EditValue.ToString();
            }
        }
        public static void SaveList(List<HCMIS.Desktop.STVSyncService.STVList> list, int userID)
        {
            BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice();
            foreach (HCMIS.Desktop.STVSyncService.STVList v in list)
            {
                // try to load by primary key
                bv.LoadBySTVNoAndAccountType(v.STVNo, v.AccountID);

                // if the entry doesn't exist, create it
                if (bv.RowCount == 0)
                {
                    BLL.PO po = new BLL.PO();
                    po.AddNew();
                    if (v.AccountID.HasValue)
                        po.StoreID = v.AccountID.Value;
                    po.SupplierID = BLL.Supplier.CONSTANTS.HOME_OFFICE;
                    if (v.HubID.HasValue)
                        po.PONumber = v.HubID.Value + "-" + v.STVNo;
                    po.Save();

                    bv.AddNew();
                    bv.STVOrInvoiceNo = v.STVNo.ToString();
                    bv.InvoiceTypeID = BLL.ReceiptInvoiceType.InvoiceType.STV;
                    bv.DateOfEntry = DateTimeHelper.ServerDateTime;
                    bv.POID = po.ID;
                    bv.SavedByUserID = userID;
                }
                // populate the contents of v on the to the database list
                bv.TotalValue = v.InvoiceTotalValue;
                bv.Insurance = v.Insurance;
                bv.SavedByUserID = userID;
                bv.Save();
            }
        }
        public static void DeleteList(List<int> list)
        {
            BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice();
            foreach (int v in list)
            {
                // try to load by primary key
                bv.LoadByPrimaryKey(v);
                // if the entry doesn't exist, create it
                if (bv.RowCount > 0)
                {
                    bv.MarkAsDeleted();
                    bv.Save();
                }
                // populate the contents of v on the to the database list

            }
        }