public void PostCreditInvoiceCompletedSignalToNav(Config config, Guid invoiceId, string invoiceNumber)
        {
            var url     = config.NavApiBaseUrl + "/" + config.NavPath + $"/companies({config.NavCompanyId})/salesCreditMemos";
            var newUrl  = url + $"({invoiceId.ToString()})/Microsoft.NAV.Cancel";
            var client  = NAV.NAVClient(newUrl, config);
            var request = new RestRequest(Method.POST);

            request.AddHeader("Content-Type", "application/json");

            IRestResponse response = client.Execute(request);

            if (response.Content == "")
            {
                //posted successfully
                CreditNote _invoice = _context.CreditNote.FirstOrDefault(x => x.Credit_Note_Number == invoiceNumber);
                if (_invoice != null)
                {
                    _invoice.IsNavPosted           = true;
                    _context.Entry(_invoice).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    _context.SaveChanges();
                }
            }
            else
            {
                string errorMessage = "Error Credit Note post, Credit Note= " + invoiceId + " Message= " + response.Content + "  " + DateTime.Now.ToString() + Environment.NewLine;
                WriteToFile(Path.GetFullPath("logs/"), "NAVSyncLog.log", errorMessage);

                //_logger.LogError("Error Credit Note post, Credit Note= " + invoiceId + " Message= " + response.Content + "  " + DateTime.Now.ToString());
            }
        }
Ejemplo n.º 2
0
    protected void btnget_Click(object sender, EventArgs e)
    {
        string from = txtfromDate.Text.Split('/')[2] + "/" + txtfromDate.Text.Split('/')[1] + "/" + txtfromDate.Text.Split('/')[0];
        string To   = txttoDate.Text.Split('/')[2] + "/" + txttoDate.Text.Split('/')[1] + "/" + txttoDate.Text.Split('/')[0];

        fdate = Convert.ToDateTime(from);
        tdate = Convert.ToDateTime(To);
        if (fdate > tdate)
        {
            MessageBox("From Date is Greater than ToDate");
            txtfromDate.Focus();
        }
        else
        {
            DataTable dt = new DataTable();
            dt = CreditNote.GetTotalCN_Bydt(Convert.ToInt32(strFY), fdate, tdate).Tables[0];
            if (dt.Rows.Count > 0)
            {
                Session["CNlist"] = dt;
                show(dt);
            }
            else
            {
                MessageBox("No Records Found");
            }
        }
        //show();
    }
Ejemplo n.º 3
0
    protected void DDLCustomer_SelectedIndexChanged(object sender, EventArgs e)
    {
        frdate = txtFromDate.Text.Split('/')[2] + "/" + txtFromDate.Text.Split('/')[1] + "/" + txtFromDate.Text.Split('/')[0];
        todate = txttoDate.Text.Split('/')[2] + "/" + txttoDate.Text.Split('/')[1] + "/" + txttoDate.Text.Split('/')[0];

        tdt = Convert.ToDateTime(todate);
        fdt = Convert.ToDateTime(frdate);

        // Rptrpending.DataSource = CreditNote.GetCNNo_byCust(Convert.ToInt32(DDLCustomer.SelectedValue));
        RptrCN.DataSource = CreditNote.GetCNNo_byCust(Convert.ToInt32(strFY), (DDLCustomer.SelectedValue), "All", fdt, tdt);
        RptrCN.DataBind();

        //RptrCN2.DataSource = CreditNote.GetCNNo_byCust((DDLCustomer.SelectedValue), "Manual");
        //RptrCN2.DataBind();

        RptrCN.Visible = true;
        // RptrCN2.Visible = true;
        PnlPrint.Visible = false;
        Pnl2.Visible     = true;

        //DataTable dt = new DataTable();
        //dt = DCReturnBook.GetCustAddress((DDLCustomer.SelectedValue), "CNCustlist").Tables[0];
        //if (dt.Rows.Count > 0)
        //{
        //    lblCustName.Text = dt.Rows[0]["CustName"].ToString();
        //    lblCustAddress.Text = dt.Rows[0]["Address"].ToString();
        //}

        if (DDLCustomer.SelectedIndex == 0)
        {
            Pnl2.Visible     = false;
            PnlPrint.Visible = false;
        }
    }
Ejemplo n.º 4
0
        /// <summary>
        /// Used only for cancelling document
        /// </summary>
        /// <param name="documentEntity"></param>
        private void Save(CreditNote documentEntity)
        {
            tblDocument docToSave = SaveDocument(documentEntity);
            CreditNote r = documentEntity as CreditNote;
            docToSave.InvoiceOrderId = r.InvoiceId;
            foreach (CreditNoteLineItem rli in r.LineItems)
            {
                tblLineItems ll = null;
                if (docToSave.tblLineItems.Any(n => n.id == rli.Id))
                    ll = docToSave.tblLineItems.First(n => n.id == rli.Id);
                else
                {
                    ll = new tblLineItems();
                    ll.id = rli.Id;
                    ll.DocumentID = documentEntity.Id;
                    docToSave.tblLineItems.Add(ll);

                }
                ll.ProductID = rli.Product.Id;
                ll.Value = rli.Value;
                ll.Quantity = rli.Qty;
                ll.Description = rli.Description;
                ll.LineItemSequenceNo = rli.LineItemSequenceNo;
            }
            _ctx.SaveChanges();
        }
        public void UpdateCreditNote(CreditNoteForm CreditNote)
        {
            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    CreditNote obj = entities.CreditNotes.Where(e => e.CN_No == CreditNote.CreditNote.CreditNo
                                                                ).SingleOrDefault();
                    if (obj != null)
                    {
                        if (!string.IsNullOrEmpty(CreditNote.CreditNote.CustomerDebitNoteAmount))
                        {
                            CreditNote.CreditNote.CDNAmount = Convert.ToDecimal(CreditNote.CreditNote.CustomerDebitNoteAmount);
                        }

                        obj.Cus_DN_No     = CreditNote.CreditNote.CustomerDebitNoteNo;
                        obj.Cus_DN_Date   = CreditNote.CreditNote.CustomerDebitNoteDate;
                        obj.Cus_DN_Amount = CreditNote.CreditNote.CDNAmount;
                        obj.ModifiedDate  = DateTime.Now;
                        entities.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        ///     Loads the credit note information on the page
        /// </summary>
        /// <param name="creditNoteID"></param>
        public void loadCreditNote(int creditNoteID)
        {
            creditNote = CreditNoteViewModel.getCreditNote(creditNoteID);
            if (creditNote != null)
            {
                // Customer details
                textBox_Customer.Text        = creditNote.customer.CustomerName;
                textBox_Contact_Details.Text = creditNote.customer.PhoneNumber.ToString();
                textBox_Email_Address.Text   = creditNote.customer.Email;
                textBox_Address.Text         = creditNote.customer.Address + ", " + creditNote.customer.City + ", " +
                                               creditNote.customer.Country;

                // Credit Note details
                txtBox_creditNoteNumber.Text       = creditNote.idCreditNote.ToString();
                txtBox_creditNoteNumber.IsReadOnly = true;
                txtBox_createdDate.Text            = creditNote.createdDate.ToString("d");
                txtBox_issuedBy.Text       = creditNote.issuedBy;
                NetTotal_TextBlock.Text    = creditNote.cost.ToString("C");
                Vat_TextBlock.Text         = creditNote.VAT.ToString("C");
                TotalAmount_TextBlock.Text = creditNote.totalCost.ToString("C");

                // Credit Note products
                creditNoteProductsGrid.ItemsSource = creditNote.products;
            }
            else
            {
                MessageBox.Show("Credit Note with ID = " + creditNoteID + ", does not exist");
            }
        }
Ejemplo n.º 7
0
        public async Task <bool> StoreNewCreditNoteAsync(int InvoiceId, CreditNote CreditNote)
        {
            CreditNote.InvoiceId = InvoiceId;

            _context.CreditNotes.Add(CreditNote);
            return((await _context.SaveChangesAsync()) > 0);
        }
Ejemplo n.º 8
0
        private async Task InvokeCreditNoteSP(CreditNoteDto creditNoteData, CreditNote res)
        {
            //Create the credit note number
            await _dbCtx.Database.OpenConnectionAsync();

            var connection = _dbCtx.Database.GetDbConnection();

            var command = connection.CreateCommand();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "SP_Save_CreditNote";
            command.Parameters.Add(new MySqlParameter("selectedIdCreditNote", creditNoteData.Id));
            command.Parameters.Add(new MySqlParameter("selectedYear", creditNoteData.Year));
            command.Parameters.Add(new MySqlParameter("issuedBy", new Guid(_claimPrincipal.Value.Identity.Name)));
            var cnNum = (int?)command.ExecuteScalar();
            await _dbCtx.Database.CloseConnectionAsync();

            if (cnNum.HasValue)
            {
                var desc = "No error description avaialle";
                if (cnNum.Value == 1062)
                {
                    desc = "Duplicate credit note number!!";
                }
                _dbCtx.CreditNotes.Remove(res);
                throw new Exception($"Unable to create ad store credit note number. ERR-NO={cnNum} {desc}");
            }
        }
    protected void btnget_Click(object sender, EventArgs e)
    {
        Session["Datacn"] = null;
        Session["Typ"]    = null;
        Session["Typ"]    = "N";
        string Selectedcn = "";
        bool   checkAll   = false;

        if (Chkbxlstcn.Items[0].Selected == true)
        {
            checkAll = true;
        }
        for (int i = 1; i < Chkbxlstcn.Items.Count; i++)
        {
            if (checkAll == true)
            {
                Selectedcn = Selectedcn + Chkbxlstcn.Items[i].Value.ToString() + ",";
            }
            else if (Chkbxlstcn.Items[i].Selected == true)
            {
                Selectedcn = Selectedcn + Chkbxlstcn.Items[i].Value.ToString() + ",";
            }
        }
        // Selectedcn = Selectedcn ;
        DataTable dt = new DataTable();

        dt = CreditNote.Get_PrintCN_multiple(Convert.ToInt32(strFY), Selectedcn).Tables[0];
        Session["Datacn"] = dt;
        fillReport();
    }
    private void GSTPrint()
    {
        string Selectedcn = "";
        bool   checkAll   = false;

        if (Chkbxlstcn.Items[0].Selected == true)
        {
            checkAll = true;
        }
        for (int i = 1; i < Chkbxlstcn.Items.Count; i++)
        {
            if (checkAll == true)
            {
                Selectedcn = Selectedcn + Chkbxlstcn.Items[i].Value.ToString() + ",";
            }
            else if (Chkbxlstcn.Items[i].Selected == true)
            {
                Selectedcn = Selectedcn + Chkbxlstcn.Items[i].Value.ToString() + ",";
            }
        }
        // Selectedcn = Selectedcn ;
        DataTable dt = new DataTable();

        dt = CreditNote.Get_PrintCN_multiple(Convert.ToInt32(strFY), Selectedcn).Tables[0];
        Session["Datacn"] = dt;
        if (Session["Datacn"] != null)
        {
            DataTable dt5 = new DataTable();
            dt5 = (DataTable)Session["Datacn"];
            ReportDocument CR = new ReportDocument();
            CR.Load(Server.MapPath("Report/GSTCNPrint1.rpt"));
            CR.SetDataSource(dt5);
            Crptcnprint.ReportSource = CR;
        }
    }
        internal static CreditNoteRefundList getCreditnoteRefundList(HttpResponseMessage responce)
        {
            var creditnoterefundList = new CreditNoteRefundList();
            var jsonObj =
                JsonConvert.DeserializeObject <Dictionary <string, object> >(responce.Content.ReadAsStringAsync().Result);

            if (jsonObj.ContainsKey("creditnote_refunds"))
            {
                var refundsArray =
                    JsonConvert.DeserializeObject <List <object> >(jsonObj["creditnote_refunds"].ToString());
                foreach (var refundObj in refundsArray)
                {
                    var creditnote = new CreditNote();
                    creditnote = JsonConvert.DeserializeObject <CreditNote>(refundObj.ToString());
                    creditnoterefundList.Add(creditnote);
                }
            }
            if (jsonObj.ContainsKey("page_context"))
            {
                var pageContext = new PageContext();
                pageContext = JsonConvert.DeserializeObject <PageContext>(jsonObj["page_context"].ToString());
                creditnoterefundList.page_context = pageContext;
            }
            return(creditnoterefundList);
        }
Ejemplo n.º 12
0
        public void Delete(CreditNote creditNote)
        {
            var creditNoteItem = testContext.CreditNote.Find(creditNote.CrNoteNo, creditNote.CrNoteDate, creditNote.ProductId, creditNote.OrderId, creditNote.OrderDate);

            testContext.CreditNote.Remove(creditNoteItem);
            testContext.SaveChanges();
        }
        public void SubmitChanges(CreditNote document, BasicConfig config)
        {
            int sequence = 0;
            var envelope = new CommandEnvelope();
            envelope.Initialize(document);
            List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute();

            CreateCommand createCommand= commandsToExecute.OfType<CreateCommand>().FirstOrDefault();
            if (createCommand != null)
                envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand));
               // _commandRouter.RouteDocumentCommand(createCommand);
            List<AfterCreateCommand> lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>().ToList();
            foreach (var item in lineItemCommands)
            {
                envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item));
                //_commandRouter.RouteDocumentCommand(item);
                
            }

            ConfirmCreditNoteCommand confirmCreditNoteCommand = commandsToExecute.OfType<ConfirmCreditNoteCommand>().FirstOrDefault();
            if (confirmCreditNoteCommand != null)
                envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCreditNoteCommand));

               // _commandRouter.RouteDocumentCommand(confirmCreditNoteCommand);
            _commandEnvelopeRouter.RouteCommandEnvelope(envelope);
           
        }
Ejemplo n.º 14
0
    protected void Grd5_RowEditing(object sender, GridViewEditEventArgs e)
    {
        try
        {
            int    rtqty5    = Convert.ToInt32(((Label)Grd5.Rows[e.NewEditIndex].FindControl("lbl5rtqty")).Text);
            string BookCode5 = ((Label)Grd5.Rows[e.NewEditIndex].FindControl("lbl5bkcode")).Text;
            string CustCode5 = ((Label)Grd5.Rows[e.NewEditIndex].FindControl("lbl5custcode")).Text;

            GrdView.DataSource = CreditNote.Get_DC_CNBkview(Convert.ToInt32(strFY), CustCode5, BookCode5);
            GrdView.DataBind();
            if (rtqty5 != 0)
            {
                Pnl5CustDetails.Visible = true;
                Pnl5.Visible            = true;
                PnlBkdetails.Visible    = true;
                Pnlview.Visible         = true;
                lbbkcode1.Text          = ((Label)Grd5.Rows[e.NewEditIndex].FindControl("lbl5bkcode")).Text;
                lbName1.Text            = ((Label)Grd5.Rows[e.NewEditIndex].FindControl("lbl5Name")).Text;
            }
            else
            {
                Pnl5CustDetails.Visible = true;
                Pnl5.Visible            = true;
                PnlBkdetails.Visible    = false;
                Pnlview.Visible         = false;
            }
        }
        catch
        {
        }
    }
Ejemplo n.º 15
0
    protected void btnget_Click(object sender, EventArgs e)
    {
        lblviewCNNo.Text = txtCnno.Text.Trim();
        CNNo             = Convert.ToInt32(txtCnno.Text.Trim());
        // Bindgrdcn();
        //grdcn.DataSource = CreditNote.PrintCN(CNNo);
        //grdcn.DataBind();
        DataSet grid = new DataSet();

        grid = CreditNote.EditCN(Convert.ToInt32(strFY), CNNo);
        grdBookDetails.DataSource = grid;
        grdBookDetails.DataBind();
        Session["tempDCData1"] = grid.Tables[0];
        DataSet ds6 = new DataSet();

        ds6 = CreditNote.PrintCN(Convert.ToInt32(strFY), CNNo);

        if (ds6.Tables[1].Rows.Count > 0)
        {
            txtCNDate.Text      = ds6.Tables[1].Rows[0]["CNDate"].ToString();
            lblCustN.Text       = ds6.Tables[1].Rows[0]["CustName"].ToString();
            lbledit.Text        = Convert.ToInt32(ds6.Tables[1].Rows[0]["IsEdit"]).ToString();
            txtGCN.Text         = ds6.Tables[1].Rows[0]["GCN"].ToString();
            txtSCN.Text         = ds6.Tables[1].Rows[0]["SCN"].ToString();
            txtlRNO.Text        = ds6.Tables[1].Rows[0]["LrNo"].ToString();
            lbltransporter.Text = ds6.Tables[1].Rows[0]["TransportName"].ToString();
            lblflagdc.Text      = ds6.Tables[1].Rows[0]["Flag"].ToString();
            CustCode            = ds6.Tables[1].Rows[0]["CustCode"].ToString();
            if (ds6.Tables[1].Rows[0]["IsExciseApplicable"].ToString() == "1")
            {
                ISExcise.Checked = true;
            }
            else
            {
                ISExcise.Checked = false;
            }
        }

        if (lbledit.Text == "0")
        {
            btn_Save.Enabled     = false;
            btn_Save.BorderColor = System.Drawing.Color.Red;
            btn_Save.ToolTip     = "Record Editing Locked";
        }
        else
        {
            btn_Save.BorderColor = System.Drawing.Color.Green;
            btn_Save.Enabled     = true;
            btn_Save.ToolTip     = "";
        }

        btn_Save.Visible = true;
        PnlAddbk.Visible = true;

        PnlPrint.Visible = false;
        btnPrint.Visible = false;

        grdBookDetails.Focus();
        //UpdatePanel1.Update();
    }
Ejemplo n.º 16
0
        public static CreditNoteDto ToDto(this CreditNote e, bool includeReceipt = false)
        {
            if (e == null)
            {
                return(null);
            }

            var res = new CreditNoteDto();

            res.Id               = e.Id;
            res.Description      = e.Description;
            res.InvoiceNumber    = e.InvoiceNumber;
            res.CreditNoteNumber = e.CreditNoteNumber;
            res.IdReceipt        = e.IdReceipt;
            res.InvoiceDate      = e.InvoiceDate;
            res.IssueDate        = e.IssueDate;
            res.IssuedBy         = e.IssuedBy;
            res.Owner            = e.Owner != null?e.Owner.ToDto() : null;

            if (includeReceipt)
            {
                res.PaymentReceipt = e.PaymentReceipt.ToDto();
            }
            return(res);
        }
        /// <summary>
        ///     Loads the credit note information on the page
        /// </summary>
        /// <param name="creditNoteId"></param>
        public void loadCreditNote(int creditNoteId)
        {
            oldCreditNote = CreditNoteViewModel.getCreditNote(creditNoteId);
            if (oldCreditNote != null)
            {
                // Customer details
                textBox_Customer.Text        = oldCreditNote.customer.CustomerName;
                textBox_Contact_Details.Text = oldCreditNote.customer.PhoneNumber.ToString();
                textBox_Email_Address.Text   = oldCreditNote.customer.Email;
                textBox_Address.Text         = oldCreditNote.customer.Address + ", " + oldCreditNote.customer.City + ", " +
                                               oldCreditNote.customer.Country;

                // Invoice details
                textBox_invoiceNumber.Text = oldCreditNote.idCreditNote.ToString();
                txtbox_invoiceDate.Text    = oldCreditNote.createdDate.ToString("d");
                ;
                issuedBy.Text              = oldCreditNote.issuedBy;
                NetTotal_TextBlock.Text    = oldCreditNote.cost.ToString("C");
                Vat_TextBlock.Text         = oldCreditNote.VAT.ToString("C");
                TotalAmount_TextBlock.Text = oldCreditNote.totalCost.ToString("C");

                foreach (var p in oldCreditNote.products)
                {
                    ProductDataGrid.Items.Add(p);
                }

                comboBox_invoiceID.ItemsSource =
                    InvoiceViewModel.getCustomerInvoices(oldCreditNote.customer.idCustomer);
            }
            else
            {
                MessageBox.Show("Credit Note id doesnt't exist");
            }
        }
Ejemplo n.º 18
0
    protected void btnget_Click(object sender, EventArgs e)
    {
        lblviewCNNo.Text = txtCnno.Text.Trim();
        CNNo             = Convert.ToInt32(txtCnno.Text.Trim());
        DateTime cndate;

        // Bindgrdcn();
        grdcn.DataSource = CreditNote.PrintCN(Convert.ToInt32(strFY), CNNo);
        grdcn.DataBind();
        DataSet ds = new DataSet();

        ds = CreditNote.PrintCN(Convert.ToInt32(strFY), CNNo);
        if (ds.Tables[1].Rows.Count > 0)
        {
            lblCustName.Text    = ds.Tables[1].Rows[0]["CustName"].ToString();
            lblCustAddress.Text = ds.Tables[1].Rows[0]["Address"].ToString();
            lblCNDate.Text      = ds.Tables[1].Rows[0]["CNDate"].ToString();
        }
        PnlPrint.Visible  = true;
        btnDelete.Visible = true;
        bool i = Global.ValidateDate(lblCNDate.Text.ToString());

        if (i == true)
        {
        }
        else
        {
            btnDelete.Visible = false;
            lblAuditMsg.Text  = "You cannot delete CN with CNDate Less than Audit CutOffDate:" + Session["AuditCutOffDate"].ToString();
        }
    }
Ejemplo n.º 19
0
        public IDataResult <CreditNote> Add(CreditNote creditNote)
        {
            Random value = new Random();

            creditNote.FindeksValue = value.Next(0, 1901);
            _creditNoteDal.Add(creditNote);
            return(new SuccessDataResult <CreditNote>(creditNote, Messages.Completed));
        }
Ejemplo n.º 20
0
        public void Update(CreditNote creditNote)
        {
            var creditNoteItem = testContext.CreditNote.Find(creditNote.CrNoteNo, creditNote.CrNoteDate, creditNote.ProductId, creditNote.OrderId, creditNote.OrderDate);

            creditNoteItem.ModifiedBy = creditNote.ModifiedBy;
            creditNoteItem.IsReturned = creditNote.IsReturned;
            testContext.SaveChanges();
        }
Ejemplo n.º 21
0
 private CreditNote Map(tblDocument tblDoc)
 {
     var cn = new CreditNote(tblDoc.Id);
     _Map(tblDoc, cn);
     cn.InvoiceId = tblDoc.InvoiceOrderId == null ? Guid.Empty : tblDoc.InvoiceOrderId.Value;
     cn._SetLineItems(tblDoc.tblLineItems.Select(n => MapCreditLineItem(n)).ToList());
     return cn;
 }
 public TimeEntryListItemViewModel(CreditNote timeEntry, InvoiceListItemView invoice, IUserRepository userRepository, IDataService dataService)
 {
     _timeEntry              = ConvertCreditNoteToTimeEntry(timeEntry);
     _invoice                = invoice;
     _userRepository         = userRepository;
     _dataService            = dataService;
     ExcludeTimeEntryCommand = new DelegateCommand(ExecuteExcludeTimeEntry, () => TimeEntry.IsStopped);
 }
