Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Altering existing Voucher creating new Voucher #23

Open
saivineeth100 opened this issue Feb 28, 2023 · 1 comment
Open

Altering existing Voucher creating new Voucher #23

saivineeth100 opened this issue Feb 28, 2023 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@saivineeth100
Copy link
Member

          As per your suggestion, I am retrieving voucher first. And then immediately posting same voucher without any modification, via PostVoucherAsync() method. Still Tally is creating new voucher, insteading of updating existing one.

voucher = await tally.GetVoucherAsync<TCM.Voucher>(_invoice.Tally_MasterId.ToString(), new TCM.VoucherRequestOptions()
                {
                    LookupField = TCM.VoucherLookupField.MasterId,
                    FetchList = TCM.Constants.Voucher.InvoiceViewFetchList.All
                });

                if (voucher != null)
                {
                    var resultVT = await tally.PostVoucherAsync<TCM.Voucher>(voucher);

                    if (resultVT.Status == TCM.RespStatus.Sucess)
                    {
                        var y = System.Text.RegularExpressions.Regex.Matches(resultVT.Response!, @"[0-9.]+")[0].Value;
                        _invoice.Tally_MasterId = int.Parse(y ?? "0");
                        _context.Invoices.Update(_invoice);
                        await _context.SaveChangesAsync();
                    }

                }

Originally posted by @drparasmehta in #5 (comment)

@saivineeth100 saivineeth100 self-assigned this Feb 28, 2023
@saivineeth100 saivineeth100 added the bug Something isn't working label Feb 28, 2023
@saivineeth100
Copy link
Member Author

Use this workaround until its fixed.

Add below code before PostVoucherAsync You can find example here VoucherAlterTest

        XmlDocument doc = new XmlDocument();
        XmlAttribute TagNameAttribute = doc.CreateAttribute("TAGNAME");
        TagNameAttribute.Value = "MasterId";
        XmlAttribute TagValueAttribute = doc.CreateAttribute("TAGVALUE");
        TagValueAttribute.Value = voucher.MasterId.ToString();
        voucher.OtherAttributes = new XmlAttribute[] { TagNameAttribute, TagValueAttribute };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant