create Invoice

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

create Invoice

info@agentur-m3.de
Hello!

This is an ofbiz-beginners question, which arose while trying my
first steps with ofbiz.

Thanks to the lots of good tutorials and the beginners book
I already could successfully create own forms, using services and
handling simple requests. This is amazing and really promising
regarding the power of the system.

With the next step to learn ofbiz nevetheless I got stuck somehow:
I would like to connect my (test)-component
with "standard-ofbiz-business-logic", as an example
I would like to sell a simple service, which
should cost  3 $ to an anonymous customer.

For this I would as an example I would like to create
an invoice which can be processed further in ofbiz (
some kind of "standard"-ofbiz-invoice, for which
payment afterwards can be tracked and so on).

How can I create such an invoice?

Is generally any documentation about services for such
"standard-business-cases available?

Looking for ofbizes-services for invoices e.g. I found (searching in
accounting services) services and java-functions like createInvoice,
createInvoiceItem (simple services) createInvoiceForOrder (java).
This seems to be good candidates: But which one should I use? And what
else should has to be done to process the invoice? Is it sufficient to
call CreateINvoice and createInvoiceItem,
or are the ofbiz-procedures more complicated?

I also tried to find createInvoice in the eCommerce-example-application,
 but it seems not to be used there (how is billing and invoice
handling done there? is createInvoice not the "standard"-procedure).

Some documentation I tried to find  concerning this point seems to be
unused (or even unnecessary?):
https://cwiki.apache.org/confluence/display/OFBIZ/11.5+Invoice+Item+Type

More general my question addresses the question how to connect to the
right interface within the ofbiz system to use the predefined business
logic in an efficient way.

Thank you for any information!


Ralf














Reply | Threaded
Open this post in threaded view
|

Re: create Invoice

joelfradkin@gmail.com
I am no expert, and I am not calling services outside of ofbiz.
That said how I would approach it is find in ofbiz using the gui where it creates an invoice.
If you look at the pages and the code you should be able to see the proper calling sequence.
I've done this allot with purchase order, receiving etc.
you can grep the service name and see who calls it in Ofbiz GUI.
Joel Fradkin
Reply | Threaded
Open this post in threaded view
|

Re: create Invoice

info@agentur-m3.de
Hello Joel,

thank you. I tried to evaulate the user screens , and still
got stuck with some search problems, like:

In https://localhost:8443/ap/control/createInvoiceItem
the forms action is action="/ap/control/createInvoiceItem".
This should  (???-> I am not quite sure about that) lead to
accounting/webapp or accounting/widget (?). But it does not.

I found a simple-method createInvoiceItem in
/accounting/Invoice/InvoiceServices.xml

Here it is:

<simple-method method-name="createInvoiceItem" short-description="Create
a new Invoice Item">
 <set field="invoiceId" from-field="parameters.invoiceId"/>
 <call-simple-method method-name="InvoiceStatusInProgress"/>
 <make-value value-field="newEntity" entity-name="InvoiceItem"/>
 <set-pk-fields map="parameters" value-field="newEntity"/>
 <set-nonpk-fields map="parameters" value-field="newEntity"/>
 <if-empty field="newEntity.invoiceItemSeqId">
 <make-next-seq-id value-field="newEntity" seq-field-
name="invoiceItemSeqId"/> <!-- this finds the next sub-sequence ID -->
 <field-to-result field="newEntity.invoiceItemSeqId"
result-name="invoiceItemSeqId"/>
 </if-empty>
 <!-- if there is no amount and a productItem is supplied fill the
amount(price) and description from the product record
 TODO: there are return adjustments now that make this code very
broken. The check for price was added as a quick fix. -->
 <if-empty field="parameters.amount">
 <if-not-empty field="parameters.productId">
 <entity-one entity-name="Product" value-field="product"/>
 <set from-field="product.description" field="newEntity.description"/>
 <set from-field="product" field="calculateProductPriceMap.product"/>
  <call-service service-name="calculateProductPrice"
in-map-name="calculateProductPriceMap">
 <result-to-field result-name="price" field="newEntity.amount"/>
 </call-service>
 </if-not-empty>
 </if-empty>
 <if-not-empty field="parameters.productId">
 <if-empty field="parameters.quantity">
 <set field="newEntity.quantity" value="1.0" type="BigDecimal"/>
 </if-empty>
 </if-not-empty>
  <if-empty field="newEntity.amount">
  <add-error>
 <fail-property resource="AccountingUiLabels"
property="AccountingInvoiceAmountIsMandatory"/>
 </add-error>
 </if-empty>
 <create-value value-field="newEntity"/>
</simple-method>


Because of the assignment
 <set-nonpk-fields map="parameters" value-field="newEntity"/>
some of the (necessary?) parameter are implicit
and I don't know exactly, what ofbiz (minimal) needs
for an invoice entry. The customer (is an acteur-id necessary?)

It invoice-item has some fields:
      <field name="invoiceId" type="id-ne"></field>
      <field name="invoiceItemSeqId" type="id-ne"></field>
      <field name="invoiceItemTypeId" type="id"></field>
      <field name="overrideGlAccountId" type="id"><description>used to
specify the override or actual glAccountId used for the invoice, avoids
problems if configuration changes after initial posting, etc
</description></field>
      <field name="overrideOrgPartyId" type="id"><description>Used to
specify the organization override rather than using the
payToPartyId</description></field>
      <field name="inventoryItemId" type="id"></field>
      <field name="productId" type="id"></field>
      <field name="productFeatureId" type="id"></field>
      <field name="parentInvoiceId" type="id"></field>
      <field name="parentInvoiceItemSeqId" type="id"></field>
      <field name="uomId" type="id"></field>
      <field name="taxableFlag" type="indicator"></field>
      <field name="quantity" type="fixed-point"></field>
      <field name="amount" type="currency-precise"></field>
      <field name="description" type="description"></field>
      <field name="taxAuthPartyId" type="id-ne"/>
      <field name="taxAuthGeoId" type="id-ne"/>
      <field name="taxAuthorityRateSeqId" type="id-ne"></field>
      <field name="salesOpportunityId" type="id-ne"></field>

Which of them do I have to specify?

Is there any documentation of such "standard"-processes
like invoice, customer, products?

Thank you,

Ralf





Am 28.10.2014 um 17:02 schrieb [hidden email]:

> I am no expert, and I am not calling services outside of ofbiz.
> That said how I would approach it is find in ofbiz using the gui where it
> creates an invoice.
> If you look at the pages and the code you should be able to see the proper
> calling sequence.
> I've done this allot with purchase order, receiving etc.
> you can grep the service name and see who calls it in Ofbiz GUI.
>
>
>
> -----
> Joel Fradkin
> --
> View this message in context: http://ofbiz.135035.n4.nabble.com/create-Invoice-tp4657422p4657457.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: create Invoice

Adrian Crum-3
How To Reverse-Engineer An OFBiz Event Request
----------------------------------------------

URL -> web app -> controller.xml -> event

Using your example URL:

https://localhost:8443/ap/control/createInvoiceItem

web app is ap (.../ap/...)

so controller.xml can be found in

applications/accounting/webapp/ap/WEB-INF

search controller.xml for createInvoiceItem request map:

Not Found

Look at includes at top of controller.xml file:

<include
location="component://accounting/webapp/accounting/WEB-INF/controller.xml"/>

search that file for createInvoiceItem request map:

<request-map uri="createInvoiceItem">
     <security https="true" auth="true"/>
     <event type="service" invoke="createInvoiceItem"/>
     <response name="success" type="view" value="listInvoiceItems"/>
     <response name="error" type="view" value="listInvoiceItems"/>
</request-map>

So, the URL will invoke the createInvoiceItem service - using request
parameters as service IN parameters.


Adrian Crum
Sandglass Software
www.sandglass-software.com

On 10/30/2014 9:43 AM, [hidden email] wrote:

> Hello Joel,
>
> thank you. I tried to evaulate the user screens , and still
> got stuck with some search problems, like:
>
> In https://localhost:8443/ap/control/createInvoiceItem
> the forms action is action="/ap/control/createInvoiceItem".
> This should  (???-> I am not quite sure about that) lead to
> accounting/webapp or accounting/widget (?). But it does not.
>
> I found a simple-method createInvoiceItem in
> /accounting/Invoice/InvoiceServices.xml
>
> Here it is:
>
> <simple-method method-name="createInvoiceItem" short-description="Create
> a new Invoice Item">
>   <set field="invoiceId" from-field="parameters.invoiceId"/>
>   <call-simple-method method-name="InvoiceStatusInProgress"/>
>   <make-value value-field="newEntity" entity-name="InvoiceItem"/>
>   <set-pk-fields map="parameters" value-field="newEntity"/>
>   <set-nonpk-fields map="parameters" value-field="newEntity"/>
>   <if-empty field="newEntity.invoiceItemSeqId">
>   <make-next-seq-id value-field="newEntity" seq-field-
> name="invoiceItemSeqId"/> <!-- this finds the next sub-sequence ID -->
>   <field-to-result field="newEntity.invoiceItemSeqId"
> result-name="invoiceItemSeqId"/>
>   </if-empty>
>   <!-- if there is no amount and a productItem is supplied fill the
> amount(price) and description from the product record
>   TODO: there are return adjustments now that make this code very
> broken. The check for price was added as a quick fix. -->
>   <if-empty field="parameters.amount">
>   <if-not-empty field="parameters.productId">
>   <entity-one entity-name="Product" value-field="product"/>
>   <set from-field="product.description" field="newEntity.description"/>
>   <set from-field="product" field="calculateProductPriceMap.product"/>
>    <call-service service-name="calculateProductPrice"
> in-map-name="calculateProductPriceMap">
>   <result-to-field result-name="price" field="newEntity.amount"/>
>   </call-service>
>   </if-not-empty>
>   </if-empty>
>   <if-not-empty field="parameters.productId">
>   <if-empty field="parameters.quantity">
>   <set field="newEntity.quantity" value="1.0" type="BigDecimal"/>
>   </if-empty>
>   </if-not-empty>
>    <if-empty field="newEntity.amount">
>    <add-error>
>   <fail-property resource="AccountingUiLabels"
> property="AccountingInvoiceAmountIsMandatory"/>
>   </add-error>
>   </if-empty>
>   <create-value value-field="newEntity"/>
> </simple-method>
>
>
> Because of the assignment
>   <set-nonpk-fields map="parameters" value-field="newEntity"/>
> some of the (necessary?) parameter are implicit
> and I don't know exactly, what ofbiz (minimal) needs
> for an invoice entry. The customer (is an acteur-id necessary?)
>
> It invoice-item has some fields:
>        <field name="invoiceId" type="id-ne"></field>
>        <field name="invoiceItemSeqId" type="id-ne"></field>
>        <field name="invoiceItemTypeId" type="id"></field>
>        <field name="overrideGlAccountId" type="id"><description>used to
> specify the override or actual glAccountId used for the invoice, avoids
> problems if configuration changes after initial posting, etc
> </description></field>
>        <field name="overrideOrgPartyId" type="id"><description>Used to
> specify the organization override rather than using the
> payToPartyId</description></field>
>        <field name="inventoryItemId" type="id"></field>
>        <field name="productId" type="id"></field>
>        <field name="productFeatureId" type="id"></field>
>        <field name="parentInvoiceId" type="id"></field>
>        <field name="parentInvoiceItemSeqId" type="id"></field>
>        <field name="uomId" type="id"></field>
>        <field name="taxableFlag" type="indicator"></field>
>        <field name="quantity" type="fixed-point"></field>
>        <field name="amount" type="currency-precise"></field>
>        <field name="description" type="description"></field>
>        <field name="taxAuthPartyId" type="id-ne"/>
>        <field name="taxAuthGeoId" type="id-ne"/>
>        <field name="taxAuthorityRateSeqId" type="id-ne"></field>
>        <field name="salesOpportunityId" type="id-ne"></field>
>
> Which of them do I have to specify?
>
> Is there any documentation of such "standard"-processes
> like invoice, customer, products?
>
> Thank you,
>
> Ralf
>
>
>
>
>
> Am 28.10.2014 um 17:02 schrieb [hidden email]:
>> I am no expert, and I am not calling services outside of ofbiz.
>> That said how I would approach it is find in ofbiz using the gui where it
>> creates an invoice.
>> If you look at the pages and the code you should be able to see the proper
>> calling sequence.
>> I've done this allot with purchase order, receiving etc.
>> you can grep the service name and see who calls it in Ofbiz GUI.
>>
>>
>>
>> -----
>> Joel Fradkin
>> --
>> View this message in context: http://ofbiz.135035.n4.nabble.com/create-Invoice-tp4657422p4657457.html
>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: create Invoice

