<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Joqim </title>
    <description>The latest articles on DEV Community by Joqim  (@joqim).</description>
    <link>https://dev.to/joqim</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1037427%2Fe5b7976a-d49f-4005-ad77-2297d7277e8b.jpeg</url>
      <title>DEV Community: Joqim </title>
      <link>https://dev.to/joqim</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joqim"/>
    <language>en</language>
    <item>
      <title>Settlr - Splitwise settling for Poker sessions (written in Python)</title>
      <dc:creator>Joqim </dc:creator>
      <pubDate>Fri, 03 Mar 2023 08:37:38 +0000</pubDate>
      <link>https://dev.to/joqim/settlr-276l</link>
      <guid>https://dev.to/joqim/settlr-276l</guid>
      <description>&lt;p&gt;&lt;a href="https://settlr-fe.vercel.app/"&gt;&lt;code&gt;LIVE on Vercel + Heroku&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recently over the past couple of months, a bunch of friends - including my roommates and I get together on Fridays (and maybe also Saturday nights considering we're not sore losers lol) for Poker.&lt;/p&gt;

&lt;p&gt;We begin dealing around 10 PM and go all night until 1 AM. &lt;br&gt;
By 1 AM almost all of us are exceptionally exhausted (not to mention losing multiple buy-in's certainly doesn't help).&lt;/p&gt;

&lt;p&gt;Then comes the annoying part, besides counting each player's chips value, someone takes turns in uploading the winnings/loses as each activity/transaction in Splitwise.&lt;/p&gt;

&lt;p&gt;Transactions in splitwise are mandatory to be accurate to the penny, followed by assignment of players as corresponding debtor and creditors. &lt;br&gt;
Carelessness in this regard is simply begging for arguments between the group members.&lt;/p&gt;

&lt;p&gt;An age old way to tackling human error has been the concept of "machines" and more so in this case "an application", which is why I came up with &lt;strong&gt;Settlr&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Splitwise API documentation while being slightly obscure does contain sufficient examples to get you started.&lt;/p&gt;

&lt;p&gt;Settlr is a python-flask web app backed with a minimalistic user interface built using Material UI, focused on ReactJS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Sn4z_Gfn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tc74qv251k74uvy3b0x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Sn4z_Gfn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tc74qv251k74uvy3b0x.png" alt="Image description" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source code - &lt;a href="https://github.com/joqim/Settlr"&gt;Settlr&lt;/a&gt;&lt;br&gt;
Live - &lt;a href="https://settlr-fe.vercel.app"&gt;Vercel + Heroku&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I began working on Settlr on tuesday, coming out hot out of last weekend's game and speedran developing the codebase just in time for the upcoming weekend. &lt;/p&gt;

&lt;p&gt;Considering the on and off intricacies of Splitwise API, I managed to present Settlr for user testing by Wednesday evening.&lt;/p&gt;

&lt;p&gt;The high level overview is that at the end of each poker game, Settlr requests key information such as the buy-in amount (which corresponds to 1000 units value in chips). &lt;/p&gt;

&lt;p&gt;FYI, each player initially sets up with 1 "buy-in" which is, assume for this example, "$5" in real money and thus translates to 1000 units split into denominations of 10*&lt;em&gt;5&lt;/em&gt;, 20*&lt;em&gt;5&lt;/em&gt;, 50*&lt;em&gt;3&lt;/em&gt;, 100*&lt;em&gt;2&lt;/em&gt; and 500*&lt;em&gt;1&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;As each player burns through his first buy-in, he requests the house for additional buy-in's thus spending additional $5's.&lt;/p&gt;

&lt;p&gt;Besides, the buy-in amount, Settlr also requires the total number of individual players participated in the poker session.&lt;/p&gt;

&lt;p&gt;Using the beauty of oauth2, Settlr makes a request to the dedicated poker group on Splitwise using my access token and renders each member of the group as a participant in the front-end.&lt;/p&gt;

&lt;p&gt;At the end of the session, the user then specifies the value of chips left with each player in units as well as the number of buy-ins for each player.&lt;/p&gt;

&lt;p&gt;Ultimately, a button click for "&lt;em&gt;Splitwise Update&lt;/em&gt;" carries user provided data to the python backend and uses a custom distribution logic which then prepares an &lt;code&gt;Expense()&lt;/code&gt; object rendering the transactions between each participant, all of which is encompassed as a single activity in Splitwise.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    expense = Expense()
    expense.setCost(total_money_paid)

    users = []
    for member in members:
        user = ExpenseUser()
        user.setId(member['id'])

        if(float (member['money']) &amp;gt; 0):
            user.setPaidShare(member['money'])
            #user.setPaidShare('2.00')
        else:
            money = abs(float (member['money']))
            print("money negative", money, flush=True)
            user.setOwedShare(str(money))

        users.append(user)

    expense.setDescription("Testing")
    expense.setUsers(users)
    expense.setGroupId(44555421)

    sObj.createExpense(expense)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Thus essentially settling.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Life before Settlr:&lt;/u&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--49tlLxt_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvykph1csl4i5qyqhp2l.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--49tlLxt_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvykph1csl4i5qyqhp2l.jpeg" alt="Image description" width="800" height="1734"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;User testing Settlr resulted in exponentially faster run-times (as expected) compared to manually updating each activity in Splitwise while also reiterating accuracy.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Life after Settlr:&lt;/u&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7Jn3Xu3Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/geh6rqxz7q849rlaq2gz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7Jn3Xu3Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/geh6rqxz7q849rlaq2gz.png" alt="Image description" width="800" height="1734"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I can't wait to test this out in the upcoming weekend.&lt;/p&gt;

&lt;p&gt;Besides the plethora of quality of life changes I have in the pipeline for Settlr, I was researching into "playing cards and chip identification using computer vision".&lt;/p&gt;

&lt;p&gt;Integrating this concept greatly improves the aspect of "settling" manifold.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>splitwiseapi</category>
      <category>react</category>
      <category>python</category>
    </item>
  </channel>
</rss>
