Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

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

    Comment


    • #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.

      Comment


      • #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


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

          Comment


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

            Comment


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

              Comment


              • #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

                Comment


                • #9
                  Originally posted by item View Post
                  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...
                  X