info@agentur-m3.de
Thank you Adrian!

I did reverse-look-up the services and at least
found all the definitions.

And in the next step  I also  could define a simple-method
to call the createInvoice-service. So this is really some
steps further now!

A problem that is stil remaining to me, is this:

The invoice-service is being called via this code:
       
<simple-method method-name="createMyInvoice"
  short-description="Create an invoice" login-required="true">
<make-value entity-name="Invoice" value-name="myInvoice" />
  <set field="myInvoice.productCategoryId" value="778"/>
  <set field="myInvoice.partyIdFrom" value="1"/>
  <set field="myInvoice.partyId" value="1"/>
  <set field="myInvoice.invoiceTypeId" value="1"/>
  <set field="myInvoice.categoryName" value="TEST"/>
<call-service service-name="createInvoice" in-map-name="myInvoice" />
</simple-method>


And it leads to this error message:

org.ofbiz.webapp.event.EventHandlerException: Service invocation error
(Could not commit transaction for service [createXMyInvoice] call: Roll
back error, could not commit transaction, was rolled back instead
because of: Failure in create operation for entity [Invoice]:
org.ofbiz.entity.GenericEntityException: Error while inserting:
[GenericEntity:Invoice][createdStamp,2014-10-31
12:42:19.645(java.sql.Timestamp)][createdTxStamp,2014-10-31
12:42:19.639(java.sql.Timestamp)][invoiceDate,2014-10-31
12:42:19.642(java.sql.Timestamp)][invoiceId,10017(java.lang.String)][invoiceTypeId,1(java.lang.String)][lastUpdatedStamp,2014-10-31
12:42:19.645(java.sql.Timestamp)][lastUpdatedTxStamp,2014-10-31
12:42:19.639(java.sql.Timestamp)][partyId,1(java.lang.String)][partyIdFrom,1(java.lang.String)][statusId,INVOICE_IN_PROCESS(java.lang.String)]
(SQL Exception while executing the following:INSERT INTO OFBIZ.INVOICE
(INVOICE_ID, INVOICE_TYPE_ID, PARTY_ID_FROM, PARTY_ID, ROLE_TYPE_ID,
STATUS_ID, BILLING_ACCOUNT_ID, CONTACT_MECH_ID, INVOICE_DATE, DUE_DATE,
PAID_DATE, INVOICE_MESSAGE, REFERENCE_NUMBER, DESCRIPTION,
CURRENCY_UOM_ID, RECURRENCE_INFO_ID, LAST_UPDATED_STAMP,
LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP) VALUES (?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (INSERT on table
'INVOICE' caused a violation of foreign key constraint 'INVOICE_INVTYP'
for key (1). The statement has been rolled back.)). Rolling back
transaction.org.ofbiz.entity.GenericEntityException: Error while
inserting: [GenericEntity:Invoice][createdStamp,2014-10-31
12:42:19.645(java.sql.Timestamp)][createdTxStamp,2014-10-31
12:42:19.639(java.sql.Timestamp)][invoiceDate,2014-10-31
12:42:19.642(java.sql.Timestamp)][invoiceId,10017(java.lang.String)][invoiceTypeId,1(java.lang.String)][lastUpdatedStamp,2014-10-31
12:42:19.645(java.sql.Timestamp)][lastUpdatedTxStamp,2014-10-31
12:42:19.639(java.sql.Timestamp)][partyId,1(java.lang.String)][partyIdFrom,1(java.lang.String)][statusId,INVOICE_IN_PROCESS(java.lang.String)]
(SQL Exception while executing the following:INSERT INTO OFBIZ.INVOICE
(INVOICE_ID, INVOICE_TYPE_ID, PARTY_ID_FROM, PARTY_ID, ROLE_TYPE_ID,
STATUS_ID, BILLING_ACCOUNT_ID, CONTACT_MECH_ID, INVOICE_DATE, DUE_DATE,
PAID_DATE, INVOICE_MESSAGE, REFERENCE_NUMBER, DESCRIPTION,
CURRENCY_UOM_ID, RECURRENCE_INFO_ID, LAST_UPDATED_STAMP,
LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP) VALUES (?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (INSERT on table
'INVOICE' caused a violation of foreign key constraint 'INVOICE_INVTYP'
for key (1). The statement has been rolled back.)) (Error while
inserting: [GenericEntity:Invoice][createdStamp,2014-10-31
12:42:19.645(java.sql.Timestamp)][createdTxStamp,2014-10-31
12:42:19.639(java.sql.Timestamp)][invoiceDate,2014-10-31
12:42:19.642(java.sql.Timestamp)][invoiceId,10017(java.lang.String)][invoiceTypeId,1(java.lang.String)][lastUpdatedStamp,2014-10-31
12:42:19.645(java.sql.Timestamp)][lastUpdatedTxStamp,2014-10-31
12:42:19.639(java.sql.Timestamp)][partyId,1(java.lang.String)][partyIdFrom,1(java.lang.String)][statusId,INVOICE_IN_PROCESS(java.lang.String)]
(SQL Exception while executing the following:INSERT INTO OFBIZ.INVOICE
(INVOICE_ID, INVOICE_TYPE_ID, PARTY_ID_FROM, PARTY_ID, ROLE_TYPE_ID,
STATUS_ID, BILLING_ACCOUNT_ID, CONTACT_MECH_ID, INVOICE_DATE, DUE_DATE,
PAID_DATE, INVOICE_MESSAGE, REFERENCE_NUMBER, DESCRIPTION,
CURRENCY_UOM_ID, RECURRENCE_INFO_ID, LAST_UPDATED_STAMP,
LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP) VALUES (?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (INSERT on table
'INVOICE' caused a violation of foreign key constraint 'INVOICE_INVTYP'
for key (1). The statement has been rolled back.))))


So all this fields seems to be used:
INVOICE_ID, INVOICE_TYPE_ID, PARTY_ID_FROM, PARTY_ID, ROLE_TYPE_ID,
STATUS_ID, BILLING_ACCOUNT_ID, CONTACT_MECH_ID, INVOICE_DATE, DUE_DATE,
PAID_DATE, INVOICE_MESSAGE, REFERENCE_NUMBER, DESCRIPTION,
CURRENCY_UOM_ID, RECURRENCE_INFO_ID, LAST_UPDATED_STAMP,
LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP

Where do I get all this values from?
As an example I found values for InvoiceTypeId in accountingtypedata.xml
e.g. SALES_INVOICE, PURCHASE_INVOICE, CUST_RTN_INVOICE, MANUFACTORING
but what do they mean? What is the difference?

Do I have to look into the "Data model Recource Book?" now?
Or is there any more ofbiz-specific documentation of this types and flags?

Thank you for any information which help for a deeper understanding
of the underlying process of creating a senseful invoice :-)

Ralf












Am 30.10.2014 um 11:00 schrieb Adrian Crum:

> How To Reverse-Engineer An OFBiz Event Request
> ----------------------------------------------
>
> URL -> web app -> controller.xml -> event
>
> Using your example URL:
>
> https://localhost:8443/ap/control/createInvoiceItem
>
> web app is ap (.../ap/...)
>
> so controller.xml can be found in
>
> applications/accounting/webapp/ap/WEB-INF
>
> search controller.xml for createInvoiceItem request map:
>
> Not Found
>
> Look at includes at top of controller.xml file:
>
> <include
> location="component://accounting/webapp/accounting/WEB-INF/controller.xml"/>
>
>
> search that file for createInvoiceItem request map:
>
> <request-map uri="createInvoiceItem">
>     <security https="true" auth="true"/>
>     <event type="service" invoke="createInvoiceItem"/>
>     <response name="success" type="view" value="listInvoiceItems"/>
>     <response name="error" type="view" value="listInvoiceItems"/>
> </request-map>
>
> So, the URL will invoke the createInvoiceItem service - using request
> parameters as service IN parameters.
>
>
> Adrian Crum
> Sandglass Software
> www.sandglass-software.com
>
> On 10/30/2014 9:43 AM, [hidden email] wrote:
>> Hello Joel,
>>
>> thank you. I tried to evaulate the user screens , and still
>> got stuck with some search problems, like:
>>
>> In https://localhost:8443/ap/control/createInvoiceItem
>> the forms action is action="/ap/control/createInvoiceItem".
>> This should  (???-> I am not quite sure about that) lead to
>> accounting/webapp or accounting/widget (?). But it does not.
>>
>> I found a simple-method createInvoiceItem in
>> /accounting/Invoice/InvoiceServices.xml
>>
>> Here it is:
>>
>> <simple-method method-name="createInvoiceItem" short-description="Create
>> a new Invoice Item">
>>   <set field="invoiceId" from-field="parameters.invoiceId"/>
>>   <call-simple-method method-name="InvoiceStatusInProgress"/>
>>   <make-value value-field="newEntity" entity-name="InvoiceItem"/>
>>   <set-pk-fields map="parameters" value-field="newEntity"/>
>>   <set-nonpk-fields map="parameters" value-field="newEntity"/>
>>   <if-empty field="newEntity.invoiceItemSeqId">
>>   <make-next-seq-id value-field="newEntity" seq-field-
>> name="invoiceItemSeqId"/> <!-- this finds the next sub-sequence ID -->
>>   <field-to-result field="newEntity.invoiceItemSeqId"
>> result-name="invoiceItemSeqId"/>
>>   </if-empty>
>>   <!-- if there is no amount and a productItem is supplied fill the
>> amount(price) and description from the product record
>>   TODO: there are return adjustments now that make this code very
>> broken. The check for price was added as a quick fix. -->
>>   <if-empty field="parameters.amount">
>>   <if-not-empty field="parameters.productId">
>>   <entity-one entity-name="Product" value-field="product"/>
>>   <set from-field="product.description" field="newEntity.description"/>
>>   <set from-field="product" field="calculateProductPriceMap.product"/>
>>    <call-service service-name="calculateProductPrice"
>> in-map-name="calculateProductPriceMap">
>>   <result-to-field result-name="price" field="newEntity.amount"/>
>>   </call-service>
>>   </if-not-empty>
>>   </if-empty>
>>   <if-not-empty field="parameters.productId">
>>   <if-empty field="parameters.quantity">
>>   <set field="newEntity.quantity" value="1.0" type="BigDecimal"/>
>>   </if-empty>
>>   </if-not-empty>
>>    <if-empty field="newEntity.amount">
>>    <add-error>
>>   <fail-property resource="AccountingUiLabels"
>> property="AccountingInvoiceAmountIsMandatory"/>
>>   </add-error>
>>   </if-empty>
>>   <create-value value-field="newEntity"/>
>> </simple-method>
>>
>>
>> Because of the assignment
>>   <set-nonpk-fields map="parameters" value-field="newEntity"/>
>> some of the (necessary?) parameter are implicit
>> and I don't know exactly, what ofbiz (minimal) needs
>> for an invoice entry. The customer (is an acteur-id necessary?)
>>
>> It invoice-item has some fields:
>>        <field name="invoiceId" type="id-ne"></field>
>>        <field name="invoiceItemSeqId" type="id-ne"></field>
>>        <field name="invoiceItemTypeId" type="id"></field>
>>        <field name="overrideGlAccountId" type="id"><description>used to
>> specify the override or actual glAccountId used for the invoice, avoids
>> problems if configuration changes after initial posting, etc
>> </description></field>
>>        <field name="overrideOrgPartyId" type="id"><description>Used to
>> specify the organization override rather than using the
>> payToPartyId</description></field>
>>        <field name="inventoryItemId" type="id"></field>
>>        <field name="productId" type="id"></field>
>>        <field name="productFeatureId" type="id"></field>
>>        <field name="parentInvoiceId" type="id"></field>
>>        <field name="parentInvoiceItemSeqId" type="id"></field>
>>        <field name="uomId" type="id"></field>
>>        <field name="taxableFlag" type="indicator"></field>
>>        <field name="quantity" type="fixed-point"></field>
>>        <field name="amount" type="currency-precise"></field>
>>        <field name="description" type="description"></field>
>>        <field name="taxAuthPartyId" type="id-ne"/>
>>        <field name="taxAuthGeoId" type="id-ne"/>
>>        <field name="taxAuthorityRateSeqId" type="id-ne"></field>
>>        <field name="salesOpportunityId" type="id-ne"></field>
>>
>> Which of them do I have to specify?
>>
>> Is there any documentation of such "standard"-processes
>> like invoice, customer, products?
>>
>> Thank you,
>>
>> Ralf
>>
>>
>>
>>
>>
>> Am 28.10.2014 um 17:02 schrieb [hidden email]:
>>> I am no expert, and I am not calling services outside of ofbiz.
>>> That said how I would approach it is find in ofbiz using the gui
>>> where it
>>> creates an invoice.
>>> If you look at the pages and the code you should be able to see the
>>> proper
>>> calling sequence.
>>> I've done this allot with purchase order, receiving etc.
>>> you can grep the service name and see who calls it in Ofbiz GUI.
>>>
>>>
>>>
>>> -----
>>> Joel Fradkin
>>> --
>>> View this message in context:
>>> http://ofbiz.135035.n4.nabble.com/create-Invoice-tp4657422p4657457.html
>>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: create Invoice

joelfradkin@gmail.com
In reply to this post by info@agentur-m3.de
Adrian knows more. But to add a bit you may know.
most services are in component service def. It will say what's optional.
I grep to find specific xml defining service. I'm still learning and don't know invoice sorry I'm not more help.
Joel Fradkin
Reply | Threaded
Open this post in threaded view
|

Re: create Invoice

joelfradkin@gmail.com
Sounds like your type isn't in the type file specified in the error. I also do show page source on gui to see options and Web tools interesting to see entity. Can view edit there.
Joel Fradkin
Reply | Threaded
Open this post in threaded view
|

Re: create Invoice

info@agentur-m3.de
I just took a second look at the the "data model resource book"
and it in fact seems to have all information concerning invoices
and explanation of the specific fields of an invoice.
So if the ofbiz logic commits to this book (I don't
really know, but I guess it does ?!?!?)
I should be able to create some senseful invoices then.





Am 31.10.2014 um 13:35 schrieb [hidden email]:

> Sounds like your type isn't in the type file specified in the error. I also
> do show page source on gui to see options and Web tools interesting to see
> entity. Can view edit there.
>
>
>
> -----
> Joel Fradkin
> --
> View this message in context: http://ofbiz.135035.n4.nabble.com/create-Invoice-tp4657422p4657626.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: create Invoice

Adrian Crum-3
In reply to this post by info@agentur-m3.de
You do not need this line:

<make-value entity-name="Invoice" value-name="myInvoice" />

That line creates a GenericValue instance that you intend to store in
the database - which you are not doing.

https://cwiki.apache.org/confluence/display/OFBADMIN/Mini-language+%28minilang%29+Reference

Yes, you need to spend some time reading The Data Model Resource Book.


Adrian Crum
Sandglass Software
www.sandglass-software.com

On 10/31/2014 12:29 PM, [hidden email] wrote:

> Thank you Adrian!
>
> I did reverse-look-up the services and at least
> found all the definitions.
>
> And in the next step  I also  could define a simple-method
> to call the createInvoice-service. So this is really some
> steps further now!
>
> A problem that is stil remaining to me, is this:
>
> The invoice-service is being called via this code:
>
> <simple-method method-name="createMyInvoice"
>    short-description="Create an invoice" login-required="true">
> <make-value entity-name="Invoice" value-name="myInvoice" />
>    <set field="myInvoice.productCategoryId" value="778"/>
>    <set field="myInvoice.partyIdFrom" value="1"/>
>    <set field="myInvoice.partyId" value="1"/>
>    <set field="myInvoice.invoiceTypeId" value="1"/>
>    <set field="myInvoice.categoryName" value="TEST"/>
> <call-service service-name="createInvoice" in-map-name="myInvoice" />
> </simple-method>
>
>
> And it leads to this error message:
>
> org.ofbiz.webapp.event.EventHandlerException: Service invocation error
> (Could not commit transaction for service [createXMyInvoice] call: Roll
> back error, could not commit transaction, was rolled back instead
> because of: Failure in create operation for entity [Invoice]:
> org.ofbiz.entity.GenericEntityException: Error while inserting:
> [GenericEntity:Invoice][createdStamp,2014-10-31
> 12:42:19.645(java.sql.Timestamp)][createdTxStamp,2014-10-31
> 12:42:19.639(java.sql.Timestamp)][invoiceDate,2014-10-31
> 12:42:19.642(java.sql.Timestamp)][invoiceId,10017(java.lang.String)][invoiceTypeId,1(java.lang.String)][lastUpdatedStamp,2014-10-31
> 12:42:19.645(java.sql.Timestamp)][lastUpdatedTxStamp,2014-10-31
> 12:42:19.639(java.sql.Timestamp)][partyId,1(java.lang.String)][partyIdFrom,1(java.lang.String)][statusId,INVOICE_IN_PROCESS(java.lang.String)]
> (SQL Exception while executing the following:INSERT INTO OFBIZ.INVOICE
> (INVOICE_ID, INVOICE_TYPE_ID, PARTY_ID_FROM, PARTY_ID, ROLE_TYPE_ID,
> STATUS_ID, BILLING_ACCOUNT_ID, CONTACT_MECH_ID, INVOICE_DATE, DUE_DATE,
> PAID_DATE, INVOICE_MESSAGE, REFERENCE_NUMBER, DESCRIPTION,
> CURRENCY_UOM_ID, RECURRENCE_INFO_ID, LAST_UPDATED_STAMP,
> LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP) VALUES (?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (INSERT on table
> 'INVOICE' caused a violation of foreign key constraint 'INVOICE_INVTYP'
> for key (1). The statement has been rolled back.)). Rolling back
> transaction.org.ofbiz.entity.GenericEntityException: Error while
> inserting: [GenericEntity:Invoice][createdStamp,2014-10-31
> 12:42:19.645(java.sql.Timestamp)][createdTxStamp,2014-10-31
> 12:42:19.639(java.sql.Timestamp)][invoiceDate,2014-10-31
> 12:42:19.642(java.sql.Timestamp)][invoiceId,10017(java.lang.String)][invoiceTypeId,1(java.lang.String)][lastUpdatedStamp,2014-10-31
> 12:42:19.645(java.sql.Timestamp)][lastUpdatedTxStamp,2014-10-31
> 12:42:19.639(java.sql.Timestamp)][partyId,1(java.lang.String)][partyIdFrom,1(java.lang.String)][statusId,INVOICE_IN_PROCESS(java.lang.String)]
> (SQL Exception while executing the following:INSERT INTO OFBIZ.INVOICE
> (INVOICE_ID, INVOICE_TYPE_ID, PARTY_ID_FROM, PARTY_ID, ROLE_TYPE_ID,
> STATUS_ID, BILLING_ACCOUNT_ID, CONTACT_MECH_ID, INVOICE_DATE, DUE_DATE,
> PAID_DATE, INVOICE_MESSAGE, REFERENCE_NUMBER, DESCRIPTION,
> CURRENCY_UOM_ID, RECURRENCE_INFO_ID, LAST_UPDATED_STAMP,
> LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP) VALUES (?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (INSERT on table
> 'INVOICE' caused a violation of foreign key constraint 'INVOICE_INVTYP'
> for key (1). The statement has been rolled back.)) (Error while
> inserting: [GenericEntity:Invoice][createdStamp,2014-10-31
> 12:42:19.645(java.sql.Timestamp)][createdTxStamp,2014-10-31
> 12:42:19.639(java.sql.Timestamp)][invoiceDate,2014-10-31
> 12:42:19.642(java.sql.Timestamp)][invoiceId,10017(java.lang.String)][invoiceTypeId,1(java.lang.String)][lastUpdatedStamp,2014-10-31
> 12:42:19.645(java.sql.Timestamp)][lastUpdatedTxStamp,2014-10-31
> 12:42:19.639(java.sql.Timestamp)][partyId,1(java.lang.String)][partyIdFrom,1(java.lang.String)][statusId,INVOICE_IN_PROCESS(java.lang.String)]
> (SQL Exception while executing the following:INSERT INTO OFBIZ.INVOICE
> (INVOICE_ID, INVOICE_TYPE_ID, PARTY_ID_FROM, PARTY_ID, ROLE_TYPE_ID,
> STATUS_ID, BILLING_ACCOUNT_ID, CONTACT_MECH_ID, INVOICE_DATE, DUE_DATE,
> PAID_DATE, INVOICE_MESSAGE, REFERENCE_NUMBER, DESCRIPTION,
> CURRENCY_UOM_ID, RECURRENCE_INFO_ID, LAST_UPDATED_STAMP,
> LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP) VALUES (?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (INSERT on table
> 'INVOICE' caused a violation of foreign key constraint 'INVOICE_INVTYP'
> for key (1). The statement has been rolled back.))))
>
>
> So all this fields seems to be used:
> INVOICE_ID, INVOICE_TYPE_ID, PARTY_ID_FROM, PARTY_ID, ROLE_TYPE_ID,
> STATUS_ID, BILLING_ACCOUNT_ID, CONTACT_MECH_ID, INVOICE_DATE, DUE_DATE,
> PAID_DATE, INVOICE_MESSAGE, REFERENCE_NUMBER, DESCRIPTION,
> CURRENCY_UOM_ID, RECURRENCE_INFO_ID, LAST_UPDATED_STAMP,
> LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP
>
> Where do I get all this values from?
> As an example I found values for InvoiceTypeId in accountingtypedata.xml
> e.g. SALES_INVOICE, PURCHASE_INVOICE, CUST_RTN_INVOICE, MANUFACTORING
> but what do they mean? What is the difference?
>
> Do I have to look into the "Data model Recource Book?" now?
> Or is there any more ofbiz-specific documentation of this types and flags?
>
> Thank you for any information which help for a deeper understanding
> of the underlying process of creating a senseful invoice :-)
>
> Ralf
>
>
>
>
>
>
>
>
>
>
>
>
> Am 30.10.2014 um 11:00 schrieb Adrian Crum:
>> How To Reverse-Engineer An OFBiz Event Request
>> ----------------------------------------------
>>
>> URL -> web app -> controller.xml -> event
>>
>> Using your example URL:
>>
>> https://localhost:8443/ap/control/createInvoiceItem
>>
>> web app is ap (.../ap/...)
>>
>> so controller.xml can be found in
>>
>> applications/accounting/webapp/ap/WEB-INF
>>
>> search controller.xml for createInvoiceItem request map:
>>
>> Not Found
>>
>> Look at includes at top of controller.xml file:
>>
>> <include
>> location="component://accounting/webapp/accounting/WEB-INF/controller.xml"/>
>>
>>
>> search that file for createInvoiceItem request map:
>>
>> <request-map uri="createInvoiceItem">
>>      <security https="true" auth="true"/>
>>      <event type="service" invoke="createInvoiceItem"/>
>>      <response name="success" type="view" value="listInvoiceItems"/>
>>      <response name="error" type="view" value="listInvoiceItems"/>
>> </request-map>
>>
>> So, the URL will invoke the createInvoiceItem service - using request
>> parameters as service IN parameters.
>>
>>
>> Adrian Crum
>> Sandglass Software
>> www.sandglass-software.com
>>
>> On 10/30/2014 9:43 AM, [hidden email] wrote:
>>> Hello Joel,
>>>
>>> thank you. I tried to evaulate the user screens , and still
>>> got stuck with some search problems, like:
>>>
>>> In https://localhost:8443/ap/control/createInvoiceItem
>>> the forms action is action="/ap/control/createInvoiceItem".
>>> This should  (???-> I am not quite sure about that) lead to
>>> accounting/webapp or accounting/widget (?). But it does not.
>>>
>>> I found a simple-method createInvoiceItem in
>>> /accounting/Invoice/InvoiceServices.xml
>>>
>>> Here it is:
>>>
>>> <simple-method method-name="createInvoiceItem" short-description="Create
>>> a new Invoice Item">
>>>    <set field="invoiceId" from-field="parameters.invoiceId"/>
>>>    <call-simple-method method-name="InvoiceStatusInProgress"/>
>>>    <make-value value-field="newEntity" entity-name="InvoiceItem"/>
>>>    <set-pk-fields map="parameters" value-field="newEntity"/>
>>>    <set-nonpk-fields map="parameters" value-field="newEntity"/>
>>>    <if-empty field="newEntity.invoiceItemSeqId">
>>>    <make-next-seq-id value-field="newEntity" seq-field-
>>> name="invoiceItemSeqId"/> <!-- this finds the next sub-sequence ID -->
>>>    <field-to-result field="newEntity.invoiceItemSeqId"
>>> result-name="invoiceItemSeqId"/>
>>>    </if-empty>
>>>    <!-- if there is no amount and a productItem is supplied fill the
>>> amount(price) and description from the product record
>>>    TODO: there are return adjustments now that make this code very
>>> broken. The check for price was added as a quick fix. -->
>>>    <if-empty field="parameters.amount">
>>>    <if-not-empty field="parameters.productId">
>>>    <entity-one entity-name="Product" value-field="product"/>
>>>    <set from-field="product.description" field="newEntity.description"/>
>>>    <set from-field="product" field="calculateProductPriceMap.product"/>
>>>     <call-service service-name="calculateProductPrice"
>>> in-map-name="calculateProductPriceMap">
>>>    <result-to-field result-name="price" field="newEntity.amount"/>
>>>    </call-service>
>>>    </if-not-empty>
>>>    </if-empty>
>>>    <if-not-empty field="parameters.productId">
>>>    <if-empty field="parameters.quantity">
>>>    <set field="newEntity.quantity" value="1.0" type="BigDecimal"/>
>>>    </if-empty>
>>>    </if-not-empty>
>>>     <if-empty field="newEntity.amount">
>>>     <add-error>
>>>    <fail-property resource="AccountingUiLabels"
>>> property="AccountingInvoiceAmountIsMandatory"/>
>>>    </add-error>
>>>    </if-empty>
>>>    <create-value value-field="newEntity"/>
>>> </simple-method>
>>>
>>>
>>> Because of the assignment
>>>    <set-nonpk-fields map="parameters" value-field="newEntity"/>
>>> some of the (necessary?) parameter are implicit
>>> and I don't know exactly, what ofbiz (minimal) needs
>>> for an invoice entry. The customer (is an acteur-id necessary?)
>>>
>>> It invoice-item has some fields:
>>>         <field name="invoiceId" type="id-ne"></field>
>>>         <field name="invoiceItemSeqId" type="id-ne"></field>
>>>         <field name="invoiceItemTypeId" type="id"></field>
>>>         <field name="overrideGlAccountId" type="id"><description>used to
>>> specify the override or actual glAccountId used for the invoice, avoids
>>> problems if configuration changes after initial posting, etc
>>> </description></field>
>>>         <field name="overrideOrgPartyId" type="id"><description>Used to
>>> specify the organization override rather than using the
>>> payToPartyId</description></field>
>>>         <field name="inventoryItemId" type="id"></field>
>>>         <field name="productId" type="id"></field>
>>>         <field name="productFeatureId" type="id"></field>
>>>         <field name="parentInvoiceId" type="id"></field>
>>>         <field name="parentInvoiceItemSeqId" type="id"></field>
>>>         <field name="uomId" type="id"></field>
>>>         <field name="taxableFlag" type="indicator"></field>
>>>         <field name="quantity" type="fixed-point"></field>
>>>         <field name="amount" type="currency-precise"></field>
>>>         <field name="description" type="description"></field>
>>>         <field name="taxAuthPartyId" type="id-ne"/>
>>>         <field name="taxAuthGeoId" type="id-ne"/>
>>>         <field name="taxAuthorityRateSeqId" type="id-ne"></field>
>>>         <field name="salesOpportunityId" type="id-ne"></field>
>>>
>>> Which of them do I have to specify?
>>>
>>> Is there any documentation of such "standard"-processes
>>> like invoice, customer, products?
>>>
>>> Thank you,
>>>
>>> Ralf
>>>
>>>
>>>
>>>
>>>
>>> Am 28.10.2014 um 17:02 schrieb [hidden email]:
>>>> I am no expert, and I am not calling services outside of ofbiz.
>>>> That said how I would approach it is find in ofbiz using the gui
>>>> where it
>>>> creates an invoice.
>>>> If you look at the pages and the code you should be able to see the
>>>> proper
>>>> calling sequence.
>>>> I've done this allot with purchase order, receiving etc.
>>>> you can grep the service name and see who calls it in Ofbiz GUI.
>>>>
>>>>
>>>>
>>>> -----
>>>> Joel Fradkin
>>>> --
>>>> View this message in context:
>>>> http://ofbiz.135035.n4.nabble.com/create-Invoice-tp4657422p4657457.html
>>>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: create Invoice

Adrian Crum-3
In reply to this post by joelfradkin@gmail.com
An easier way to look up services, is by using Web Tools:

https://localhost:8443/webtools/control/ServiceList

Adrian Crum
Sandglass Software
www.sandglass-software.com

On 10/31/2014 12:30 PM, [hidden email] wrote:

> Adrian knows more. But to add a bit you may know.
> most services are in component service def. It will say what's optional.
> I grep to find specific xml defining service. I'm still learning and don't
> know invoice sorry I'm not more help.
>
>
>
> -----
> Joel Fradkin
> --
> View this message in context: http://ofbiz.135035.n4.nabble.com/create-Invoice-tp4657422p4657625.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: create Invoice

info@agentur-m3.de
That is very useful,
both for the minilang overview and
the service overview (the parameter list is great!).

Thank you!
Ralf

Am 31.10.2014 um 16:44 schrieb Adrian Crum:

> An easier way to look up services, is by using Web Tools:
>
> https://localhost:8443/webtools/control/ServiceList
>
> Adrian Crum
> Sandglass Software
> www.sandglass-software.com
>
> On 10/31/2014 12:30 PM, [hidden email] wrote:
>> Adrian knows more. But to add a bit you may know.
>> most services are in component service def. It will say what's optional.
>> I grep to find specific xml defining service. I'm still learning and
>> don't
>> know invoice sorry I'm not more help.
>>
>>
>>
>> -----
>> Joel Fradkin
>> --
>> View this message in context:
>> http://ofbiz.135035.n4.nabble.com/create-Invoice-tp4657422p4657625.html
>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>
>