How to solve Error Expected a Resource or Concept

0 votes

My code is as follows:

    /**

 * New model file

 */

namespace org.acme.paysystem

enum PaymentStatus{

o PARTIALLY_PAID

o TOTAL_AMOUNT_PAID

o NOT_PAID

}

enum DeliveryStatus{

o DELIVERED

o IN_TRANSIT

}

asset Goods identified by billNo{

  o String billNo

  o Double billAmount

  o DateTime billDate

  o DeliveryStatus deliveryStatus

  o PaymentStatus paymentStatus default = 'NOT_PAID'

}

concept Address{

o String Country optional

o String City optional

o String Street optional

o String Zip optional

}

abstract participant user identified by email{

  o String email

  o String fname

  o String lname

  o Address address

}

participant Retailer extends user {

o String shopNo

o Double amountDue

o Double accountBalance

}

participant Distributor extends user{

o String PAN

o Double bankBalance

}

transaction Payment{

  --> Goods goods

  --> Retailer retailer

  --> Distributor distributor

  o PaymentStatus paymentStatus

}

transaction GoodsMovement {

  --> Goods goods

  o DeliveryStatus deliveryStatus

The script file is as follows:

/**

* @param {org.acme.paysystem.Payment} Payment

* @transaction

*/

function Payment(Payment){

        var paymentRecievedFlag = 0;

        var amountRecieved = 0;

                if(GoodsMovement == 'IN_TRANSIT')

                    {

                         console.log("Goods are IN_TRANSIT");

                    }

          else

          {

            if ((Payment.retailer.accountBalance - Payment.goods.billAmount) > 0 ){

               Payment.retailer.accountbalance -= Payment.goods.billAmount;

               Payment.distributor.bankBalance += Payment.goods.billAmount;

              Payment.paymentStatus = 'TOTAL_AMOUNT_PAID';

              //Payment.goods.paymentStatus = 'TOTAL_AMOUNT_PAID';

          }

            else{

                  Payment.retailer.amountDue = Payment.goods.billAmount - Payment.retailer.accountBalance;

                  Payment.distributor.bankBalance += Payment.retailer.accountBalance;

                  Payment.paymentStatus = PARTIALLY_PAID;

            }}

          return getParticipantRegistry('org.acme.paysystem.Distributor')

               .then(function(distributorRegistry){

                  return distributorRegistry.update(Payment.distributer);

          })

               .then(function(){

                  return getParticipantRegistry('org.acme.paysystem.Retailer');

          })

               .then(function(retailerRegistry){

                  return retailerRegistry.update(Payment.retailer);

          })

                 .then(function(){

                       return getAssetRegistry('org.acme.paysystem.Goods');

          })

                 .then(function(goodsRegistry){

                        return goodsRegistry.update(Payment.goods);

          });       

}

How to solve this error?

Jul 31, 2018 in Blockchain by digger
• 26,740 points
995 views

1 answer to this question.

0 votes

There are few errors in code. I have gone through your code and found out what should be changed> I mentioned the changes below:

line 10: if(Payment.goods.deliveryStatus == 'IN_TRANSIT')

line 31: return distributorRegistry.update(Payment.distributor);

line 18 and 25: Payment.goods.paymentStatus = 'TOTAL_AMOUNT_PAID';

line 25: Payment.goods.paymentStatus = 'PARTIALLY_PAID';

After making the above mentioned changes, use this transaction:

{
  "$class": "org.acme.paysystem.Payment",
  "goods": "resource:org.acme.paysystem.Goods#1",
  "retailer": "resource:org.acme.paysystem.Retailer#a@b.com",
  "distributor": "resource:org.acme.paysystem.Distributor#a@b.com",
  "paymentStatus": "PARTIALLY_PAID"
}
answered Jul 31, 2018 by slayer
• 29,350 points

Related Questions In Blockchain

0 votes
1 answer

How to solve EACCES:permission denied error in Hyperledger Composer?

It seems like there is no required ...READ MORE

answered Jul 11, 2018 in Blockchain by digger
• 26,740 points
2,066 views
0 votes
10 answers

How to solve gradle build failed error?

I migrated the project to a different ...READ MORE

answered Dec 7, 2018 in Blockchain by Rajat
47,140 views
0 votes
1 answer

How to solve "Failed to deserialize creator identity error"?

It seems like the problem is caused ...READ MORE

answered Jul 13, 2018 in Blockchain by slayer
• 29,350 points
1,393 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,215 views
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 26,740 points
708 views
+1 vote
1 answer
0 votes
1 answer

How to solve “ltdl.h: No such file or directory” error?

It seems like you are missing header ...READ MORE

answered Jul 26, 2018 in Blockchain by slayer
• 29,350 points
2,771 views
0 votes
1 answer

How to solve Runtime error when querying Hyperledger?

OCI is open container initiative.. The error ...READ MORE

answered Jul 9, 2018 in Blockchain by slayer
• 29,350 points
767 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP