sakarepmu

In this example below you will see how to do a sakarepmu with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by Wiro, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright Wiro ©
  • HTML
  • CSS
  • JavaScript
    

/*Downloaded from https://www.codeseek.co/Wiro/sakarepmu-JEmXrr */
    


/*Downloaded from https://www.codeseek.co/Wiro/sakarepmu-JEmXrr */
    var transaction = [{
  code : 'TJ0009928946',
  items: [{
    code : '002193921',
    name : 'arsyad',
    total: '100000'
  },{
    code : '0021317237621',
    name : 'abi',
    total: '500000'
  }],
  info: 'buy'
},{
  code : 'TJ0009928926',
  items: [{
    code : '00219393121',
    name : 'arsyad001',
    total: '10000'
  },{
    code : '002131723722621',
    name : 'abi001',
    total: '50000'
  }],
  info: 'sell'
},{
  code : 'TJ00099298946',
  items: [{
    code : '0021913921',
    name : 'arsyad002',
    total: '400000'
  },{
    code : '00213172376213',
    name : 'abi002',
    total: '300000'
  }],
  info: 'sell'
},{
  code : 'TJ00099289461',
  items: [{
    code : '0021939212',
    name : 'arsyad003',
    total: '400000'
  },{
    code : '00213172376213',
    name : 'abi003',
    total: '100000'
  }],
  info: 'buy'
}]

var subtotal = 0 ;
var buy = 0 ;
var sell = 0;

function OTG(){
  for (var i=0; i<transaction.length;i++){
    for (var a in transaction[i].items){
      if (transaction[i].info ==='buy'){
        buy +=parseFloat(transaction[i].items[a].total)
      };
      if (transaction[i].info ==='sell'){
        sell +=parseFloat(transaction[i].items[a].total)
        };
      subtotal +=parseFloat(transaction[i].items[a].total)
    }
  }
  console.log(subtotal)
  console.log(buy) 
  console.log(sell)
}
OTG()




// hitung total tiap transaksi dan seluruh transaksi

Comments