Zepto
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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
    • 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 Help
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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
    # Anton's board ## 2020.09.04 Transactions: Payments, Prs, Invoices, ... Entries: Debit/Credit Txn: DebitTxn/CreditTxn Submission: DebitTxnSubmission/CreditTxnSubmission # Other Trans Initiator bank account for Transfer must be the one which will later be used in DebitTxn grouping. It must be Bank Account -> debit_processing_banks: [nab_de] -> credit_processing_banks: [nab_npp, nab_de] Debit -> Initiator Bank Account Debit.with_initiator_processing_banks(banks) Proposed solution A: Currently we are relying on Debit.with_initiator_processing_banks scope It's possible to adjust it with new logic, but it's will be too complicated IMO Instead we should add new column Debit.first_processing_bank and set the value So we can do fast and simple query later. Proposed solution B: Debit.virtual_bank_involved Debit.initiator_processing_banks Debit.recipient_processing_banks ### Submission Example Debit.initiator_bank_account (Bank A) + Rule -> config Debit.initiator_bank_account (Bank B) -> config Credit processing bank - usual: copy from Debit - new: if bank_account is virtual then use virtual_bank processing bank Cigno - bank A - real bank account - wbc_t3 processing bank - bank B - Virtual Bank Account - [nab] - debit processing bank - [npp, nab] - credit processing bank Money flow: Debit -> Control Account -> Credit ### Top up transfer transaction Debit (from real bank account): [nab] - debiting merchant bank account A and the processing bank comes from config on bank B Credit (to Virtual Bank Account): [virtual_bank] ### Withdraw transfer transaction Debit (from Virtual Bank Account): [virtual_bank] Credit (to real bank account): [npp, nab] - crediting contact bank account and the processing bank comes from config on bank B Edge case: Credit reversal (to Virtual Bank Account): [virtual_bank] ### Rule When there is a transaction including a Virtual Bank Account, the processing bank should be the one configured on the Virtual Bank Account. Select * From debits where ( # Top-up Debit.initiator_bank_account_id != Debit.from_bank_account_id AND initiator_bank_account.processing_bank.first == query AND debit.source_type == 'Transfer' AND initiator_bank_account.processing_bank.first == query ) OR ( # Withdrawal Debit.initiator_bank_account_id == Debit.from_bank_account_id AND debit.source_type == 'Transfer' AND query == 'virtual' # OR Debit.from_bank_account_id is virtual AND query == 'virtual' ) OR ( # The rest initiator_bank_account.processing_bank.first == query ) # Proposal Solution A * Add Debit.initiator_bank_account_id column * Debit.initiator_bank_account_id will be different for Top-up and Withdraw transactions ## Top-up Debit join Virtual bank account and take config -> nab Credit - if bank_account is virtual then use virtual_bank processing bank - otherwise copy from Debit if Debit.initiator_bank_account_id != Debit.from_bank_account_id use initiator_bank_account config ## Withdraw Debit joins Virtual bank account and take config -> nab , but it should be 'virtual' - lookup query should have a conditional to check if bank account is virtual and always return 'virtual' in that case Credit - if debit is virtual then use debit.initiator_bank_account.credit_processing_bank - otherwise copy from Debit if Debit.initiator_bank_account_id == Debit.from_bank_account_id always 'virtual' # Proposal Solution B Debit processing banks * Add Debit.first_processing_bank column * maybe Debit::Matured * Add Debit.actual_processing_bank column * Include Proposal Solution A * When bank account config is changed we need to refresh Debit.first_processing_bank * Debit.initiator_bank_account ?? * Default processing bank - we can make it work, if we store Debit.first_processing_bank == 'default' * Race condition to deal with Mature on Saturday -> nab Config change on Sunday -> wbc Submit on Monday -> should be wbc, but will nab ## Proposed solution C * calculate processing bank in ruby and not SQL ``` Creating a TransferTxn from_bank_account: bank A (real) to_bank_account: bank B (virtual) Debit.processing_bank - should use bank B processing bank config (so it sits in control account) Credit.processing - virtual ``` # Policy authorisation ```ruby policy = PaymentPolicy.new Payment Refund if payment.can_be_refunded? # Is it doable at all? Can account owner do it? - can_I_refund = policy(@payment).refund? # Can YOU do it - css = can_I_refund ? '' : 'disabled' = button_to 'Refund', url, class: css account - can anybody in my account refund the payment? (includes Feature flags) permission - can I refund the payment? object - can payment be refunded? (excludes Feature flags) #e.g. state check of debit/credit pundit_user + record Policy checks - role - object - feature flag Command checks - inputs - limit checks policy(): role, object, feature flag account_policy(): object, feature flag object_policy(): object * account_policy(@payment).refund? * policy(@payment).refund?() * policy(@payment).refund?(:role, :object, :flag) * policy(@payment).refund?(:account) * policy(@payment).refund?(for: :account) * policy(@payment).refund?(checks: :object) * policy(@payment).refund?(roles: false) * policy(@payment).refund?(:object) * policy(@payment).refund?(skip_roles: true) * policy(@payment).account.refund? * policy(@payment).object.refund? * policy(@payment).anybody.refund? can I create payment? policy(Payment).create? policy(Payment.new).create? policy(account.payments.new).create? auth_css(....) * enable_button_css(policy(@payment).refund?) * policy(@payment).refund?(:button_css) * policy(@payment).button_css(:refund?) * ~~policy(@payment).button_css.refund?~~ * disabled_button_css(policy(@payment).refund?) * auth_check_css(policy(@payment).refund?) = link_to 'Refund', url, policy: policy(@payment).refund?, class: 'this that' -> class: 'this that disabled' = form_for ...., policy: policy(@payment).refund? = simple_form_for ...., policy: policy(@payment).refund? = authorised_form_for import_file, command: Command::ImportFile::Add policy(ImportFile).add? ``` ## High level flow overview Traditional web app: Ajay (Browser) -> Controller -> DB Sync: Ajay (Browser) -> Controller -> Command -> Event -> Projector -> DB -> Reactor (1 off action) -> Event -> Project/Reactor Async: Ajay (Browser) -> Controller -> Command -> Event Event -> DB

    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