Ejemplo n.º 23
0
 public static CreditNote[] GetByInvoice(int invoice_id)
 {
     DataTable tbl = GetDataTableByInvoice(invoice_id);
     CreditNote[] list = new CreditNote[tbl.Rows.Count];
     for (int i = 0; i < tbl.Rows.Count; i++)
         list[i] = LoadAll(tbl.Rows[i]);
     return list;
 }
Ejemplo n.º 24
0
        private Xero.Api.Core.Model.CreditNote CreateCreditNote(CreditNote CreditNote)
        {
            Xero.Api.Core.Model.CreditNote xeroCreditNote = new Xero.Api.Core.Model.CreditNote
            {
                Number       = CreditNote.No,
                Date         = CreditNote.TransactionDate,
                Type         = Xero.Api.Core.Model.Types.CreditNoteType.AccountsPayable,
                Status       = Xero.Api.Core.Model.Status.InvoiceStatus.Authorised,
                Reference    = CreditNote.ReferenceNumber,
                CurrencyCode = CreditNote.Currency.Value,
                SubTotal     = (decimal)CreditNote.SubTotalExcl,
                TotalTax     = (decimal)CreditNote.VATTotal,
                Total        = (decimal)CreditNote.TotalIncl,
                Contact      = XeroFunctions.CoreApi().Contacts.Find(CreditNote.Vendor.AccountingPartnerIdentifier)
            };

            CreditNote.AccountingPartnerIdentifier = xeroCreditNote.Id.ToString();

            if (xeroCreditNote.Contact == null)
            {
                xeroCreditNote.Contact = new Xero.Api.Core.Model.Contact()
                {
                    Name          = CreditNote.Vendor.FullName,
                    IsCustomer    = true,
                    FirstName     = CreditNote.Vendor.FirstName,
                    LastName      = CreditNote.Vendor.LastName,
                    TaxNumber     = CreditNote.Vendor.VATNo,
                    EmailAddress  = CreditNote.Vendor.Email,
                    ContactNumber = CreditNote.Vendor.CellNo,
                    AccountNumber = CreditNote.Vendor.ExternalAccountsCode
                };

                CreditNote.Vendor.AccountingPartnerIdentifier = xeroCreditNote.Contact.Id.ToString();
            }

            foreach (WorkflowItem workflowItem in CreditNote.Items)
            {
                if (xeroCreditNote.LineItems == null)
                {
                    xeroCreditNote.LineItems = new List <Xero.Api.Core.Model.LineItem>();
                }

                Xero.Api.Core.Model.LineItem lineItem = new Xero.Api.Core.Model.LineItem()
                {
                    Description = workflowItem.Description,
                    Quantity    = (decimal)workflowItem.Quantity,
                    UnitAmount  = (decimal)workflowItem.SellingPrice,
                    TaxAmount   = (decimal)workflowItem.VATTotal,
                    LineAmount  = (decimal)workflowItem.TotalIncl
                };

                xeroCreditNote.LineItems.Add(lineItem);

                workflowItem.AccountingPartnerIdentifier = lineItem.LineItemId.ToString();
            }

            return(xeroCreditNote);
        }
Ejemplo n.º 25
0
    protected void btngetcust_Click(object sender, EventArgs e)
    {
        Pnl2.Visible     = false;
        PnlAddbk.Visible = false;
        btn_Save.Visible = false;
        PnlPrint.Visible = false;
        btnPrint.Visible = false;

        frdate = txtFromDate.Text.Split('/')[2] + "/" + txtFromDate.Text.Split('/')[1] + "/" + txtFromDate.Text.Split('/')[0];
        todate = txttoDate.Text.Split('/')[2] + "/" + txttoDate.Text.Split('/')[1] + "/" + txttoDate.Text.Split('/')[0];

        fdt = Convert.ToDateTime(frdate);
        tdt = Convert.ToDateTime(todate);

        if (tdt >= fdt)
        {
            if (RdbtnSelect.SelectedValue == "CN")
            {
                Pnl1.Visible = false;

                RptrCN2.DataSource = CreditNote.GetCNNo_Bydt(Convert.ToInt32(strFY), fdt, tdt);
                RptrCN2.DataBind();

                RptrCN2.Visible = true;
                // RptrCN2.Visible = true;
                PnlPrint.Visible = false;
                Pnl2.Visible     = true;
                PnlAddbk.Visible = false;
            }
            if (RdbtnSelect.SelectedValue == "CustomerwiseCN")
            {
                DataSet ds = new DataSet();
                ds = CreditNote.GetCustlist_Bydt(Convert.ToInt32(strFY), fdt, tdt);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DDLCustomer.DataSource = CreditNote.GetCustlist_Bydt(Convert.ToInt32(strFY), fdt, tdt);
                    DDLCustomer.DataBind();
                    DDLCustomer.Items.Insert(0, new ListItem("-Select Customer-", "0"));
                    Pnl1.Visible = true;
                }
                else
                {
                    MessageBox("Records Not Available ");
                }
            }
        }
        else
        {
            MessageBox("From Date is greater than To Date");
        }
        //else
        //if (Convert.ToDateTime(todate) == Convert.ToDateTime(frdate))
        //{
        //    MessageBox("From Date and To Date are similar");

        //}
        DDLCustomer.Focus();
    }
