cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hi Guys, hope that all of you are fine!

I've been trying to deal with this on my own for a while, but honestly.. I just can't.

I'm trying to create a Customer Invoice from the sdk, as far as I know in order to do that you need first to generate a Customer Invoice Request.. here's where it gets annoying..

I tried it.. several times, with the code in the PSM (It doesn't work.. what a surprise), consuming the CustomerInvoiceRequest web service.. and nothing..

There's a web service in the system that allows to create an Invoice.. it's called ManageCustomerInvoiceRequestIn.. but i'm not able to use it..

Thanks to all of you in advance

0 Likes
View Entire Topic
Former Member
0 Likes

Melvin, I worked on this before. Are you able to achieve this by now?

If not, can you let me know what kind of errors you are getting while creation of Customer Invoice Request?

You can post the error screenshot which would be convenient for you.

May be you can go for the webservice option, ManageCustomerInvoiceRequestIn in the worst case as I think this invoice creation would be easier to create from sdk than through webservice.

former_member197479
Active Participant
0 Likes

Hi Srivatsava Janaswamy, I've been trying to do this with no further success...

Basically the error that I'm getting is a service exception, that something is missing into the Web Service.

It just doesn't have sense, I mean.. we should be able to generate an Invoice document through the PDI itself without needing to publish any web services..

Have you ever try to do this directly on a script into the PDI?

Thanks in advance!

Former Member
0 Likes

Hi Melvin,

My comments on this.

You cant create all node instances of Customer Invoice Request (CIR) BO in the ABSL of the custom BO. say for e.g. Currency code is mandatory for creating CIR and it is present under PricingTerms node. You cant assign the currency code here in the custom BO action. Also there is a create() function for this node which you cant use as creation is disabled. So to come across such strange nodes, you have to extend the CIR BO where in the extended BO before save event you can assign these node data.

Basically, some data can be assigned in the custom BO action and some can be assigned in the extension BO action. So that you can manage to get rid off those errors.

has already worked on this and was successful. So he can give you the right info to create a CI

Best regards,

Hari

Former Member
0 Likes

I have tested this code and this is working fine.

This code was written in a BeforeSave of a CustomBO.

It also contains the code for creating and releasing the Invoice after creating Request.

So, please find the syntax of creating invoice from a request(incase you missed this from studio)

I request you to use this function based on your use case.

You  might see some errors after executing this code. You can ignore them. However, both InvoiceRequest and Invoice will be created successfully.

Whatever you do, I request you NOT to change the sequence of code.

Invoice Item needs either a product or a GL account assignment. So, I have given you both examples in this code by commenting one.

Also, please make a note that you can eliminate some coding by right customer account setup.

For eg., Currency and Pricing terms can be assigned in the Sales Data of the Customer Account and so, whenever this customer along with the sales unit is used in any Customer Invoice Request, those values are picked up automatically so that you don't have to maintain them in your coding.

May be your CRM leads can help you in this setup.

import

ABSL;


import

AP.CustomerInvoicing.Global;



// define CustomerInvoiceRequest root node


var

elCustomerInvoiceRequest_Root: elementsof CustomerInvoiceRequest;


var

instCustomerInvoiceRequest;



// define CustomerInvoiceRequest BusinessProcessVariantType node


var

elCustomerInvoiceRequest_BPVT: elementsof CustomerInvoiceRequest.BusinessProcessVariantType;


var

instCustomerInvoiceRequest_BPVT;



// define CustomerInvoiceRequest buyer party node


var

elCustomerInvoiceRequest_BuyerParty: elementsof CustomerInvoiceRequest.Party;


var

instCustomerInvoiceRequest_BuyerParty;



// define CustomerInvoiceRequest sales unit party node


var

elCustomerInvoiceRequest_SalesUnitParty: elementsof CustomerInvoiceRequest.Party;


var

instCustomerInvoiceRequest_SalesUnitParty;



// define CustomerInvoiceRequest item node


var

elCustomerInvoiceRequest_Item: elementsof CustomerInvoiceRequest.Item;


var

instCustomerInvoiceRequest_Item;



var

ItemProduct : elementsof CustomerInvoiceRequest.Item.ItemProduct;



// define CustomerInvoiceRequest item accounting coding block node


var

elCustomerInvoiceRequest_ItemACBD: elementsof CustomerInvoiceRequest.Item.ItemAccountingCodingBlockDistribution;


var

instCustomerInvoiceRequest_ItemACBD;



// define CustomerInvoiceRequest item price component


var

elCustomerInvoiceRequest_Item_MainPrice: elementsof CustomerInvoiceRequest.PriceAndTaxCalculation.Item.ItemPriceComponent;


var

instCustomerInvoiceRequest_Item_MainPrice;



// InvoiceDate setting to current date for this example.


var

InvoiceDate = Context.GetCurrentUserDate();



// CustomerInvoiceRequest: create new instance




// CustomerInvoiceRequest: maintain BPVT node


// BusinessProcessVariantTypeCode = 3 describes type 'Manual Invoice'


elCustomerInvoiceRequest_BPVT

.BusinessProcessVariantTypeCode = "3";



elCustomerInvoiceRequest_Root

.CustomerInvoiceProcessingTypeCode = "CI";


instCustomerInvoiceRequest

= CustomerInvoiceRequest.Create(elCustomerInvoiceRequest_Root);


// CustomerInvoiceRequest: create new BPVT instance


// Without the BPVT node no modifications can be made to the CustomerInvoiceRequest


instCustomerInvoiceRequest_BPVT

= instCustomerInvoiceRequest.BusinessProcessVariantType.Create(elCustomerInvoiceRequest_BPVT);



// Assign currencycode


if

(!instCustomerInvoiceRequest.PricingTerms.IsSet()){


var temp = instCustomerInvoiceRequest.PricingTerms.Create();


temp.CurrencyCode = "GBP";


}


else

{


instCustomerInvoiceRequest.PricingTerms.CurrencyCode = "GBP";


}



// CustomerInvoiceRequest: maintain customer invoice processing type - mandatory


instCustomerInvoiceRequest

.CustomerInvoiceProcessingTypeCode = "CI";



// CustomerInvoiceRequest: maintain description - optional


instCustomerInvoiceRequest

.Name = "CIR From ABSL";



// CustomerInvoiceRequest:: maintain buyer party - mandatory


elCustomerInvoiceRequest_BuyerParty

.PartyKey.PartyID.content = "CP100992";



// CustomerInvoiceRequest: create new party instance


instCustomerInvoiceRequest_BuyerParty

= instCustomerInvoiceRequest.BuyerParty.Create(elCustomerInvoiceRequest_BuyerParty);



// CustomerInvoiceRequest:: maintain sales unit party - mandatory


elCustomerInvoiceRequest_SalesUnitParty

.PartyKey.PartyID.content = "P1110";



// CustomerInvoiceRequest: create new party instance


instCustomerInvoiceRequest_SalesUnitParty

= instCustomerInvoiceRequest.SalesUnitParty.Create(elCustomerInvoiceRequest_SalesUnitParty);



// Assign Cash Discount Terms


if

(!instCustomerInvoiceRequest.CashDiscountTerms.IsSet()){


var PaymentTerms = instCustomerInvoiceRequest.CashDiscountTerms.Create();


PaymentTerms.Code.content = "001";


}


else

{


instCustomerInvoiceRequest.CashDiscountTerms.Code.content = "0001";


}



// CustomerInvoiceRequest: maintain item with product



// CustomerInvoiceRequest.Item: maintain description - mandatory


elCustomerInvoiceRequest_Item

.Description.content = "Test from ABSL";



// CustomerInvoiceRequest.Item: maintain quantity - mandatory


elCustomerInvoiceRequest_Item

.Quantity.content  = 1;


elCustomerInvoiceRequest_Item

.Quantity.unitCode = "EA";



// CustomerInvoiceRequest: create item instance


instCustomerInvoiceRequest_Item

= instCustomerInvoiceRequest.Item.Create(elCustomerInvoiceRequest_Item);


if

(!instCustomerInvoiceRequest_Item.ItemProduct.IsSet()){


var instItemProduct = instCustomerInvoiceRequest_Item.ItemProduct.Create();


instItemProduct.ProductKey.ProductID.content = "P100202";


}



// CustomerInvoiceRequest.Item.ItemAccountingCodingBlockDistribution: maintain GL-account - mandatory


//elCustomerInvoiceRequest_ItemACBD.GeneralLedgerAccountAliasCode.content = "A-1500";



// CustomerInvoiceRequest.Item: create new ItemAccountingCodingBlockDistribution instance


//instCustomerInvoiceRequest_ItemACBD = instCustomerInvoiceRequest_Item.ItemAccountingCodingBlockDistribution.Create(elCustomerInvoiceRequest_ItemACBD);



// CustomerInvoiceRequest.Item.PATCItem: maintain tax code - mandatory (code 501 = Sales Tax - Standard Rate)


instCustomerInvoiceRequest_Item

.PriceAndTaxCalculationItem.TaxationCharacteristicsCode.content = "509";



// CustomerInvoiceRequest.Item.PriceAndTaxCalculationItem.ItemMainTotal: Maintain price


instCustomerInvoiceRequest_Item

.PriceAndTaxCalculationItem.ItemMainTotal.Rate.BaseDecimalValue = 150;


instCustomerInvoiceRequest_Item

.PriceAndTaxCalculationItem.ItemMainTotal.Rate.CurrencyCode     = "GBP";



// To Create Invoice from this request and to release it.


// Use the parameters of this function based on your need. Setting second parameter to "true" releases the invoice.


// Incase you miss the syntax from ByD, here you go CreateCustomerInvoices(CustomerInvoiceDate,AutomaticReleaseIndicator,BBTDBasedSeperationReqdIndicator,PDBasedSeperationReqdIndicator,InvClearingRequestedIndicator)


instCustomerInvoiceRequest

.CreateCustomerInvoices(InvoiceDate,true,false,false,false);

Message was edited by: Srivatsava Janaswamy

Former Member
0 Likes

End of whole discussion

Cheers!!!

former_member197479
Active Participant
0 Likes

Hi, Srivatsava Janaswamy, thanks for sharing this valuable information with me.

I already tried that code that you provide me, but I'm getting the following error:

Former Member
0 Likes

Did you setup the Sales Data for the customer you are trying to create?

Pricing Terms and Payment Terms can be set in the customer data.

Is this setup?

former_member197479
Active Participant
0 Likes

Everything Is set up..

I even try to generate the Manual Invoice through the system itself, with the same data and it worked.

Former Member
0 Likes

If everything is setup, then despite of the errors you get, Invoice Request should have been created.

Did you also check in the Customer Invoicing --> Inovoice Requests if the Request which you are trying to create is there or not?

And one more question. Are you using the code pasted by me or the one which you are trying with earlier?

former_member197479
Active Participant
0 Likes

Hi Srivatsava,

It doesn't appear to work for me.. I'm using the exactly same code that you provide me.

There's no Customer Invoices, or Requests created.. Something is not working..

former_member197479
Active Participant
0 Likes

Hi Srivatsava!!

It worked!!

Now I have a couple of questions, is there anyway to hide or do something in order to those error messages?

Former Member
0 Likes

Unfortunately, No Way!

Former Member
0 Likes

Hi Srivatsava Janaswamy,

              

            I copied your code , filled my data.

            The system already has enough master data for the process.

            The invoice request is created but it is not released.

            There is nothing wrong with the data because we can release the invoice request created by ABSL from Customer Invoicing work center.

             I was stuck here. Please give me some suggestions.

Best Regards,

Naing

Former Member
0 Likes

Hi, Srivatsava.

       I can release the invoice request now with a small change to your whole code. (Thanks for the detail codes)

       I had to change InvClearingRequestedIndicator to true.

instCustomerInvoiceRequest.CreateCustomerInvoices(InvoiceDate,true,false,false,true);

         I don't know why I had to change the parameter to true.

         Can you please explain?

Best Regards

Naing

0 Likes

Hi Melvin,

Could you please share your code as I am trying to create a customer invoice from SDK and have been following your thread. I am trying to create customer Invoice through a file upload, I don't see any errors in process communication as well, but it doesn't not create any invoice and exactly same values generates a manual invoice when entered through BYD work center. Could you please advise? Many Thanks.

import ABSL;

import AP.CustomerInvoicing.Global;

import AP.Common.GDT;

// define CustomerInvoiceRequest root node

var elCustomerInvoiceRequest_Root: elementsof CustomerInvoiceRequest;

var instCustomerInvoiceRequest;

// define CustomerInvoiceRequest BusinessProcessVariantType node

var elCustomerInvoiceRequest_BPVT: elementsof CustomerInvoiceRequest.BusinessProcessVariantType;

var instCustomerInvoiceRequest_BPVT;

// define CustomerInvoiceRequest buyer party node

var elCustomerInvoiceRequest_BuyerParty: elementsof CustomerInvoiceRequest.Party;

var instCustomerInvoiceRequest_BuyerParty;

// define CustomerInvoiceRequest sales unit party node

var elCustomerInvoiceRequest_SalesUnitParty: elementsof CustomerInvoiceRequest.Party;

var instCustomerInvoiceRequest_SalesUnitParty;

// define CustomerInvoiceRequest item node

var elCustomerInvoiceRequest_Item: elementsof CustomerInvoiceRequest.Item;

var instCustomerInvoiceRequest_Item;

var ItemProduct : elementsof CustomerInvoiceRequest.Item.ItemProduct;

// define CustomerInvoiceRequest item accounting coding block node

var elCustomerInvoiceRequest_ItemACBD: elementsof CustomerInvoiceRequest.Item.ItemAccountingCodingBlockDistribution;

var instCustomerInvoiceRequest_ItemACBD;

// define CustomerInvoiceRequest item price component

var elCustomerInvoiceRequest_Item_MainPrice: elementsof CustomerInvoiceRequest.PriceAndTaxCalculation.Item.ItemPriceComponent;

var instCustomerInvoiceRequest_Item_MainPrice;

// InvoiceDate setting to current date for this example.

var InvoiceDate = Context.GetCurrentUserDate();

// read the uploaded XML invoice file

Trace.Info("Started BILLING upload...", this.companyID);

// CustomerInvoiceRequest: create new instance

// CustomerInvoiceRequest: maintain BPVT node

// BusinessProcessVariantTypeCode = 3 describes type 'Manual Invoice'

elCustomerInvoiceRequest_BPVT.BusinessProcessVariantTypeCode = "3";

elCustomerInvoiceRequest_Root.CustomerInvoiceProcessingTypeCode = "CI";

instCustomerInvoiceRequest

= CustomerInvoiceRequest.Create(elCustomerInvoiceRequest_Root);

// CustomerInvoiceRequest: create new BPVT instance

// Without the BPVT node no modifications can be made to the CustomerInvoiceRequest

instCustomerInvoiceRequest_BPVT

= instCustomerInvoiceRequest.BusinessProcessVariantType.Create(elCustomerInvoiceRequest_BPVT);

// Assign currencycode

if (!instCustomerInvoiceRequest.PricingTerms.IsSet()){

  var temp = instCustomerInvoiceRequest.PricingTerms.Create();

  temp.CurrencyCode = "GBP";

}

else

{

  instCustomerInvoiceRequest.PricingTerms.CurrencyCode = "GBP";

}

// CustomerInvoiceRequest: maintain customer invoice processing type - mandatory

instCustomerInvoiceRequest

.CustomerInvoiceProcessingTypeCode = "CI";

// CustomerInvoiceRequest: maintain description - optional

instCustomerInvoiceRequest

.Name = "CIR From SDK";

// CustomerInvoiceRequest:: maintain buyer party - mandatory

elCustomerInvoiceRequest_BuyerParty

.PartyKey.PartyID.content = "DCIB001";

// CustomerInvoiceRequest: create new party instance

instCustomerInvoiceRequest_BuyerParty

= instCustomerInvoiceRequest.BuyerParty.Create(elCustomerInvoiceRequest_BuyerParty);

// CustomerInvoiceRequest:: maintain sales unit party - mandatory

elCustomerInvoiceRequest_SalesUnitParty

.PartyKey.PartyID.content = "UK02-GSAL";

// CustomerInvoiceRequest: create new party instance

instCustomerInvoiceRequest_SalesUnitParty

= instCustomerInvoiceRequest.SalesUnitParty.Create(elCustomerInvoiceRequest_SalesUnitParty);

// Assign Cash Discount Terms

if(!instCustomerInvoiceRequest.CashDiscountTerms.IsSet()){

  var PaymentTerms = instCustomerInvoiceRequest.CashDiscountTerms.Create();

  PaymentTerms.Code.content = "001";

}

else

{

  instCustomerInvoiceRequest.CashDiscountTerms.Code.content = "0001";

}

// CustomerInvoiceRequest: maintain item with product

// CustomerInvoiceRequest.Item: maintain description - mandatory

elCustomerInvoiceRequest_Item

.Description.content = "Test from Deepthi";

// CustomerInvoiceRequest.Item: maintain quantity - mandatory

elCustomerInvoiceRequest_Item

.Quantity.content  = 1;

elCustomerInvoiceRequest_Item

.Quantity.unitCode = "EA";

// CustomerInvoiceRequest: create item instance

instCustomerInvoiceRequest_Item

= instCustomerInvoiceRequest.Item.Create(elCustomerInvoiceRequest_Item);

if (!instCustomerInvoiceRequest_Item.ItemProduct.IsSet()){

  var instItemProduct = instCustomerInvoiceRequest_Item.ItemProduct.Create();

  instItemProduct.ProductKey.ProductID.content = "200001";

}

// CustomerInvoiceRequest.Item.ItemAccountingCodingBlockDistribution: maintain GL-account - mandatory

//elCustomerInvoiceRequest_ItemACBD.GeneralLedgerAccountAliasCode.content = "A-1500";

// CustomerInvoiceRequest.Item: create new ItemAccountingCodingBlockDistribution instance

//instCustomerInvoiceRequest_ItemACBD = instCustomerInvoiceRequest_Item.ItemAccountingCodingBlockDistribution.Create(elCustomerInvoiceRequest_ItemACBD);

// CustomerInvoiceRequest.Item.PATCItem: maintain tax code - mandatory (code 501 = Sales Tax - Standard Rate)

instCustomerInvoiceRequest_Item

.PriceAndTaxCalculationItem.TaxationCharacteristicsCode.content = "501";

// CustomerInvoiceRequest.Item.PriceAndTaxCalculationItem.ItemMainTotal: Maintain price

instCustomerInvoiceRequest_Item

.PriceAndTaxCalculationItem.ItemMainTotal.Rate.BaseDecimalValue = 150;

instCustomerInvoiceRequest_Item

.PriceAndTaxCalculationItem.ItemMainTotal.Rate.CurrencyCode    = "GBP";

// To Create Invoice from this request and to release it.

// Use the parameters of this function based on your need. Setting second parameter to "true" releases the invoice.

// Incase you miss the syntax from ByD, here you go CreateCustomerInvoices(CustomerInvoiceDate,AutomaticReleaseIndicator,BBTDBasedSeperationReqdIndicator,PDBasedSeperationReqdIndicator,InvClearingRequestedIndicator)

//instCustomerInvoiceRequest.CreateCustomerInvoices(InvoiceDate,true,false,false,false);

CustomerInvoice.CreateWithCustomerInvoiceRequestReference(instCustomerInvoiceRequest, Context.GetCurrentUserDate(), false, false, false, true);

Trace.Info("inv create", this.companyID);

Former Member
0 Likes

Hi Fred & Srivatsava,

We are doing a mass upload of Customer Invoice Requests and requests should be released as invoice, so I am calling the action CreateCustomerInvoices.

I also have the same problem, if I make the InvoicingClearingRequestedIndicator to true only Invoice is getting released.


CreateCustomerInvoices(InvoiceDate,true,false,false,true);


Due to this automatically Clearing ID is generated and this should not happen because we have separate file for uploading receivables part and there may be also partial payment.

Is there anyway to sort this and why it works like this?

Thanks,

Madhan