Autonumbering in Acumatica second way

In one of my previous posts I described how to add autonumbering to acumatica. Described method will work pretty well, if you don't have any pop-ups which also need to have autonumbering. In case if you have such pop-ups, then it is different story.

My next assignment on the job was to add autonumbering to the screen "Fund Transfers" which is marked as "CA301000" to the field Document ref at three places:

There is a saying, that one image is better then thousands of words :).

Here is example of my code for OutExtRefNbr:

        protected void CATransfer_OutExtRefNbr_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            var row = e.Row as CATransfer;
            if (row == null)
                return;
            var refNbr = "001224";
            e.NewValue = refNbr;
        }

 

If you have a question why on earth code below needed:

                   var row = e.Row as "Class for which we will provide extension";

                   if( row == null )

                      return;

the answer is simple: because Acumatica for some unknown reason calls method FieldDefaulting and for mysterious reason passes into e.Row null. If you have any idea why, you are welcome to share them. I don't have and just used workaround ( don't say it to my boss ).

 

The second part of my task was to add some value to pop-up window. That can be done via the following template:

public class "Class Extention name" : PXGraphExtension<"Class for which we will provide extension">

{

      protected void "Class for which we will provide extension"_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)

      {

             Base.AddFilter.Current."Field in pop-up" = "some default value";

            Base.AddFilter.Update(Base.AddFilter.Current);

       }

"Field in pop-up" you can find also in Design mode of Acumatica forms.

Here is fragment of my source code for changes:

protected void CATransfer_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
{
     Base.AddFilter.Current.ExtRefNbr = "0012224";
     Base.AddFilter.Update(Base.AddFilter.Current);
}

In case if you have any comments, ideas don't hesitate to share them via comments line.

There is a saying, that one image is better then thousands of words :).

Here is example of my code for OutExtRefNbr:

        protected void CATransfer_OutExtRefNbr_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            var row = e.Row as CATransfer;
            if (row == null)
                return;
            var refNbr = "001224";
            e.NewValue = refNbr;
        }

 

If you have a question why on earth code below needed:

                   var row = e.Row as "Class for which we will provide extension";

                   if( row == null )

                      return;

the answer is simple: because Acumatica for some unknown reason calls method FieldDefaulting and for mysterious reason passes into e.Row null. If you have any idea why, you are welcome to share them. I don't have and just used workaround ( don't say it to my boss ).

 

The second part of my task was to add some value to pop-up window. That can be done via the following template:

public class "Class Extention name" : PXGraphExtension<"Class for which we will provide extension">

{

protected void "Class for which we will provide extension"_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
{
      Base.AddFilter.Current."Field in pop-up" = "some default value";
      Base.AddFilter.Update(Base.AddFilter.Current);
}

"Field in pop-up" you can find also in Design mode of Acumatica forms.

Here is fragment of my source code for changes:

protected void CATransfer_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
{
     Base.AddFilter.Current.ExtRefNbr = "0012224";
     Base.AddFilter.Update(Base.AddFilter.Current);
}

In case if you have any comments, ideas don't hesitate to share them via comments line.

 

Copy entry types via web services in Acumatica from one instance into another

Hello everybody.

Today I want to share how to copy Entty Types items in acumaticca from one instance into another instance.

The first step was to create import export settings in both instances of acumatica as described in acumatica manual similar to this screenshot:

The second step was to create project, which I decided to make as windows forms application with the following input fields:

For the button click at entry types write the following:

           var context = new ImportEt.Screen
                {
                    CookieContainer = new CookieContainer(), AllowAutoRedirect = true, EnableDecompression = true, Timeout = 1000000, Url = txtFrom.Text
                };

