How to update new record from previous month record - Stock Module

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nishan Perera
    Active Community Member
    • Jan 2019
    • 348

    How to update new record from previous month record - Stock Module

    Hi,

    I'm trying to create a stock maintaining module inside of the CRM. So I got below entities

    Items - for maintain stock items
    Stocks - maintaining Previous month stock/New stock/New Stock date/Total Stock/Total Issue/Month End Stock/Stock Month
    Supplies - Item Name/Branch/Supply Units/Supply Date



    In this case im stuck with the data fetching from the previous month. I hope that can be done but something there i missed.

    What I need at the moment is to fetch previous month "Month End Stock" to new month field "previous month stock"

    Eg: January 2020 "Month End Stock" = 100 & February 2020 "Previous Month Stock" = 100


    is there anyone know a way to do this. ? Im going to continue this thread as this is help us to built a different module with some complex conditions im guess.
    Cheers!
    Nishan.
  • Nishan Perera
    Active Community Member
    • Jan 2019
    • 348

    #2
    Can I have someone's input for above ?
    Cheers!
    Nishan.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8453

      #3
      Hi,

      Your question is difficult to answer. It's not clear. Whether you asking about how to better design your module or how to fetch something from DB with a specific parameters.
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • Nishan Perera
        Active Community Member
        • Jan 2019
        • 348

        #4
        yuri If you can help me on better design its much easier for me

        Basically what I need is to fetch data with specific parameters.

        As per to the attachments Jan.png containing Month End Stock as 345 what I need is to put that 345 to the Feb.png Previous Month Stock

        Attached Files
        Cheers!
        Nishan.

        Comment

        • Nishan Perera
          Active Community Member
          • Jan 2019
          • 348

          #5
          yuri any luck with above ?
          Cheers!
          Nishan.

          Comment

          • Nishan Perera
            Active Community Member
            • Jan 2019
            • 348

            #6
            yuri Maximus Can I have your input for this ?
            Cheers!
            Nishan.

            Comment

            • Maximus
              Senior Member
              • Nov 2018
              • 2731

              #7
              Hi,
              I believe it is possible to achieve by Hook https://docs.espocrm.com/development/hooks/.

              Comment

              • item
                Active Community Member
                • Mar 2017
                • 1476

                #8
                Hello,
                i think i do like this : a job who run every month

                PHP Code:
                foreach items as item
                   find lastStock
                   create new Stock with lastStock.value and newValue
                   relate newStock to item 
                
                my 2cents idea
                If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

                Comment

                • Nishan Perera
                  Active Community Member
                  • Jan 2019
                  • 348

                  #9
                  Originally posted by item
                  Hello,
                  i think i do like this : a job who run every month

                  PHP Code:
                  foreach items as item
                  find lastStock
                  create new Stock with lastStock.value and newValue
                  relate newStock to item 
                  
                  my 2cents idea
                  item think the idea is good enough. could you please let me know to where do i need to put this code ? is this for formula or inside code ?
                  Cheers!
                  Nishan.

                  Comment

                  Working...