Ejemplo n.º 26
0
        public int UpdateRefundToCustomer(RefundToCustomerForm psForm)
        {
            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    foreach (var item in psForm.RefundToCustomerDetails)
                    {
                        CashAndBankTransaction obj = entities.CashAndBankTransactions.Where(e => e.Cash_Cheque_No == psForm.RefundToCustomer.CashChequeNo &&
                                                                                            e.SO_CN_PO_DN_No == item.SalesNo).SingleOrDefault();
                        if (obj != null)
                        {
                            obj.Acc_Id           = psForm.RefundToCustomer.AccountId;
                            obj.Amount           = psForm.RefundToCustomer.Amount;
                            obj.Cash_Cheque_No   = psForm.RefundToCustomer.CashChequeNo;
                            obj.Cash_Cheque_Date = psForm.RefundToCustomer.Date;
                            obj.Remarks          = psForm.RefundToCustomer.Remarks;

                            obj.Is_Cheque = psForm.RefundToCustomer.IsCheque;

                            //saving details entity
                            obj.SO_CN_PO_DN_No   = item.SalesNo;
                            obj.SO_CN_PO_DN_Date = item.SalesDate;
                            obj.SO_CN_PO_DN_Amt  = item.SalesAmount;
                            obj.Amt_Due          = obj.Amt_Due = item.AmountDue - item.AmountAdjusted;
                            obj.Amt_Refunded     = item.AmountAdjusted;
                            obj.Discount         = item.Discount;

                            obj.UpdatedBy   = 0;
                            obj.UpdatedDate = DateTime.Now;
                            entities.SaveChanges();

                            if (item.AmountDue == 0 && item.AmountAdjusted == item.SalesAmount)
                            {
                                CreditNote dn    = entities.CreditNotes.Where(e => e.CN_No == item.SalesNo).SingleOrDefault();
                                SalesOrder order = entities.SalesOrders.Where(e => e.SO_No == item.SalesNo).SingleOrDefault();
                                if (dn != null)
                                {
                                    dn.CN_Status = Convert.ToByte(DN_Status.Refunded);
                                    entities.SaveChanges();
                                }
                                else if (order != null)
                                {
                                    order.SO_Status = Convert.ToByte(PO_Status.Refunded);
                                    entities.SaveChanges();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(psForm.RefundToCustomer.ID);
        }
Ejemplo n.º 27
0
        public static Result <Invoice> ApplyCreditNote(Invoice invoice, CreditNote creditNoteToApply, out CreditNote creditNote)
        {
            creditNote = creditNoteToApply;
            if (!string.IsNullOrEmpty(invoice.AppliedCreditNote))
            {
                if (creditNoteToApply == null)
                {
                    return(new Result <Invoice>(-1, -1, $"creditNoteNotExist_msg | {invoice.AppliedCreditNote}"));
                }

                if (creditNoteToApply.Applied)
                {
                    return(new Result <Invoice>(-1, -1, $"creditNoteApplied_msg | {invoice.AppliedCreditNote},{creditNoteToApply.ModifiedByName}"));
                }

                if (creditNoteToApply.CurrencyId != invoice.CurrencyId)
                {
                    return(new Result <Invoice>(-1, -1, $"differentCurrency_msg | {invoice.AppliedCreditNote},{creditNoteToApply.ModifiedByName}"));
                }

                if (creditNoteToApply.Amount > invoice.TotalAmount)
                {
                    return(new Result <Invoice>(-1, -1, "amountIsGreater_msg"));
                }

                creditNoteToApply.Applied = true;

                creditNoteToApply.ModifiedBy           = invoice.CreatedBy;
                creditNoteToApply.ModifiedDate         = DateTime.Now;
                creditNoteToApply.AppliedInvoiceNumber = invoice.InvoiceNumber;
                creditNote = creditNoteToApply;
                invoice.AppliedCreditNote       = creditNoteToApply.Sequence;
                invoice.AppliedCreditNoteAmount = creditNoteToApply.Amount;
                invoice.PaidAmount += creditNoteToApply.Amount;
                //  invoice.OwedAmount -= creditNoteToApply.Amount;
                invoice.OwedAmount = invoice.OwedAmount < 0 ? 0 : invoice.OwedAmount;
                // Invoice.MontoAdeudado -= creditNoteToApply.Monto;
                //invoice.InvoiceLeads.ForEach(d =>
                //{
                //    decimal porcentajeNC = (d.TotalAmount / invoice.TotalAmount) / d.Quantity;
                //    d.CreditNoteAmount = porcentajeNC * creditNoteToApply.Amount;


                //});

                return(new Result <Invoice>(0, 0, "ok_msg", new List <Invoice>()
                {
                    invoice
                }));
            }

            return(new Result <Invoice>(0, 0, "ok_msg", new List <Invoice>()
            {
                invoice
            }));;
        }
        /// <summary>
        ///     Given the credit note object inserts it in to the database
        /// </summary>
        /// <param name="creditNote"></param>
        public static void insertCreditNote(CreditNote creditNote)
        {
            try
            {
                //insert invoice
                var query =
                    "INSERT INTO CreditNote (idCreditNote, idCustomer, Cost, Vat, TotalCost, CreatedDate, PreviousBalance, IssuedBy) Values (@idCreditNote, @idCustomer, @Cost, @Vat, @TotalCost, @CreatedDate, @PreviousBalance, @IssuedBy)";

                using (var cmd = new MySqlCommand(query, conn))
                {
                    // Now we can start using the passed values in our parameters:
                    cmd.Parameters.AddWithValue("@idCreditNote", creditNote.idCreditNote);
                    cmd.Parameters.AddWithValue("@idCustomer", creditNote.customer.idCustomer);
                    cmd.Parameters.AddWithValue("@Cost", creditNote.cost);
                    cmd.Parameters.AddWithValue("@Vat", creditNote.VAT);
                    cmd.Parameters.AddWithValue("@TotalCost", creditNote.totalCost);
                    cmd.Parameters.AddWithValue("@CreatedDate", creditNote.createdDate);
                    cmd.Parameters.AddWithValue("@IssuedBy", creditNote.issuedBy);
                    cmd.Parameters.AddWithValue("@PreviousBalance", creditNote.customer.Balance);
                    // Execute the query
                    cmd.ExecuteNonQuery();
                }

                //insert product
                var sCommand =
                    new StringBuilder(
                        "INSERT INTO CreditNoteProduct (idCreditNote, idProduct, idInvoice, Quantity) VALUES ");
                var Rows = new List <string>();


                foreach (var p in creditNote.products)
                {
                    Rows.Add(string.Format("('{0}','{1}','{2}','{3}')",
                                           MySqlHelper.EscapeString(creditNote.idCreditNote.ToString()),
                                           p.idProduct, MySqlHelper.EscapeString(p.productInvoiceID.ToString()), p.Quantity));

                    using (var cmd3 = new MySqlCommand("UPDATE Product SET Stock = REPLACE(Stock,Stock,Stock+" +
                                                       p.Quantity + ") WHERE idProduct=" + p.idProduct + ";", conn))
                    {
                        cmd3.ExecuteNonQuery();
                    }
                }

                sCommand.Append(string.Join(",", Rows));
                sCommand.Append(";");
                using (var myCmd = new MySqlCommand(sCommand.ToString(), conn))
                {
                    myCmd.CommandType = CommandType.Text;
                    myCmd.ExecuteNonQuery();
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 29
0
        public Allocation Allocate(CreditNote creditNote, Allocation allocation)
        {
            string requestXml = ModelSerializer.Serialize(allocation);

            string responseXml = _proxy.ApplyAllocation(creditNote, requestXml);

            Response response = ModelSerializer.DeserializeTo <Response>(responseXml);

            return(response.GetTypedProperty <Allocation>().First());
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Updates an existing credit note.
        /// </summary>
        /// <param name="creditnote_id">The creditnote_id is the identifier of the creditnote.</param>
        /// <param name="update_info">The update_info is the Creditnote object which is having the updation details.</param>
        /// <param name="parameters">The parameters is the dictionary object which is having the optional parameters.<br></br>Those are<br></br>
        /// <table>
        /// <tr><td>ignore_auto_number_generation</td><td>Ignore auto number generation for this credit note only. On enabling this option credit note number is mandatory.</td></tr>
        /// </table>
        /// </param>
        /// <returns>Creditnote object.</returns>
        public CreditNote Update(string creditnote_id, CreditNote update_info, Dictionary <object, object> parameters)
        {
            string url  = baseAddress + "/" + creditnote_id;
            var    json = JsonConvert.SerializeObject(update_info);

            parameters.Add("JSONString", json);
            var responce = ZohoHttpClient.put(url, getQueryParameters(parameters));

            return(CreditNoteParser.getCreditnote(responce));
        }
Ejemplo n.º 31
0
        /// <summary>
        ///     Creates a credit note for a customer..
        /// </summary>
        /// <param name="new_creditnote_info">
        ///     The new_creditnote_info is the Creditnote object which contains the information to
        ///     create a new creditnote with customer_id as mandatory parameter.
        /// </param>
        /// <param name="parameters">
        ///     The parameters is the dictionary object which is having the optional parameters to the new creditnote.<br></br>
        ///     Those are listed below<br></br>
        ///     <table>
        ///         <tr>
        ///             <td>invoice_id</td><td>Create a credit note and apply it to an invoice.</td>
        ///         </tr>
        ///         <tr>
        ///             <td>ignore_auto_number_generation</td>
        ///             <td>
        ///                 Ignore auto number generation for this credit note only. On enabling this option credit note number is
        ///                 mandatory.
        ///             </td>
        ///         </tr>
        ///     </table>
        /// </param>
        /// <returns>Creditnote object.</returns>
        public CreditNote Create(CreditNote new_creditnote_info, Dictionary <object, object> parameters)
        {
            var url  = baseAddress;
            var json = JsonConvert.SerializeObject(new_creditnote_info);

            parameters.Add("JSONString", json);
            var responce = ZohoHttpClient.post(url, getQueryParameters(parameters));

            return(CreditNoteParser.getCreditnote(responce));
        }
Ejemplo n.º 32
0
    public static CreditNote LoadAll(DataRow row)
    {
        CreditNote creditNote = Load(row);

        creditNote.Staff              = StaffDB.Load(row, "staff_");
        creditNote.Staff.Person       = PersonDB.Load(row, "person_");
        creditNote.Staff.Person.Title = IDandDescrDB.Load(row, "title_title_id", "title_descr");

        return(creditNote);
    }
        public IActionResult Add(CreditNote creditNote)
        {
            var result = _creditNoteService.Add(creditNote);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Refund credit note amount.
        /// </summary>
        /// <param name="creditnote_id">The creditnote_id is the identifier of the crditnote.</param>
        /// <param name="refund_details">The refund_details is the Creditnote object which is having the refund details with date and amount parameters as mandatory.</param>
        /// <returns>Creditnote object.</returns>
        public CreditNote AddRefund(string creditnote_id, CreditNote refund_details)
        {
            string url        = baseAddress + "/" + creditnote_id + "/refunds";
            var    json       = JsonConvert.SerializeObject(refund_details);
            var    jsonstring = new Dictionary <object, object>();

            jsonstring.Add("JSONString", json);
            var responce = ZohoHttpClient.post(url, getQueryParameters(jsonstring));

            return(CreditNoteParser.getCreditnoteRefund(responce));
        }
Ejemplo n.º 35
0
        public Document CreateDocument(Guid id, DocumentType documentType, CostCentre documentIssuerCC, CostCentre documentRecipientCC, User documentIssuerUser, string DocumentReference, double? longitude=null, double? latitude=null)
        {
            Document doc = null;
            switch (documentType)
            {
                case DocumentType.Order:
                    doc = new Order(id);
                    doc = Map(doc, documentType, documentIssuerCC, documentRecipientCC, /*null, */documentIssuerUser, DocumentReference, longitude, latitude);
                    break;
                case DocumentType.DispatchNote://
                    doc = new DispatchNote(id);
                    doc = Map(doc, documentType, documentIssuerCC, documentRecipientCC, /*null, */documentIssuerUser, DocumentReference, longitude, latitude);
                    break;
                
                case DocumentType.Receipt:
                    doc = new Receipt(id);
                    doc = Map(doc, documentType, documentIssuerCC, documentRecipientCC, documentIssuerUser, DocumentReference, longitude, latitude);
                    break;
                case DocumentType.DisbursementNote:
                    doc = new DisbursementNote(id);
                    doc = Map(doc, documentType, documentIssuerCC, documentRecipientCC, documentIssuerUser, DocumentReference, longitude, latitude);
                    break;
                case DocumentType.CreditNote:
                    doc = new CreditNote(id);
                    doc = Map(doc, documentType, documentIssuerCC, documentRecipientCC, documentIssuerUser, DocumentReference, longitude, latitude);
                    break;
                case DocumentType.ReturnsNote:
                  
                    doc = new ReturnsNote(id);
                    doc = Map(doc, documentType, documentIssuerCC, documentRecipientCC, documentIssuerUser, DocumentReference, longitude, latitude);
                    break;
                case DocumentType.PaymentNote:
                    doc = new PaymentNote(id);
                    doc = Map(doc, documentType, documentIssuerCC, documentRecipientCC, documentIssuerUser, DocumentReference, longitude, latitude);
                    break;


            }

            return doc;
        }
Ejemplo n.º 36
0
 public string ApplyAllocation(CreditNote creditNote, string requestXml)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 37
0
    public static CreditNote[] GetByInvoiceIDs(int[] invoice_ids)
    {
        string sql = JoinedSql + (invoice_ids != null && invoice_ids.Length > 0 ? " WHERE invoice_id IN (" + string.Join(",", invoice_ids) + ")" : " WHERE 1<>1");
        DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0];

        CreditNote[] ret = new CreditNote[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
            ret[i] = LoadAll(tbl.Rows[i]);

        return ret;
    }
 public string ApplyAllocation(CreditNote creditNote, string body)
 {
     EnforceRateLimit();
     return _innerIntegrationProxy.ApplyAllocation(creditNote, body);
 }
Ejemplo n.º 39
0
        public string ApplyAllocation(CreditNote creditNote, string body)
        {
            Uri uri = ConstructChildResourceUri(_oauthSession.ConsumerContext.BaseEndpointUri, "CreditNotes", creditNote.CreditNoteID.ToString(), "Allocations", null);

            IConsumerRequest oauthRequest = _oauthSession.Request()
                .ForMethod("PUT")
                .WithAcceptHeader(MimeTypes.TextXml)
                .ForUri(uri)
                .SignWithToken()
                .WithBody(body);

            var consumerResponse = oauthRequest.ToConsumerResponse();

            // Check for <ApiException> response message
            if (consumerResponse.Content.StartsWith("<ApiException"))
            {
                ApiExceptionDetails details = ModelSerializer.DeserializeTo<ApiExceptionDetails>(consumerResponse.Content);
                throw new ApiException(details);
            }

            return consumerResponse.Content;
        }
Ejemplo n.º 40
0
 public ValidationResultInfo Validate(CreditNote itemToValidate)
 {
     return _Validate(itemToValidate);
 }
Ejemplo n.º 41
0
 public void SubmitToWF(CreditNote creditNote)
 {
     _confirmCreditNoteWfManager.SubmitChanges(creditNote, null);
 }
Ejemplo n.º 42
0
 public void ConfirmCommandCN()
 {
     SaveCommandCN();
     if (note != null)
     {
         using (StructureMap.IContainer c = NestedContainer)
         {
             BasicConfig config = c.GetInstance<IConfigService>().Load();
          Using<IConfirmCreditNoteWFManager>(c).SubmitChanges(note,config);
             note = null;
             ClearViewModel();
             MessageBox.Show("Credit Note Issued Succesful");
         }
     }
     else
     {
         throw new Exception("Save first ");
     }
 }
Ejemplo n.º 43
0
        public void SaveCommandCN()
        {
            using (StructureMap.IContainer c = NestedContainer)
            {
                note = new CreditNote(Guid.NewGuid());
                note.DocumentDateIssued = DateTime.Now;
                note.DocumentIssuerCostCentre = Using<ICostCentreRepository>(c).GetById(Using<IConfigService>(c).Load().CostCentreId);
                note.DocumentIssuerCostCentreApplicationId = Using<IConfigService>(c).Load().CostCentreApplicationId;
                note.DocumentIssuerUser = Using<IUserRepository>(c).GetById(Using<IConfigService>(c).ViewModelParameters.CurrentUserId);
                note.DocumentRecipientCostCentre = Using<ICostCentreRepository>(c).GetById( Using<IConfigService>(c).Load().CostCentreId);
                note.DocumentReference = "";
                note.InvoiceId = InvoiceNo;
                note.DocumentType = DocumentType.InventoryTransferNote;

                List<CreditNoteLineItem> ListitnLineitem = new List<CreditNoteLineItem>();
                //foreach (EditCNItemsViewModel item in LineItems)
                //{
                CreditNoteLineItem itnLineitem = new CreditNoteLineItem(Guid.NewGuid())
                    {
                        Description = Description,
                        LineItemSequenceNo = 0,
                        LineItemVatValue = LineItemVatValue,
                        Product = Using<IProductRepository>(c).GetById(ProductId),
                        Qty = Qty,
                        IsNew = true,
                        Value = Value
                    };
                ListitnLineitem.Add(itnLineitem);
                //}
                note._SetLineItems(ListitnLineitem);
            }
        }
 public void AddToCreditNote(CreditNote creditNote)
 {
     base.AddObject("CreditNote", creditNote);
 }
 public static CreditNote CreateCreditNote(int creditNoteID)
 {
     CreditNote creditNote = new CreditNote();
     creditNote.CreditNoteID = creditNoteID;
     return creditNote;
 }