           var lgRes = context.Login(txtUserName.Text, txtPassword.Text);
           if (lgRes.Code == ErrorCode.OK)
           {
                var ca203000 = context.CA203000GetSchema();
                context.CA203000Clear();


                var export = context.CA203000Export(
                    new Command[]
                        {
                            ca203000.EntryType.EntryTypeID, ca203000.EntryType.DisbReceipt, ca203000.EntryType.EntryTypeDescription, ca203000.EntryType.Module, 
ca203000.EntryType.BusinessAccount, ca203000.EntryType.DefaultOffsetAccount, ca203000.EntryType.UseForPaymentsReclassification,
ca203000.EntryType.ReclassificationAccount, ca203000.EntryType.DeductFromPayment }, null, 0, false, false); context.Url = txtTo.Text; var lgRes2 = context.Login(txtUserName.Text, txtPassword.Text); if (lgRes2.Code == ErrorCode.OK) { ca203000 = context.CA203000GetSchema(); context.CA203000Clear(); foreach (var et in export) { var ca203000ImportResults = context.CA203000Submit( new Command[] { new Value { Value = et[0], LinkedCommand = ca203000.EntryType.EntryTypeID}, new Value { Value = et[1], LinkedCommand = ca203000.EntryType.DisbReceipt }, new Value { Value = et[2], LinkedCommand = ca203000.EntryType.EntryTypeDescription }, new Value { Value = et[3], LinkedCommand = ca203000.EntryType.Module }, new Value { Value = et[4], LinkedCommand = ca203000.EntryType.BusinessAccount }, new Value { Value = et[5], LinkedCommand = ca203000.EntryType.DefaultOffsetAccount }, new Value { Value = et[6], LinkedCommand = ca203000.EntryType.UseForPaymentsReclassification }, new Value { Value = et[7], LinkedCommand = ca203000.EntryType.ReclassificationAccount }, new Value { Value = et[8], LinkedCommand = ca203000.EntryType.DeductFromPayment }, ca203000.Actions.Save }); } } }

 

All activities in Acumatica are done via interface context, whic is of type screen. 

As for me, the easiest way to get some data is via command "screenID" + export. In my code you can see construction CA203000Export. Inside of it you can point to id of screen, data of which you want to receive. For example CA203000Export.

The simplest way to send something to acumatica another instance is function "screen id" + "Submit". In my code you can see method CA203000Submit. Fields Value is self-explanatory as for me. The most important and hard to understand for me was LinkedCommand. It can be name of the field. That means values has to be putted into a field. It can be action name to push on and etc. 

Another important facet of mentioned code is Actions.Save. If it is not mentioned, than code will post data to web services, but they wil not be saved.

 

P.S.    source code

 

LiqPay for nopcommerce version 3.2

Hello everybody who is reader of my post.

As it was requested, I created also version of liqpay for nopcommerce of version 3.2. In case if you need it you can enjoy. 

For downloading of new module you can  click here.  

In case if you want to express your thankfullness, you can do it here:

http://payment.zaletskyy.com/send-600 just enter some price and choose currency which is convenient for you.

Also at forum: http://payment.zaletskyy.com/boards/forum/1/liqpay you can express your proposals in any convenient language for you.

If to compare versions 3.1 and 3.2 they have some small differences, and the biggest difference is in the interface IPaymentMethod and as result in processor LiqPayPaymentProcessor.</

Nopcommerce liqpay payment module

Hello everybody.

Today I just want to share with everybody liqpay payment module for pryvatbank. Pryvatbank is Ukrainian bank which makes possible to accept credit cards payments on your web site. If you'll install nopcommerce, then you can use my payment module absolutely for free. Later  I will modify this article with description of process of development.

You can Download  it and use it for your own. 

For downloading of 3.2 module you can  click here.  

If you wish to support future extensions of this module, you can do it here.

Web sites which use this module:

http://abc-device.com

http://payment.zaletskyy.com/en/

If you use this module as well let me know in comments

Autonumbering in Acumatica

Today I want to share with you how I implemented autonumbering feature in acumatica for page CA304000.

My task originally was the following: add autonumbering feature to the "Document Ref" field with following rules:

  a. step of incrementing is 1

  b. length of field should be six characters. For example 000001, 000002, ... ,  000223,  001024, ..., and so on

First of all I want to state that my way of adding much simpler then "canonical" ( according to acumatica manuals ) way of adding autonumbering.  If you wish to use standard way you should accomplish so many steps that I should admit that my brain wasn't able to boil them in one project. 

Instead of this I used the following steps.

1. In the page CA304000 I found class, which provides data for the page. It looks like this:

<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" PrimaryView="CAAdjRecords" TypeName="PX.Objects.CA.CATranEntry">

2. Created extention of class in the following way:

public class CATranEntryExt : PXGraphExtension<CATranEntry>
    {

3. Located method which returns list of records for the page CA304000, it was the method: CAAdjRecords.

4. According to rules of acumatica, if I want to modify behaviour of method CAAdjRecords I should implement method caadjrecords.

5. 

protected virtual IEnumerable caadjrecords()
        {

6. Implemented method which digs in DB, and returns needed number in string format:

protected string GetExtRefNbr()
        {
            var maxNbr = 1;
            foreach (var cAddjRec in PXSelect<CAAdj>.Select(Base, new byte[0]))
            {
                var extRefNbr = ((CAAdj) cAddjRec).ExtRefNbr;
                int curNbr = 0;
                if (int.TryParse(extRefNbr, out curNbr))
                {
                    maxNbr = curNbr + 1;
                }
            }
            var result = maxNbr.ToString(CultureInfo.InvariantCulture).PadLeft(defaultLength, '0');
            return result;
        }

7. Used GetExtRefNbr in the method caadjrecords in the following way:

protected virtual IEnumerable caadjrecords()
        {
            var res = new List<CAAdj>();
            var availableCashAccounts = GetAvailableCashAccounts();

            foreach (
                var doc in
                    PXSelect<CAAdj, Where<CAAdj.draft, Equal<False>>>.Select(Base, new byte[0]))
            {
                
                if (((CAAdj)doc).RefNbr.Contains("NEW"))
                {
                    ((CAAdj) doc).ExtRefNbr = GetExtRefNbr();
                }
                    
            }
            return res;
        }

8. Enjoyed results: