Mario Alberto Sanchez Garcia
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Steps for next projects ## New Cron Jobs - Payment Reset Cron (@ 6AM Chile?) ## New PubSub resources - seller-profile - seller-profile-netsuite-pull - seller_payment_initialization_topic - seller_payment_initialization_subscription - balance_data_retrieval_topic - balance_data_retrieval_subscription - pay_seller_balance_topic - pay_seller_balance_subscription - check_fpay_payment_status_topic - check_fpay_payment_status_subscription ## New Tables in AG DB ### Countries - id - name - enabled (bool) ### Sellers <!--- Do sellers will be generated as multiple sellers when they have different type of operation (local|international) ? ---> - id - fpay_id - day_balance_generated (bool) - countries (json) - Example: ```json= { "cl": { "currency": "CLP", "enabled": true }, "pe": { "currency": "USD", "enabled": false } } ``` - erp_id <!--- vendor_id NetSuite reference? --> - type ### SellerBalances - id - seller_id - date - country - invoices - vendor_bills - vendor_payments <!--- vendor_payments document generated to report payment status ---> - amount_owed - currency - status - Jobs (json) - Example: ```json= [ { "seller_payment_initialization": { "message_id": 12345, "finished": true, "successful": true, "last_execution": "2021-03-21 10:00:00" } }, { "balance_data_retrieval": { "message_id": 12345, "finished": false, "successful": false, "last_execution": "2021-03-21 10:00:00" } } ] ``` - bank_response - settlement_id - … # Seller Creation ## Flow https://confluence.falabella.com/display/CMP/Sellers+-+Create ## Seller Event https://confluence.falabella.com/display/Catalyst/Outbound+Events+and+Schemas#OutboundEventsandSchemas-SellerOutboundEventv2 ## Seller Creation Flow - GSC will send Seller creation Event - AG will receive event from PubSub - AG will query GSC API for seller details. - New seller will be created in DB. - Seller will be created in NetSuite. ## Seller Update Flow - GSC will send Seller Update Event with FPay ID - AG will receive event from PubSub - AG will query GSC API for seller details - Seller FPay ID will be updated to AG DB - (?) Set FPay ID in NetSuite <!--- fpay_id is received as the account_number ---> # Payment Process ## Payment Reset Cron - AG will run a query to set ALL seller’s day_balance_generated to false. - Once its verified that all are false, it will queue a message of type: `seller_payment_initialization_topic` ## Seller Payment Initialization Job - Read X number of sellers which have d tay_balance_generated == false - For each seller - Generate an empty SellerBalance model for the previous day for each country the seller operates in. This should include a parameter for seller ID, country, currency, and the date, with the rest of the fields empty. (This should only happen for the ones that are enabled. If not enabled, log the reason why the balance is not running for the given seller in country x). - Queue a message of type `balance_data_retrieval_topic` for each of the seller’s SellerBalance (making sure to include the `seller_balance_id` parameter for each one) - Add entry to SellerBalance `jobs` field which includes PubSub `message_id`. - Update the seller’s day_balance_generated to true - Repeat the process until we query the DB and there are no sellers with day_balance_generated = false. - Return true once that happens so that job can finish. If anything goes wrong.. return false so that it runs again and processes remaining sellers on the next execution. ## Balance Data Retrieval Job - Job will run with parameter of `seller_balance_id`. - Query DB to get back model of SellerBalance with the given id. This will tell us the date, seller, country, and currency we’re working with. - Query NetSuite for ALL vendorBill and Invoice for this seller, country, day. - Loop through each result - For each record found add to SellerBalance model. - If it's an invoice `$sellerBalance->addInvoice()`. - if its a vendorBill `$sellerBalance->addVendorBill()`. - Once all NetSuite records have been added, calculate the balance and set the value in the model. - Query DB to see which settlement this SellerBalance corresponds to. - If we don’t find a match - Alert log so we can let finance know. This should only happen if someone manually created a VendorBill or Invoice. - If we do find a match - Set the `settlement_id` value of the SellerBalance. - If the amount is different alert log to let finance know. This can happen if someone manually changes the values in NetSuite. - Persist SellerBalance - If the amount_owed is <= 0, we do not need to pay the seller. - (ask Alejandro if we need to do anything else. Do we need to notify GSC if there will be no payment made?) - If the amount_owed is > 0, we need to make a payment. - Queue the `pay_seller_balance_topic` with the `seller_balance_id` as parameter - Add entry to SellerBalance `jobs` field which includes PubSub `message_id`. ## Pay Seller Balance Job - Job will run with parameter of seller_balance_id available. - Query DB to get back model of SellerBalance with the given id. - Query Seller based on the SellerBalance’s seller_id. - Figure out for this seller, country, currency, which bank will be used (can hardcode FPay for now). - Instantiate bank service - Make payment to seller with the necessary amount and currency. - Persist SellerBalance with the status and bank receipt details. - (Ask if we need to notify NetSuite that payment was scheduled). - If the web hook where FPay calls us to let us know the payment was successful/failed is not available we do the steps below. - Queue a `check_fpay_payment_status_topic` with the `seller_balance_id` as parameter. - Add entry to SellerBalance `jobs` field which includes PubSub `message_id`. ## Check Fpay Payment Status Job - Job will run with parameter of `seller_balance_id` available. - Query DB to get model of SellerBalance with the given id. - Perform API request to FPay to get payment status details. - If pending - Return false so that the job runs again in some time. - If rejected - Evaluate the reason for rejection. - If the reason was because we don’t have enough money in the account or something like that.. alert so we can let finance know. - If the reason is because of something which can not be fixed. - Set status to FAILURE - Notify NetSuite somehow (ask Alejandro how they want us to let them know) - Return true so that this job does not try to run again later - If successful - Notify NetSuite by updating the relevant documents - If the settlement id was matched successfully AND its 3P - Notify GSC by hitting their API endpoint # Questions ### Bellido: Can one seller have multiple FPay ID or Payonir ID? Like one per country? > It's possible to have a single seller/vendor created in NetSuite, with multiple subsidiaries. Therefore, we can attach to the seller their respective bank info based on its subsidiary. ### Bellido: Will a seller have 1 seller resource in NetSuite or have multiple like one for each country. > Refer to the previous answer. ### Bellido: How do we alert finance of a system issue? > With logs, and generate them, as more detailed as possible. Make sure we can give all the details of what failed at the moment. ### Bellido: IF seller balance is less than 0, do we still notify GSC? Do we need to do anything else? > Seller Balance less than 0 is viable. We can owe the seller, as well as the opposite. And NetSuite is responsible for the Seller Balance, and we need to rely on what it's reported by it. ### Isabelle: What happens if there are multiple bank info? > Sellers will not have more than 1 bank info: > > * Either they will be national sellers and will be paid through Fpay > * Or they will be international and will be paid in USD through another financial gateway (most likely payoneer) > > Note: sellers from LATAM that wish to sell in a different country (such as seller from CL selling in PE) is not our target as it's a border case today. ### Bellido: What happened if there is a mismatch in the settlements (SellerBalance vs SellerClosing)? > It's expected this kind of behavior, and it is something NetSuite is responsible for. We can't delegate this task to our project and only rely on what NetSuite reports since it's our source of truth. ### Isabelle: What if another field changes in a seller update event? > Yes, sellers could update any other field (expect their tax id (rut in CL)). I think Ale was going to check what could be updated in Netsuite with the Finance area/team. ### Bellido: Which fields of the seller can't be updated? > The finance team needs to coordinate about this topic then they'll let us know which would be the fields that will be updatable. Depending on that communication, we can provide the list of fields allowed to be sent in the scenario of an update event.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully